- Introduced a comprehensive framework for incremental trading strategies, including modules for strategy execution, backtesting, and data processing. - Added key components such as `IncTrader`, `IncBacktester`, and various trading strategies (e.g., `MetaTrendStrategy`, `BBRSStrategy`, `RandomStrategy`) to facilitate real-time trading and backtesting. - Implemented a robust backtesting framework with configuration management, parallel execution, and result analysis capabilities. - Developed an incremental indicators framework to support real-time data processing with constant memory usage. - Enhanced documentation to provide clear usage examples and architecture overview, ensuring maintainability and ease of understanding for future development. - Ensured compatibility with existing strategies and maintained a focus on performance and scalability throughout the implementation.
91 lines
2.0 KiB
Python
91 lines
2.0 KiB
Python
"""
|
|
Incremental Indicators Framework
|
|
|
|
This module provides incremental indicator implementations for real-time trading strategies.
|
|
All indicators maintain constant memory usage and provide identical results to traditional
|
|
batch calculations.
|
|
|
|
Available Indicators:
|
|
- Base classes: IndicatorState, SimpleIndicatorState, OHLCIndicatorState
|
|
- Moving Averages: MovingAverageState, ExponentialMovingAverageState
|
|
- Volatility: ATRState, SimpleATRState
|
|
- Trend: SupertrendState, SupertrendCollection
|
|
- Bollinger Bands: BollingerBandsState, BollingerBandsOHLCState
|
|
- RSI: RSIState, SimpleRSIState
|
|
|
|
Example:
|
|
from IncrementalTrader.strategies.indicators import SupertrendState, ATRState
|
|
|
|
# Create indicators
|
|
atr = ATRState(period=14)
|
|
supertrend = SupertrendState(period=10, multiplier=3.0)
|
|
|
|
# Update with OHLC data
|
|
ohlc = {'open': 100, 'high': 105, 'low': 98, 'close': 103}
|
|
atr_value = atr.update(ohlc)
|
|
st_result = supertrend.update(ohlc)
|
|
"""
|
|
|
|
# Base indicator classes
|
|
from .base import (
|
|
IndicatorState,
|
|
SimpleIndicatorState,
|
|
OHLCIndicatorState,
|
|
)
|
|
|
|
# Moving average indicators
|
|
from .moving_average import (
|
|
MovingAverageState,
|
|
ExponentialMovingAverageState,
|
|
)
|
|
|
|
# Volatility indicators
|
|
from .atr import (
|
|
ATRState,
|
|
SimpleATRState,
|
|
)
|
|
|
|
# Trend indicators
|
|
from .supertrend import (
|
|
SupertrendState,
|
|
SupertrendCollection,
|
|
)
|
|
|
|
# Bollinger Bands indicators
|
|
from .bollinger_bands import (
|
|
BollingerBandsState,
|
|
BollingerBandsOHLCState,
|
|
)
|
|
|
|
# RSI indicators
|
|
from .rsi import (
|
|
RSIState,
|
|
SimpleRSIState,
|
|
)
|
|
|
|
__all__ = [
|
|
# Base classes
|
|
"IndicatorState",
|
|
"SimpleIndicatorState",
|
|
"OHLCIndicatorState",
|
|
|
|
# Moving averages
|
|
"MovingAverageState",
|
|
"ExponentialMovingAverageState",
|
|
|
|
# Volatility indicators
|
|
"ATRState",
|
|
"SimpleATRState",
|
|
|
|
# Trend indicators
|
|
"SupertrendState",
|
|
"SupertrendCollection",
|
|
|
|
# Bollinger Bands
|
|
"BollingerBandsState",
|
|
"BollingerBandsOHLCState",
|
|
|
|
# RSI indicators
|
|
"RSIState",
|
|
"SimpleRSIState",
|
|
] |