(20241226) With new bash scripts for SocketIO.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kill all the scripts:
|
||||
echo "Killing the script."
|
||||
pkill -9 -f "$(pwd)/wsio/finstitutions/trading/main.py"
|
||||
|
||||
# All done:
|
||||
echo "Done!"
|
||||
exit 0
|
||||
@@ -185,6 +185,7 @@ def main():
|
||||
# Get the instruments of interest:
|
||||
response = httpx.post(url = r"https://api.thecaoffice.com/markets/watchlist/distincts")
|
||||
instruments_of_interest = response.json()["data"]["rs0"]
|
||||
print("TOTAL INSTR. OF INTEREST:", len(instruments_of_interest))
|
||||
symbols_of_interest = [i["symbol"] for i in instruments_of_interest]
|
||||
|
||||
# Create an instance of Zerodha's Kite connection:
|
||||
@@ -192,17 +193,18 @@ def main():
|
||||
kite.set_access_token(access_token)
|
||||
|
||||
# Get the entire list of instruments:
|
||||
instruments = kite.instruments(exchange = "NSE")
|
||||
instruments += kite.instruments(exchange = "NFO")
|
||||
instruments += kite.instruments(exchange = "BSE")
|
||||
instruments += kite.instruments(exchange = "BFO")
|
||||
instruments = []
|
||||
# instruments += kite.instruments(exchange = "NSE")
|
||||
# instruments += kite.instruments(exchange = "NFO")
|
||||
# instruments += kite.instruments(exchange = "BSE")
|
||||
# instruments += kite.instruments(exchange = "BFO")
|
||||
instruments += kite.instruments(exchange = "MCX")
|
||||
instruments += kite.instruments(exchange = "CDS")
|
||||
instruments += kite.instruments(exchange = "BCD")
|
||||
# instruments += kite.instruments(exchange = "CDS")
|
||||
# instruments += kite.instruments(exchange = "BCD")
|
||||
|
||||
# # Pick the instruments of interest:
|
||||
# instruments = [TradingSymbol.from_zerodha_kite(i) for i in instruments[:1000]]
|
||||
instruments = [TradingSymbol.from_zerodha_kite(i) for i in instruments if i["tradingsymbol"] in symbols_of_interest]
|
||||
instruments = [TradingSymbol.from_zerodha_kite(i) for i in instruments[:1000]]
|
||||
# instruments = [TradingSymbol.from_zerodha_kite(i) for i in instruments if i["tradingsymbol"] in symbols_of_interest]
|
||||
|
||||
# Create the lookup:
|
||||
for i in instruments:
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Use this to run the microservice without any docker setup.
|
||||
source .venv/bin/activate
|
||||
python3 "$(pwd)/wsio/finstitutions/trading/main.py" --host "0.0.0.0" --port 5214 --script-id "kps_cnv_KBC3MoaU" &
|
||||
deactivate
|
||||
|
||||
# All done:
|
||||
echo "Done!"
|
||||
exit 0
|
||||
@@ -57,6 +57,7 @@ from models.finstitutions.trading.symbols import TradingSymbol
|
||||
from models.finstitutions.trading.ticks import TradingTick
|
||||
|
||||
# To work with SocketIO:
|
||||
import socket
|
||||
import socketio
|
||||
|
||||
# For asynchronous activities:
|
||||
@@ -80,6 +81,9 @@ from icecream import IceCreamDebugger
|
||||
printer = IceCreamDebugger(prefix = "Tick-Disp, | ", includeContext = True)
|
||||
printer.disable()
|
||||
|
||||
# General:
|
||||
SERVER_HOSTNAME = str(socket.gethostname())
|
||||
|
||||
# For SocketIO:
|
||||
sio = socketio.AsyncServer(async_mode = "asgi")
|
||||
app = socketio.ASGIApp(sio)
|
||||
@@ -238,6 +242,7 @@ async def init():
|
||||
ticks_from_kafka,
|
||||
consumer = ConsumerKafka(
|
||||
topic = "tickers",
|
||||
group_id = f"{SERVER_HOSTNAME}_tickers",
|
||||
bootstrap_servers = "del.ditscentre.in:9092",
|
||||
security_protocol = "SSL",
|
||||
ssl_context = get_ssl_context(
|
||||
|
||||
Reference in New Issue
Block a user