This commit is contained in:
Dobromir Popov
2025-08-05 00:38:41 +03:00
parent 3bbfde5d2b
commit 3e0d7d5a99
7 changed files with 30 additions and 127 deletions

View File

@ -143,9 +143,9 @@ class StandardAggregationEngine(AggregationEngine):
except Exception as e:
logger.error(f"Error aggregating across exchanges: {e}")
raise AggregationError(f"Cross-exchange aggregation failed: {e}", "CONSOLIDATION_ERROR")
def calculate_volume_weighted_price(self, orderbooks: List[OrderBookSnapshot]) -> float:
raise AggregationError(f"Cross-exchange aggregation failed: {e}", "CONSOLIDATION_ERROR")
def calculate_volume_weighted_price(self, orderbooks: List[OrderBookSnapshot]) -> float:
"""
Calculate volume-weighted average price across exchanges.

View File

@ -118,6 +118,18 @@ class PriceBucketer:
logger.debug(f"Aggregated {len(bucket_list)} bucket sets")
return aggregated
def get_bucket_price(self, price: float) -> float:
"""
Get the bucket price for a given price.
Args:
price: Original price
Returns:
float: Bucket price (rounded to bucket boundaries)
"""
return math.floor(price / self.bucket_size) * self.bucket_size
def get_bucket_range(self, center_price: float, depth: int) -> Tuple[float, float]:
"""
Get price range for buckets around a center price.

View File

@ -111,11 +111,9 @@ class Config:
log_dir = Path(self.logging.file_path).parent
log_dir.mkdir(parents=True, exist_ok=True)
# Validate bucket sizes
if self.aggregation.btc_bucket_size <= 0:
raise ValueError("BTC bucket size must be positive")
if self.aggregation.eth_bucket_size <= 0:
raise ValueError("ETH bucket size must be positive")
# Validate bucket size
if self.aggregation.bucket_size <= 0:
raise ValueError("Bucket size must be positive")
def get_bucket_size(self, symbol: str = None) -> float:
"""Get bucket size (now universal $1 for all symbols)"""

View File

@ -10,6 +10,7 @@ from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Callable, Any
from datetime import datetime, timedelta
from ..models.core import ConnectionStatus, OrderBookSnapshot, TradeEvent
from ..interfaces.exchange_connector import ExchangeConnector
from ..utils.logging import get_logger, set_correlation_id
from ..utils.exceptions import ConnectionError, ValidationError
from ..utils.timing import get_current_timestamp

View File

@ -94,8 +94,9 @@ class DataQualityChecker:
if issues:
logger.debug(f"Order book quality issues for {orderbook.symbol}@{orderbook.exchange}: {issues}")
return quality_score, issues de
f check_trade_quality(self, trade: TradeEvent) -> Tuple[float, List[str]]:
return quality_score, issues
def check_trade_quality(self, trade: TradeEvent) -> Tuple[float, List[str]]:
"""
Check trade data quality.
@ -197,8 +198,9 @@ f check_trade_quality(self, trade: TradeEvent) -> Tuple[float, List[str]]:
if orderbook.bids[0].price >= orderbook.asks[0].price:
issues.append("Best bid >= best ask (crossed book)")
return issues def
_check_orderbook_volumes(self, orderbook: OrderBookSnapshot) -> List[str]:
return issues
def _check_orderbook_volumes(self, orderbook: OrderBookSnapshot) -> List[str]:
"""Check order book volume validity"""
issues = []