refactor algo orchestrator and hedge ratio bug fix
This commit is contained in:
@@ -26,7 +26,6 @@ load_dotenv()
|
||||
LOG_FILEPATH: str = os.getenv("LOGS_PATH") + '/Fund_Rate_Algo_Orchestrator.log'
|
||||
|
||||
ALGO_CONFIG: None | dict
|
||||
# ALGO_CONFIG: None | Algo_Config = None
|
||||
|
||||
async def orchestrator() -> None:
|
||||
global ALGO_CONFIG
|
||||
@@ -35,7 +34,7 @@ async def orchestrator() -> None:
|
||||
VK_PUBSUB = VAL_KEY.pubsub()
|
||||
VK_PUBSUB.subscribe(VK_IN)
|
||||
|
||||
print(f"Subscribed to '{VK_IN}'. Waiting for messages...")
|
||||
logging.info(f"Subscribed to '{VK_IN}'. Waiting for messages...")
|
||||
|
||||
for message in VK_PUBSUB.listen():
|
||||
if message['type'] == 'message':
|
||||
@@ -46,7 +45,7 @@ async def orchestrator() -> None:
|
||||
with open('/algo_local_drive/algo_config.json', 'r', encoding='utf-8') as f:
|
||||
# ALGO_CONFIG = json.load(f, object_hook=lambda d: Algo_Config(**d))
|
||||
ALGO_CONFIG = json.load(f)
|
||||
ALGO_CONFIG['Config_Updated_Timestamp'] = timestamp
|
||||
ALGO_CONFIG['Updated_Timestamp'] = timestamp
|
||||
|
||||
for k, v in data.items():
|
||||
if ALGO_CONFIG.get(k, None) is not None:
|
||||
@@ -54,12 +53,11 @@ async def orchestrator() -> None:
|
||||
|
||||
VAL_KEY.set(VK_OUT, json.dumps(ALGO_CONFIG))
|
||||
with open('/algo_local_drive/algo_config.json', 'w', encoding='utf-8') as f:
|
||||
# print('SAVING FILE')
|
||||
json.dump(ALGO_CONFIG, f, indent=4)
|
||||
print(f"Algo Config Updated @ {timestamp}; {data}")
|
||||
logging.info(f"Algo Config Updated @ {timestamp}; {data}")
|
||||
|
||||
except valkey.exceptions.ConnectionError as e:
|
||||
print(f"Could not connect to Valkey. Please check the publish server is up; {e}")
|
||||
logging.info(f"Could not connect to Valkey. Please check the publish server is up; {e}")
|
||||
except KeyboardInterrupt:
|
||||
logging.info('ORCHESTRATOR SHUTTING DOWN...')
|
||||
except Exception as e:
|
||||
@@ -78,7 +76,7 @@ async def main() -> None:
|
||||
with open('/algo_local_drive/algo_config.json', 'r', encoding='utf-8') as f:
|
||||
# ALGO_CONFIG = json.load(f, object_hook=lambda d: Algo_Config(**d))
|
||||
ALGO_CONFIG = json.load(f)
|
||||
ALGO_CONFIG['Config_Updated_Timestamp'] = round(datetime.now().timestamp()*1000)
|
||||
ALGO_CONFIG['Updated_Timestamp'] = round(datetime.now().timestamp()*1000)
|
||||
|
||||
# async with engine.connect() as CON:
|
||||
await orchestrator()
|
||||
|
||||
Reference in New Issue
Block a user