(20241223) Zerodha auth now returns views.

This commit is contained in:
2024-12-23 16:27:52 +05:30
parent 3296fec639
commit 58e91fb15f
16 changed files with 112 additions and 294 deletions
View File
View File
@@ -42,10 +42,6 @@ import os
# my utils:
from utils_v2.string import json
# To work with SocketIO:
import socketio
from aiohttp import web
# For asynchronous activities:
import asyncio
@@ -60,7 +56,8 @@ from icecream import IceCreamDebugger
# *****************************************************************************************************************
# --- Nothing Yet
# Debugging:
printer = IceCreamDebugger(prefix = "SocketIO | ", includeContext = True)
# *****************************************************************************************************************
@@ -70,13 +67,7 @@ from icecream import IceCreamDebugger
# *****************************************************************************************************************
# The SocketIo server:
sio = socketio.AsyncServer(cors_allowed_origins = "*")
app = web.Application()
sio.attach(app)
# Debugging:
printer = IceCreamDebugger(prefix = "SocketIO | ", includeContext = True)
# --- Nothing Yet
# *****************************************************************************************************************
@@ -86,30 +77,8 @@ printer = IceCreamDebugger(prefix = "SocketIO | ", includeContext = True)
# *****************************************************************************************************************
@sio.event
async def connect(sid, environ):
printer(sid)
# ---------------------------------------------------------------------------------------------------------------------
@sio.event
async def disconnect(sid):
printer(sid)
# ---------------------------------------------------------------------------------------------------------------------
async def init():
"""
Initialize stuff here.
:return: ?
"""
pass
async def subscribe(sid, data):
printer(data)
# *****************************************************************************************************************
@@ -121,20 +90,4 @@ async def init():
if __name__ == "__main__":
async def main():
# Start receiving live market data in the background:
# asyncio.create_task(start_live_feed())
# Run the web server:
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", 5214)
printer("Server running.")
await site.start()
# Keep the server running:
while True: await asyncio.sleep(3_600)
# Let's go:
asyncio.run(main())
pass
+29 -18
View File
@@ -52,6 +52,13 @@ import asyncio
# for debugging:
from icecream import IceCreamDebugger
# To work with date and time:
import time
import datetime
# To work with Zerodha's Kite platform:
from kiteconnect import KiteConnect, KiteTicker
# *****************************************************************************************************************
# ***** ****
@@ -60,7 +67,23 @@ from icecream import IceCreamDebugger
# *****************************************************************************************************************
# --- Nothing Yet
INSTRUMENT_MAP = {
256265: "NIFTY 50",
260617: "NIFTY 100",
259849: "NIFTY IT",
341249: "HDFCBANK",
738561: "RELIANCE",
408065: "INFY",
2953217: "TCS",
356865: "HINDUNILVR",
1270529: "ICICIBANK",
492033: "KOTAKBANK",
110630919: "GOLD25JAN75800CE",
110050823: "SILVER25FEB76000CE",
10670594: "NIFTY24DEC23650PE",
17167874: "BANKNIFTY24DEC45000PE",
}
INSTRUMENT_TOKENS = list(INSTRUMENT_MAP.keys())
# *****************************************************************************************************************
@@ -99,19 +122,6 @@ async def disconnect(sid):
printer(sid)
# ---------------------------------------------------------------------------------------------------------------------
async def init():
"""
Initialize stuff here.
:return: ?
"""
pass
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***
@@ -121,20 +131,21 @@ async def init():
if __name__ == "__main__":
# Import the needed events:
from wsocket.finstitutions.trading import live_feed
async def main():
# Start receiving live market data in the background:
# asyncio.create_task(start_live_feed())
# register all the events:
sio.on("subscribe", live_feed.subscribe)
# Run the web server:
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", 5214)
printer("Server running.")
await site.start()
# Keep the server running:
while True: await asyncio.sleep(3_600)
# Let's go:
asyncio.run(main())