Files
foxhunt/crates/ml-data-validation/src/lib.rs
jgrusewski d06c99b0e1 fix(clippy): achieve zero warnings across entire workspace
- Fix format_push_string: write!() instead of push_str(&format!()) (25 sites)
- Fix str_to_string: .to_owned() instead of .to_string() on &str (6 sites)
- Fix unseparated_literal_suffix: add _ separator (6 sites)
- Fix multiple_inherent_impl: merge split impl blocks in TGGN, TFT, OFI (3)
- Fix else_if_without_else: add exhaustive else clauses (3 sites)
- Fix if_then_some_else_none: use .then().transpose() (1 site)
- Fix unwrap_in_result: replace expect() with match + ? (2 sites)
- Fix wildcard_enum_match_arm: enumerate Storage variants explicitly (2)
- Fix decimal_literal_representation: use hex for power-of-2 constants (5)
- Fix rc_buffer: Arc<Vec<T>> → Arc<[T]> for OFI features
- Fix needless_range_loop: convert to iterator patterns (17 sites)
- Fix used_underscore_binding: remove prefix on used vars (6 sites)
- Fix doc list item indentation (7 sites)
- Allow too_many_arguments on ML training functions (4)
- Allow multiple_unsafe_ops_per_block on CUDA FFI functions (3)
- Allow upper_case_acronyms on SLSTM/MLSTM model names (2)
- Add ML-crate pedantic allows: shadow, similar_names, type_complexity,
  indexing_slicing, partial_pub_fields, non_ascii_literal, same_name_method
  (following existing ml-labeling/ml-universe pattern)

Result: cargo clippy --workspace -- -D warnings passes with zero warnings.
All 2758+ lib tests pass (2 pre-existing backtesting failures unchanged).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 13:18:57 +01:00

79 lines
3.2 KiB
Rust

#![deny(clippy::unwrap_used, clippy::expect_used)]
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::integer_division)]
#![allow(clippy::shadow_reuse, clippy::shadow_same, clippy::shadow_unrelated)] // Tensor ops: let x = x.relu() is idiomatic
#![allow(clippy::non_ascii_literal)] // Math symbols in ML documentation and error messages
#![allow(clippy::partial_pub_fields)] // ML config structs: some fields are pub API, some internal
#![allow(clippy::same_name_method)] // Intentional: inherent methods shadow trait defaults for ML-specific behavior
#![allow(clippy::indexing_slicing)] // Validation code: bounds checked by construction
#![allow(clippy::similar_names)] // ML naming: min_val/max_val, state/states are conventional
//! # ML Data Validation
//!
//! Data quality validation, cross-validation, and statistical correction
//! for Foxhunt ML training data.
//!
//! ## Modules
//!
//! - [`corrector`] -- Automatic correction of data quality issues
//! - [`cpcv`] -- Combinatorial Purged Cross-Validation (Lopez de Prado)
//! - [`fdr`] -- False Discovery Rate correction for multiple hypothesis testing
//! - [`rules`] -- Composable validation rules for OHLCV data
//! - [`validator`] -- Orchestrator that runs rules and generates reports
pub mod corrector;
pub mod cpcv;
pub mod fdr;
pub mod rules;
pub mod validator;
// Re-export core types used by this crate
pub use ml_core::types::OHLCVBar;
pub use ml_core::MLError;
/// Technical indicators (10 essential ones).
///
/// All indicators are calculated with standard parameters for 1-minute OHLCV data:
/// - RSI(14): Relative Strength Index
/// - MACD(12,26,9): Moving Average Convergence Divergence
/// - Bollinger Bands(20, 2.0): Price envelope
/// - ATR(14): Average True Range
/// - EMA(12, 26): Exponential moving averages
/// - Volume MA(20): Volume moving average
///
/// This type mirrors `ml::data_loader::Indicators` so that the validation crate
/// can operate independently of the full `ml` crate. Conversion between the two
/// is trivial (both are plain `pub` field structs with identical layout).
#[derive(Debug, Clone)]
pub struct Indicators {
/// RSI(14) - values 0-100
pub rsi: Vec<f32>,
/// MACD line (12,26)
pub macd: Vec<f32>,
/// MACD signal line (9)
pub macd_signal: Vec<f32>,
/// Bollinger upper band (20, 2.0)
pub bb_upper: Vec<f32>,
/// Bollinger middle band (SMA 20)
pub bb_middle: Vec<f32>,
/// Bollinger lower band (20, 2.0)
pub bb_lower: Vec<f32>,
/// ATR(14) - volatility measure
pub atr: Vec<f32>,
/// EMA(12) - fast exponential moving average
pub ema_fast: Vec<f32>,
/// EMA(26) - slow exponential moving average
pub ema_slow: Vec<f32>,
/// Volume MA(20) - volume moving average
pub volume_ma: Vec<f32>,
}
// Re-export main types
pub use corrector::DataCorrector;
pub use cpcv::{CPCVConfig, CPCVResult, CPCVSplit, CPCVValidator};
pub use fdr::{FDRConfig, FDRCorrector, FDRMethod, FDRResult};
pub use rules::{
CompletenessRule, ContinuityRule, IndicatorRule, IntegrityRule, TimestampRule, ValidationRule,
};
pub use validator::{DataValidator, ValidationReport, ValidationResult};