refactor(ml): consolidate 13 duplicate OHLCVBar definitions into single canonical type

Created ml/src/types/ohlcv.rs as the single source of truth for OHLCVBar
(DateTime<Utc> timestamp, f64 OHLCV fields). Replaced all 13 duplicate
definitions across features/, regime/, real_data_loader, and evaluation/
with imports from crate::types::OHLCVBar.

Key changes:
- New: ml/src/types/mod.rs + ohlcv.rs with canonical OHLCVBar
  (derives: Debug, Clone, Copy, PartialEq, Serialize, Deserialize + Default)
- Renamed: evaluation::metrics::OHLCVBar → OHLCVBarF32 (genuinely
  different type: f32 fields, i64 timestamp for compact backtesting)
- Eliminated all import aliases (ExtractionOHLCVBar, RegimeOHLCVBar,
  PriceOHLCVBar, VolumeOHLCVBar) in dbn_sequence_loader.rs and pipeline.rs
- Renamed regime::orchestrator::Bar → OHLCVBar (same fields, just aliased)
- Updated 39 files total (13 definitions removed, imports normalized)

1883 lib tests passing, compilation clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-02-20 18:14:42 +01:00
parent 4ad9d45d7e
commit 1934367bfa
39 changed files with 171 additions and 275 deletions

View File

@@ -51,7 +51,7 @@ use tracing::info;
use chrono::Utc;
use crate::evaluation::engine::{Action, EvaluationEngine};
use crate::evaluation::metrics::{OHLCVBar, PerformanceMetrics};
use crate::evaluation::metrics::{OHLCVBarF32, PerformanceMetrics};
use crate::hyperopt::paths::TrainingPaths;
use crate::hyperopt::traits::{HyperparameterOptimizable, ParameterSpace};
use crate::trainers::dqn::{DQNHyperparameters, DQNTrainer as InternalDQNTrainer};
@@ -2452,7 +2452,7 @@ impl HyperparameterOptimizable for DQNTrainer {
// Create OHLCV bar (we only have close price from validation data)
// For backtest purposes, we set open=high=low=close
let bar = OHLCVBar {
let bar = OHLCVBarF32 {
timestamp: bar_idx as i64, // Use bar index as timestamp
open: close_price as f32,
high: close_price as f32,