-`config/strategies/user_strategies/` - Directory for user-defined strategy configurations
-`config/strategies/config_utils.py` - Strategy configuration utilities and validation
-`database/models.py` - Updated to include strategy signals table definition
-`database/repositories/strategy_repository.py` - Strategy signals repository following repository pattern
-`database/operations.py` - Updated to include strategy operations access
-`database/migrations/versions/add_strategy_signals_table.py` - Alembic migration for strategy signals table
-`components/charts/layers/strategy_signals.py` - Strategy signal chart layer for visualization
-`components/charts/data_integration.py` - Updated to include strategy data integration
-`tests/strategies/test_base_strategy.py` - Unit tests for BaseStrategy abstract class
-`tests/strategies/test_strategy_factory.py` - Unit tests for strategy factory system
-`tests/strategies/test_strategy_manager.py` - Unit tests for StrategyManager class
-`tests/strategies/implementations/test_ema_crossover.py` - Unit tests for EMA Crossover strategy
-`tests/strategies/implementations/test_rsi.py` - Unit tests for RSI strategy
-`tests/strategies/implementations/test_macd.py` - Unit tests for MACD strategy
-`tests/database/test_strategy_repository.py` - Unit tests for strategy repository
### Notes
- **Strict Adherence to Indicator Patterns**: The strategy engine components (BaseStrategy, StrategyFactory, StrategyManager, Strategy implementations, and configurations) MUST strictly mirror the existing `data/common/indicators/` module's structure, factory approach, and configuration management. This ensures consistency and simplifies development.
- **Database Segregation for Signals**: The newly created `strategy_signals` table is exclusively for strategy analysis and backtesting results, distinct from the existing `signals` table which is for live bot trading operations. Maintain this clear separation.
- **Initial Full Recalculation**: For real-time strategy execution, strategies will initially recalculate completely on each new candle, similar to how technical indicators currently operate. Optimizations for incremental updates can be considered in a later phase.
- **Multi-timeframe Support**: Strategies should be designed to support and utilize market data from multiple timeframes, following the pattern established by indicators that can consume data from different timeframes.
- **Exclusive Use of Repository Pattern**: All database interactions, including storing and retrieving strategy signals and run data, must be performed exclusively through the `StrategyRepository` and other existing repositories. Avoid raw SQL queries.
- **JSON-based Configuration**: Strategy parameters and configurations are to be managed via JSON files within `config/strategies/`, aligning with the existing configuration system for indicators and other components.
- **Layered Chart Integration**: Strategy signals and performance visualizations will be integrated into the dashboard as a new chart layer, utilizing the existing modular chart system.
- **Comprehensive Testing**: Ensure that all new classes, functions, and modules within the strategy engine have corresponding unit tests placed in the `tests/strategies/` directory, following established testing conventions.
- **Decision**: Refactored strategy signal detection to use vectorized Pandas operations (e.g., `shift()`, boolean indexing) instead of iterative Python loops.
- **Reasoning**: Significantly improves performance for signal generation, especially with large datasets, while maintaining identical results as verified by dedicated tests.
- **Impact**: All core strategy implementations (EMA Crossover, RSI, MACD) now leverage vectorized functions for their primary signal detection logic.
### 2. Indicator Key Generation Consistency
- **Decision**: Centralized the `_create_indicator_key` logic into a shared utility function `create_indicator_key()` in `strategies/utils.py`.
- **Reasoning**: Eliminates code duplication in `StrategyFactory` and individual strategy implementations, ensuring consistent key generation and easier maintenance if indicator naming conventions change.
- **Impact**: `StrategyFactory` and all strategy implementations now use this shared utility for generating unique indicator keys.
- **Decision**: The `calculate_multiple_strategies` method was removed from `strategies/factory.py`.
- **Reasoning**: This functionality is not immediately required for the current phase of development and can be re-introduced later when needed, to simplify the codebase and testing efforts.
- **Impact**: The `StrategyFactory` now focuses on calculating signals for individual strategies, simplifying its interface and reducing initial complexity.
### 4. `strategy_name` in Concrete Strategy `__init__`
- **Decision**: Updated the `__init__` methods of concrete strategy implementations (e.g., `EMAStrategy`, `RSIStrategy`, `MACDStrategy`) to accept and pass `strategy_name` to `BaseStrategy.__init__`.
- **Reasoning**: Ensures consistency with the `BaseStrategy` abstract class, which now requires `strategy_name` during initialization, providing a clear identifier for each strategy instance.
- **Impact**: All strategy implementations now correctly initialize their `strategy_name` via the base class, standardizing strategy identification across the engine.