107 lines
3.0 KiB
Python
107 lines
3.0 KiB
Python
"""
|
|
IncrementalTrader - A modular incremental trading system
|
|
|
|
This module provides a complete framework for incremental trading strategies,
|
|
including real-time data processing, backtesting, and strategy development tools.
|
|
|
|
Key Components:
|
|
- strategies: Incremental trading strategies and indicators
|
|
- trader: Trading execution and position management
|
|
- backtester: Backtesting framework and configuration
|
|
- utils: Utility functions for timeframe aggregation and data management
|
|
|
|
Example:
|
|
from IncrementalTrader import IncTrader, IncBacktester
|
|
from IncrementalTrader.strategies import MetaTrendStrategy
|
|
from IncrementalTrader.utils import MinuteDataBuffer, aggregate_minute_data_to_timeframe
|
|
|
|
# Create strategy
|
|
strategy = MetaTrendStrategy("metatrend", params={"timeframe": "15min"})
|
|
|
|
# Create trader
|
|
trader = IncTrader(strategy, initial_usd=10000)
|
|
|
|
# Use timeframe utilities
|
|
buffer = MinuteDataBuffer(max_size=1440)
|
|
|
|
# Run backtest
|
|
backtester = IncBacktester()
|
|
results = backtester.run_single_strategy(strategy)
|
|
"""
|
|
|
|
__version__ = "1.0.0"
|
|
__author__ = "Cycles Trading Team"
|
|
|
|
# Import main components for easy access
|
|
# Note: These are now available after migration
|
|
try:
|
|
from .trader import IncTrader, TradeRecord, PositionManager, MarketFees
|
|
except ImportError:
|
|
IncTrader = None
|
|
TradeRecord = None
|
|
PositionManager = None
|
|
MarketFees = None
|
|
|
|
try:
|
|
from .backtester import IncBacktester, BacktestConfig, OptimizationConfig
|
|
except ImportError:
|
|
IncBacktester = None
|
|
BacktestConfig = None
|
|
OptimizationConfig = None
|
|
|
|
# Import strategy framework (now available)
|
|
from .strategies import IncStrategyBase, IncStrategySignal, TimeframeAggregator
|
|
|
|
# Import available strategies
|
|
from .strategies import (
|
|
MetaTrendStrategy,
|
|
IncMetaTrendStrategy, # Compatibility alias
|
|
RandomStrategy,
|
|
IncRandomStrategy, # Compatibility alias
|
|
BBRSStrategy,
|
|
IncBBRSStrategy, # Compatibility alias
|
|
)
|
|
|
|
# Import timeframe utilities (new)
|
|
from .utils import (
|
|
aggregate_minute_data_to_timeframe,
|
|
parse_timeframe_to_minutes,
|
|
get_latest_complete_bar,
|
|
MinuteDataBuffer,
|
|
TimeframeError
|
|
)
|
|
|
|
# Public API
|
|
__all__ = [
|
|
# Core components (now available after migration)
|
|
"IncTrader",
|
|
"IncBacktester",
|
|
"BacktestConfig",
|
|
"OptimizationConfig",
|
|
"TradeRecord",
|
|
"PositionManager",
|
|
"MarketFees",
|
|
|
|
# Strategy framework (available now)
|
|
"IncStrategyBase",
|
|
"IncStrategySignal",
|
|
"TimeframeAggregator",
|
|
|
|
# Available strategies
|
|
"MetaTrendStrategy",
|
|
"IncMetaTrendStrategy", # Compatibility alias
|
|
"RandomStrategy",
|
|
"IncRandomStrategy", # Compatibility alias
|
|
"BBRSStrategy",
|
|
"IncBBRSStrategy", # Compatibility alias
|
|
|
|
# Timeframe utilities (new)
|
|
"aggregate_minute_data_to_timeframe",
|
|
"parse_timeframe_to_minutes",
|
|
"get_latest_complete_bar",
|
|
"MinuteDataBuffer",
|
|
"TimeframeError",
|
|
|
|
# Version info
|
|
"__version__",
|
|
] |