Rewrote main.py
This commit is contained in:
35
main.py
35
main.py
@@ -1,23 +1,20 @@
|
||||
import sys
|
||||
from utils import load_config, create_mqttc
|
||||
from tastytrade import OAuthSession
|
||||
from loguru import logger
|
||||
from producers.sp500 import get_spx_market, stream_spx_greeks
|
||||
import asyncio
|
||||
import json
|
||||
import tomllib
|
||||
import paho.mqtt.client as paho
|
||||
import time
|
||||
from utils import load_config, authenticate
|
||||
|
||||
config = load_config()
|
||||
#client = paho.Client(paho.CallbackAPIVersion.VERSION2)
|
||||
#client.username_pw_set(username=config.mqtt.username,password=config.mqtt.password)
|
||||
session = OAuthSession(config.tasty_trade.client_secret,config.tasty_trade.refresh_token)
|
||||
logger.info("Tasty Trade session instantiated")
|
||||
|
||||
#if client.connect("proliant.lan", 1883, 60) != 0:
|
||||
#print("Couldn't connect to the mqtt broker")
|
||||
#sys.exit(1)
|
||||
async def main():
|
||||
functions = [get_spx_market, stream_spx_greeks]
|
||||
tasks = []
|
||||
for function in functions:
|
||||
task = asyncio.create_task(function(session))
|
||||
tasks.append(task)
|
||||
for task in tasks:
|
||||
await task
|
||||
|
||||
|
||||
#client.publish("SP500", json.dumps({"value":6349}), 0)
|
||||
#time.sleep(0.5)
|
||||
|
||||
|
||||
#client.disconnect()
|
||||
|
||||
authenticate()
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user