wip cob test
This commit is contained in:
@ -59,6 +59,18 @@ class COBStabilityTester:
|
|||||||
|
|
||||||
def _cob_data_callback(self, symbol: str, cob_data: dict):
|
def _cob_data_callback(self, symbol: str, cob_data: dict):
|
||||||
"""Callback function to receive COB data from the DataProvider."""
|
"""Callback function to receive COB data from the DataProvider."""
|
||||||
|
# Debug: Log first few callbacks to see what symbols we're getting
|
||||||
|
if self.cob_data_received < 5:
|
||||||
|
logger.info(f"DEBUG: Received COB data for symbol '{symbol}' (target: '{self.symbol}')")
|
||||||
|
|
||||||
|
# Filter to only our requested symbol - handle both formats (ETH/USDT and ETHUSDT)
|
||||||
|
normalized_symbol = symbol.replace('/', '')
|
||||||
|
normalized_target = self.symbol.replace('/', '')
|
||||||
|
if normalized_symbol != normalized_target:
|
||||||
|
if self.cob_data_received < 5:
|
||||||
|
logger.info(f"DEBUG: Skipping symbol '{symbol}' (normalized: '{normalized_symbol}' vs target: '{normalized_target}')")
|
||||||
|
return
|
||||||
|
|
||||||
self.cob_data_received += 1
|
self.cob_data_received += 1
|
||||||
self.latest_cob_data[symbol] = cob_data
|
self.latest_cob_data[symbol] = cob_data
|
||||||
|
|
||||||
@ -168,11 +180,22 @@ class COBStabilityTester:
|
|||||||
timestamp = snapshot['timestamp']
|
timestamp = snapshot['timestamp']
|
||||||
for side in ['bids', 'asks']:
|
for side in ['bids', 'asks']:
|
||||||
for order in snapshot[side]:
|
for order in snapshot[side]:
|
||||||
bucketed_price = round(order['price'] / self.price_granularity) * self.price_granularity
|
# Handle both dict and list formats
|
||||||
|
if isinstance(order, dict):
|
||||||
|
price = order['price']
|
||||||
|
size = order['size']
|
||||||
|
elif isinstance(order, (list, tuple)) and len(order) >= 2:
|
||||||
|
price = float(order[0])
|
||||||
|
size = float(order[1])
|
||||||
|
else:
|
||||||
|
logger.warning(f"Unknown order format: {order}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
bucketed_price = round(price / self.price_granularity) * self.price_granularity
|
||||||
heatmap_data.append({
|
heatmap_data.append({
|
||||||
'time': timestamp,
|
'time': timestamp,
|
||||||
'price': bucketed_price,
|
'price': bucketed_price,
|
||||||
'size': order['size'],
|
'size': size,
|
||||||
'side': side
|
'side': side
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user