4.0 - 2.0 Implement strategy configuration utilities and templates
- Introduced `config_utils.py` for loading and managing strategy configurations, including functions for loading templates, generating dropdown options, and retrieving parameter schemas and default values. - Added JSON templates for EMA Crossover, MACD, and RSI strategies, defining their parameters and validation rules to enhance modularity and maintainability. - Implemented `StrategyManager` in `manager.py` for managing user-defined strategies with file-based storage, supporting easy sharing and portability. - Updated `__init__.py` to include new components and ensure proper module exports. - Enhanced error handling and logging practices across the new modules for improved reliability. These changes establish a robust foundation for strategy management and configuration, aligning with project goals for modularity, performance, and maintainability.
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
- `strategies/utils.py` - Strategy utility functions and helpers
|
||||
- `strategies/data_types.py` - Strategy-specific data types and signal definitions
|
||||
- `config/strategies/templates/` - Directory for JSON strategy templates
|
||||
- `config/strategies/templates/ema_crossover_template.json` - EMA crossover strategy template with schema
|
||||
- `config/strategies/templates/rsi_template.json` - RSI strategy template with schema
|
||||
- `config/strategies/templates/macd_template.json` - MACD strategy template with schema
|
||||
- `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
|
||||
@@ -50,6 +53,16 @@
|
||||
- **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.
|
||||
|
||||
### 3. Removal of `calculate_multiple_strategies`
|
||||
- **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.
|
||||
|
||||
## Tasks
|
||||
|
||||
- [x] 1.0 Core Strategy Foundation Setup
|
||||
@@ -64,16 +77,16 @@
|
||||
- [x] 1.9 Create `strategies/utils.py` with helper functions for signal validation and processing
|
||||
- [x] 1.10 Create comprehensive unit tests for all strategy foundation components
|
||||
|
||||
- [ ] 2.0 Strategy Configuration System
|
||||
- [ ] 2.1 Create `config/strategies/` directory structure mirroring indicators configuration
|
||||
- [ ] 2.2 Implement `config/strategies/config_utils.py` with configuration validation and loading functions
|
||||
- [ ] 2.3 Create JSON schema definitions for strategy parameters and validation rules
|
||||
- [ ] 2.4 Create strategy templates in `config/strategies/templates/` for common strategy configurations
|
||||
- [ ] 2.5 Implement `StrategyManager` class in `strategies/manager.py` following `IndicatorManager` pattern
|
||||
- [ ] 2.6 Add strategy configuration loading and saving functionality with file-based storage
|
||||
- [ ] 2.7 Create user strategies directory `config/strategies/user_strategies/` for custom configurations
|
||||
- [ ] 2.8 Implement strategy parameter validation and default value handling
|
||||
- [ ] 2.9 Add configuration export/import functionality for strategy sharing
|
||||
- [x] 2.0 Strategy Configuration System
|
||||
- [x] 2.1 Create `config/strategies/` directory structure mirroring indicators configuration
|
||||
- [x] 2.2 Implement `config/strategies/config_utils.py` with configuration validation and loading functions
|
||||
- [x] 2.3 Create JSON schema definitions for strategy parameters and validation rules
|
||||
- [x] 2.4 Create strategy templates in `config/strategies/templates/` for common strategy configurations
|
||||
- [x] 2.5 Implement `StrategyManager` class in `strategies/manager.py` following `IndicatorManager` pattern
|
||||
- [x] 2.6 Add strategy configuration loading and saving functionality with file-based storage
|
||||
- [x] 2.7 Create user strategies directory `config/strategies/user_strategies/` for custom configurations
|
||||
- [x] 2.8 Implement strategy parameter validation and default value handling
|
||||
- [x] 2.9 Add configuration export/import functionality for strategy sharing
|
||||
|
||||
- [ ] 3.0 Database Schema and Repository Layer
|
||||
- [ ] 3.1 Create new `strategy_signals` table migration (separate from existing `signals` table for bot operations)
|
||||
|
||||
Reference in New Issue
Block a user