saving
This commit is contained in:
18
ws_clob.py
18
ws_clob.py
@@ -13,6 +13,7 @@ from typing import AsyncContextManager
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
import valkey
|
||||
import time
|
||||
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
@@ -27,7 +28,7 @@ VAL_KEY = None
|
||||
|
||||
### Logging ###
|
||||
load_dotenv()
|
||||
LOG_FILEPATH: str = os.getenv("LOGS_PATH") + '/Polymarket_5min.log'
|
||||
LOG_FILEPATH: str = os.getenv("LOGS_PATH") + '/Polymarket_CLOB.log'
|
||||
|
||||
WSS_URL = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
|
||||
SLUG_END_TIME = 0
|
||||
@@ -67,10 +68,10 @@ def get_mkt_details_by_slug(slug: str) -> dict[str, str, str]: # {'Up' : 123, 'D
|
||||
d['ConditionId'] = market['conditionId']
|
||||
d['EndDateTime'] = market['endDate']
|
||||
# d['Liquidity'] = market['liquidity']
|
||||
d['LiquidityClob'] = market['liquidityClob']
|
||||
d['VolumeNum'] = market['volumeNum']
|
||||
d['Volume24hr'] = market['volume24hr']
|
||||
print(market)
|
||||
# d['LiquidityClob'] = market['liquidityClob']
|
||||
# d['VolumeNum'] = market['volumeNum']
|
||||
# d['Volume24hr'] = market['volume24hr']
|
||||
logging.info(f'MARKET CHANGED: {market}')
|
||||
|
||||
return d, market
|
||||
|
||||
@@ -197,6 +198,7 @@ async def polymarket_stream():
|
||||
sec_remaining = SLUG_END_TIME - round(datetime.now().timestamp())
|
||||
|
||||
if sec_remaining <= 0:
|
||||
time.sleep(0.1)
|
||||
ref_data = json.loads(VAL_KEY.get('poly_rtds_cl_btcusd'))
|
||||
TARGET_PX = float(ref_data['value'])
|
||||
HIST_TRADES = np.empty((0, 2))
|
||||
@@ -316,15 +318,15 @@ async def polymarket_stream():
|
||||
continue
|
||||
elif event_type == "market_resolved":
|
||||
print(f"Received: {event_type}")
|
||||
print(data)
|
||||
# print(data)
|
||||
continue
|
||||
elif event_type == "tick_size_change": # may want for CLOB order routing
|
||||
print(f"Received: {event_type}")
|
||||
print(data)
|
||||
# print(data)
|
||||
continue
|
||||
else:
|
||||
print(f"*********** REC UNMAPPED EVENT: {event_type}")
|
||||
print(data)
|
||||
# print(data)
|
||||
continue
|
||||
elif isinstance(data, dict):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user