Move 17 library crates into crates/, CLI binary into bin/fxt, consolidate 10 test crates into testing/, split config crate from deployment config files. Root directory reduced from 38+ to ~17 directories. All Cargo.toml paths and build.rs proto refs updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
196 lines
5.7 KiB
Rust
196 lines
5.7 KiB
Rust
//! Minimal Feature Configuration for ML Strategy
|
|
//!
|
|
//! This module defines a minimal FeatureConfig type that can be used in common
|
|
//! without creating a circular dependency with the ml crate.
|
|
//!
|
|
//! The ml crate has a more comprehensive FeatureConfig with additional methods,
|
|
//! but this version provides just enough functionality for common/ml_strategy.rs.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Feature engineering phase (Wave 19 progressive implementation)
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum FeaturePhase {
|
|
/// Wave A: 26 features (baseline technical indicators + microstructure)
|
|
WaveA,
|
|
/// Wave B: 36 features (adds alternative bars + barrier optimization)
|
|
WaveB,
|
|
/// Wave C: 201 features (adds fractional diff + regime detection)
|
|
WaveC,
|
|
/// Wave D: 225 features (adds Wave D regime detection + adaptive strategies)
|
|
WaveD,
|
|
}
|
|
|
|
/// Minimal Feature Configuration
|
|
///
|
|
/// This is a simplified version of ml::features::config::FeatureConfig
|
|
/// that can be used in common without creating circular dependencies.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct FeatureConfig {
|
|
/// Feature engineering phase (Wave A/B/C/D)
|
|
pub phase: FeaturePhase,
|
|
|
|
/// Enable baseline OHLCV features (5 features)
|
|
pub enable_ohlcv: bool,
|
|
|
|
/// Enable technical indicators (21 features)
|
|
pub enable_technical_indicators: bool,
|
|
|
|
/// Enable microstructure features (3 features)
|
|
pub enable_microstructure: bool,
|
|
|
|
/// Enable alternative bar features (10 features)
|
|
pub enable_alternative_bars: bool,
|
|
|
|
/// Enable barrier optimization features
|
|
pub enable_barrier_optimization: bool,
|
|
|
|
/// Enable fractional differentiation features (162 features)
|
|
pub enable_fractional_diff: bool,
|
|
|
|
/// Enable regime detection features
|
|
pub enable_regime_detection: bool,
|
|
|
|
/// Enable Wave D regime detection features (24 features)
|
|
pub enable_wave_d_regime: bool,
|
|
}
|
|
|
|
impl Default for FeatureConfig {
|
|
fn default() -> Self {
|
|
Self::wave_a()
|
|
}
|
|
}
|
|
|
|
impl FeatureConfig {
|
|
/// Wave A configuration: 26 features (baseline)
|
|
pub fn wave_a() -> Self {
|
|
Self {
|
|
phase: FeaturePhase::WaveA,
|
|
enable_ohlcv: true,
|
|
enable_technical_indicators: true,
|
|
enable_microstructure: false,
|
|
enable_alternative_bars: false,
|
|
enable_barrier_optimization: false,
|
|
enable_fractional_diff: false,
|
|
enable_regime_detection: false,
|
|
enable_wave_d_regime: false,
|
|
}
|
|
}
|
|
|
|
/// Wave B configuration: 36 features (alternative bars)
|
|
pub fn wave_b() -> Self {
|
|
Self {
|
|
phase: FeaturePhase::WaveB,
|
|
enable_ohlcv: true,
|
|
enable_technical_indicators: true,
|
|
enable_microstructure: false,
|
|
enable_alternative_bars: true,
|
|
enable_barrier_optimization: true,
|
|
enable_fractional_diff: false,
|
|
enable_regime_detection: false,
|
|
enable_wave_d_regime: false,
|
|
}
|
|
}
|
|
|
|
/// Wave C configuration: 201 features (advanced)
|
|
pub fn wave_c() -> Self {
|
|
Self {
|
|
phase: FeaturePhase::WaveC,
|
|
enable_ohlcv: true,
|
|
enable_technical_indicators: true,
|
|
enable_microstructure: true,
|
|
enable_alternative_bars: true,
|
|
enable_barrier_optimization: true,
|
|
enable_fractional_diff: true,
|
|
enable_regime_detection: true,
|
|
enable_wave_d_regime: false,
|
|
}
|
|
}
|
|
|
|
/// Wave D configuration: 225 features (regime detection + adaptive strategies)
|
|
pub fn wave_d() -> Self {
|
|
Self {
|
|
phase: FeaturePhase::WaveD,
|
|
enable_ohlcv: true,
|
|
enable_technical_indicators: true,
|
|
enable_microstructure: true,
|
|
enable_alternative_bars: true,
|
|
enable_barrier_optimization: true,
|
|
enable_fractional_diff: true,
|
|
enable_regime_detection: true,
|
|
enable_wave_d_regime: true,
|
|
}
|
|
}
|
|
|
|
/// Calculate total feature count based on enabled feature groups
|
|
pub fn feature_count(&self) -> usize {
|
|
let mut count = 0;
|
|
|
|
if self.enable_ohlcv {
|
|
count += 5;
|
|
}
|
|
|
|
if self.enable_technical_indicators {
|
|
count += 21;
|
|
}
|
|
|
|
if self.enable_microstructure {
|
|
count += 3;
|
|
}
|
|
|
|
if self.enable_alternative_bars {
|
|
count += 10;
|
|
}
|
|
|
|
if self.enable_fractional_diff {
|
|
count += 162;
|
|
}
|
|
|
|
if self.enable_wave_d_regime {
|
|
count += 24;
|
|
}
|
|
|
|
count
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_wave_a_config() {
|
|
let config = FeatureConfig::wave_a();
|
|
assert_eq!(config.phase, FeaturePhase::WaveA);
|
|
assert_eq!(config.feature_count(), 26);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wave_b_config() {
|
|
let config = FeatureConfig::wave_b();
|
|
assert_eq!(config.phase, FeaturePhase::WaveB);
|
|
assert_eq!(config.feature_count(), 36);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wave_c_config() {
|
|
let config = FeatureConfig::wave_c();
|
|
assert_eq!(config.phase, FeaturePhase::WaveC);
|
|
assert_eq!(config.feature_count(), 201);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wave_d_config() {
|
|
let config = FeatureConfig::wave_d();
|
|
assert_eq!(config.phase, FeaturePhase::WaveD);
|
|
assert_eq!(config.feature_count(), 225);
|
|
}
|
|
|
|
#[test]
|
|
fn test_default_is_wave_a() {
|
|
let config = FeatureConfig::default();
|
|
assert_eq!(config.phase, FeaturePhase::WaveA);
|
|
assert_eq!(config.feature_count(), 26);
|
|
}
|
|
}
|