Refactor aggregation module and enhance structure
- Split the `aggregation.py` file into a dedicated sub-package, improving modularity and maintainability. - Moved `TimeframeBucket`, `RealTimeCandleProcessor`, and `BatchCandleProcessor` classes into their respective files within the new `aggregation` sub-package. - Introduced utility functions for trade aggregation and validation, enhancing code organization. - Updated import paths throughout the codebase to reflect the new structure, ensuring compatibility. - Added safety net tests for the aggregation package to verify core functionality and prevent regressions during refactoring. These changes enhance the overall architecture of the aggregation module, making it more scalable and easier to manage.
This commit is contained in:
@@ -398,12 +398,21 @@ candles = transformer.process_trades_to_candles(
|
||||
|
||||
**Real-time candle processing:**
|
||||
```python
|
||||
# Same code works for any exchange
|
||||
candle_processor = RealTimeCandleProcessor(symbol, exchange, config)
|
||||
candle_processor.add_candle_callback(my_candle_handler)
|
||||
# Example usage
|
||||
from data.common.aggregation.realtime import RealTimeCandleProcessor
|
||||
|
||||
for trade in real_time_trades:
|
||||
completed_candles = candle_processor.process_trade(trade)
|
||||
processor = RealTimeCandleProcessor(symbol, "binance", config)
|
||||
processor.add_candle_callback(on_candle_completed)
|
||||
processor.process_trade(trade)
|
||||
```
|
||||
|
||||
```python
|
||||
# Example usage
|
||||
from data.common.aggregation.realtime import RealTimeCandleProcessor
|
||||
|
||||
candle_processor = RealTimeCandleProcessor(symbol, exchange, config)
|
||||
candle_processor.add_candle_callback(on_candle_completed)
|
||||
candle_processor.process_trade(trade)
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -164,7 +164,7 @@ The indicators module is designed to work seamlessly with the TCP platform's agg
|
||||
### Real-Time Processing
|
||||
|
||||
```python
|
||||
from data.common.aggregation import RealTimeCandleProcessor
|
||||
from data.common.aggregation.realtime import RealTimeCandleProcessor
|
||||
from data.common.indicators import TechnicalIndicators
|
||||
|
||||
# Set up real-time processing
|
||||
|
||||
Reference in New Issue
Block a user