/home/jgrusewski/Work/foxhunt/config/src/lib.rs
Line | Count | Source |
1 | | #![warn(missing_docs)] |
2 | | //! Configuration management for Foxhunt HFT trading system |
3 | | |
4 | | #![allow(missing_docs)] // Internal implementation details don't require documentation |
5 | | #![allow(missing_debug_implementations)] // Not all types need Debug |
6 | | |
7 | | // Allow pedantic lints for configuration management |
8 | | #![allow(clippy::type_complexity)] |
9 | | #![allow(clippy::unnecessary_map_or)] |
10 | | #![allow(clippy::map_flatten)] |
11 | | #![allow(dead_code)] |
12 | | |
13 | | use serde::{Deserialize, Serialize}; |
14 | | |
15 | | // Module declarations |
16 | | pub mod asset_classification; |
17 | | pub mod compliance_config; |
18 | | pub mod data_config; |
19 | | pub mod data_providers; |
20 | | pub mod database; |
21 | | pub mod error; |
22 | | pub mod manager; |
23 | | pub mod ml_config; |
24 | | pub mod risk_config; |
25 | | pub mod runtime; |
26 | | pub mod schemas; |
27 | | pub mod storage_config; |
28 | | pub mod structures; |
29 | | pub mod symbol_config; |
30 | | pub mod vault; |
31 | | |
32 | | // Re-export commonly used types |
33 | | pub use asset_classification::{ |
34 | | create_default_configurations, AssetClass, AssetClassificationManager, AssetConfig, |
35 | | CommodityType, CryptoType, DerivativeType, EquitySector, ExecutionConfig, FixedIncomeType, |
36 | | ForexPairType, FutureType, GeographicRegion, JumpRiskProfile, MarketCapTier, MarketMakingConfig, OrderType, |
37 | | PositionLimits, RiskThresholds, SettlementConfig, TimeInForce, |
38 | | TradingHours as DetailedTradingHours, TradingParameters, |
39 | | VolatilityProfile as DetailedVolatilityProfile, |
40 | | }; |
41 | | pub use data_config::{ |
42 | | DataCompressionAlgorithm, DataCompressionConfig, DataConfig, DataRetentionConfig, |
43 | | DataStorageConfig, DataStorageFormat, DataVersioningConfig, MissingDataHandling, |
44 | | }; |
45 | | pub use data_providers::{ |
46 | | AlpacaEndpoints, BenzingaEndpoints, DataProviderConfig, DataProviderEnvironment, |
47 | | DatabentoEndpoints, IBGatewayConfig, |
48 | | }; |
49 | | pub use compliance_config::ComplianceRuleConfig; |
50 | | #[cfg(feature = "postgres")] |
51 | | pub use compliance_config::PostgresComplianceRuleLoader; |
52 | | pub use database::{DatabaseConfig, PoolConfig, TransactionConfig}; |
53 | | #[cfg(feature = "postgres")] |
54 | | pub use database::{ |
55 | | PostgresAssetClassificationLoader, PostgresConfigLoader, PostgresSymbolConfigLoader, |
56 | | }; |
57 | | pub use error::{ConfigError, ConfigResult}; |
58 | | pub use manager::{ConfigManager, ServiceConfig}; |
59 | | pub use ml_config::{ |
60 | | MLConfig, Mamba2Config, MarketState, ModelArchitectureConfig, SimulationConfig, |
61 | | SymbolConfig as MLSymbolConfig, TrainingConfig, |
62 | | }; |
63 | | pub use risk_config::{ |
64 | | AssetClass as RiskAssetClass, AssetClassMapping, RiskConfig, StressScenarioConfig, |
65 | | }; |
66 | | pub use runtime::{ |
67 | | CacheRuntimeConfig, DatabaseRuntimeConfig, Environment, LimitsConfig, RuntimeConfig, |
68 | | TimeoutConfig, |
69 | | }; |
70 | | pub use schemas::*; |
71 | | pub use storage_config::{ModelArchitecture, ModelMetadata, StorageConfig, TrainingMetrics}; |
72 | | pub use structures::{ |
73 | | AssetClass as SimpleAssetClass, AssetClassificationConfig, BacktestingDatabaseConfig, |
74 | | BacktestingPerformanceConfig, BacktestingStrategyConfig, BrokerConfig, BrokerRoutingRule, |
75 | | CommissionConfig, EncryptionConfig, MarketDataConfig, TlsConfig, TradingConfig, VolatilityProfile as SimpleVolatilityProfile, |
76 | | }; |
77 | | pub use symbol_config::{ |
78 | | AssetClassification, SymbolConfig, SymbolConfigManager, SymbolMetadata, TradingHours, |
79 | | VolatilityProfile, VolatilityRegime, |
80 | | }; |
81 | | pub use vault::VaultConfig; |
82 | | |
83 | | /// Configuration categories for organizing different aspects of the trading system. |
84 | | /// |
85 | | /// This enum categorizes different types of configurations to enable organized |
86 | | /// access and management of system settings across various functional domains. |
87 | | #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] |
88 | | pub enum ConfigCategory { |
89 | | /// Trading system configuration including order management and execution |
90 | | Trading, |
91 | | /// Risk management configuration including position limits and VaR settings |
92 | | Risk, |
93 | | /// Market data configuration for data providers and feeds |
94 | | MarketData, |
95 | | /// Machine learning model configuration and training parameters |
96 | | MachineLearning, |
97 | | /// Broker connectivity and execution configuration |
98 | | Brokers, |
99 | | /// Performance monitoring and optimization configuration |
100 | | Performance, |
101 | | /// Symbol classification and trading parameters configuration |
102 | | Symbols, |
103 | | /// Comprehensive asset classification with advanced features |
104 | | AssetClassification, |
105 | | } |
106 | | |
107 | | /// Production-ready asset classification system integration. |
108 | | /// |
109 | | /// This module provides a comprehensive asset classification system that integrates |
110 | | /// with the existing config infrastructure while offering advanced features like: |
111 | | /// - Dynamic pattern-based classification |
112 | | /// - Regime-aware volatility profiling |
113 | | /// - Hot-reload configuration management |
114 | | /// - Performance caching and audit trails |
115 | | /// |
116 | | /// # Usage |
117 | | /// |
118 | | /// ```rust,no_run |
119 | | /// use config::{AssetClassificationManager, create_default_configurations}; |
120 | | /// |
121 | | /// # async fn example() -> Result<(), Box<dyn std::error::Error>> { |
122 | | /// let mut manager = AssetClassificationManager::new(); |
123 | | /// let configs = create_default_configurations(); |
124 | | /// manager.load_configurations(configs).await?; |
125 | | /// |
126 | | /// // Classify a symbol |
127 | | /// let asset_class = manager.classify_symbol("AAPL"); |
128 | | /// |
129 | | /// // Get trading parameters |
130 | | /// if let Some(params) = manager.get_trading_parameters("AAPL") { |
131 | | /// let max_position = params.position_limits.max_position_fraction; |
132 | | /// println!("Max position fraction for AAPL: {}", max_position); |
133 | | /// } |
134 | | /// # Ok(()) |
135 | | /// # } |
136 | | /// ``` |
137 | | pub mod asset_classification_integration { |
138 | | pub use crate::asset_classification::*; |
139 | | |
140 | | /// Convenience function to create a fully configured asset classification manager |
141 | | /// with default configurations suitable for production use. |
142 | 0 | pub async fn create_production_manager( |
143 | 0 | database_pool: Option<sqlx::PgPool>, |
144 | 0 | ) -> Result<AssetClassificationManager, Box<dyn std::error::Error + Send + Sync>> { |
145 | 0 | let mut manager = AssetClassificationManager::new(); |
146 | | |
147 | | // Load configurations from database if available, otherwise use defaults |
148 | 0 | let configs = if let Some(_pool) = database_pool { |
149 | | // In production, load from database |
150 | | // let loader = crate::database::PostgresAssetClassificationLoader::with_pool(pool); |
151 | | // loader.load_asset_configurations().await? |
152 | 0 | create_default_configurations() |
153 | | } else { |
154 | 0 | create_default_configurations() |
155 | | }; |
156 | | |
157 | 0 | manager.load_configurations(configs).await?; |
158 | 0 | Ok(manager) |
159 | 0 | } |
160 | | } |