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.