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>
170 lines
6.4 KiB
Rust
170 lines
6.4 KiB
Rust
#![warn(missing_docs)]
|
|
//! Configuration management for Foxhunt HFT trading system
|
|
|
|
#![allow(missing_docs)] // Internal implementation details don't require documentation
|
|
#![allow(missing_debug_implementations)] // Not all types need Debug
|
|
|
|
// Allow pedantic lints for configuration management
|
|
#![allow(clippy::type_complexity)]
|
|
#![allow(clippy::unnecessary_map_or)]
|
|
#![allow(clippy::map_flatten)]
|
|
|
|
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
// Module declarations
|
|
pub mod asset_classification;
|
|
pub mod compliance_config;
|
|
pub mod data_config;
|
|
pub mod data_providers;
|
|
pub mod database;
|
|
pub mod error;
|
|
pub mod jwt_config;
|
|
pub mod manager;
|
|
pub mod ml_config;
|
|
pub mod risk_config;
|
|
pub mod runtime;
|
|
pub mod schemas;
|
|
pub mod storage_config;
|
|
pub mod structures;
|
|
pub mod symbol_config;
|
|
pub mod vault;
|
|
|
|
// Re-export commonly used types
|
|
pub use asset_classification::{
|
|
create_default_configurations, AssetClass, AssetClassificationManager, AssetConfig,
|
|
CommodityType, CryptoType, DerivativeType, EquitySector, ExecutionConfig, FixedIncomeType,
|
|
ForexPairType, FutureType, GeographicRegion, JumpRiskProfile, MarketCapTier,
|
|
MarketMakingConfig, OrderType, PositionLimits, RiskThresholds, SettlementConfig, TimeInForce,
|
|
TradingHours as DetailedTradingHours, TradingParameters,
|
|
VolatilityProfile as DetailedVolatilityProfile,
|
|
};
|
|
pub use compliance_config::ComplianceRuleConfig;
|
|
#[cfg(feature = "postgres")]
|
|
pub use compliance_config::PostgresComplianceRuleLoader;
|
|
pub use data_config::{
|
|
DataCompressionAlgorithm, DataCompressionConfig, DataConfig, DataRetentionConfig,
|
|
DataStorageConfig, DataStorageFormat, DataVersioningConfig, MissingDataHandling,
|
|
};
|
|
pub use data_providers::{
|
|
AlpacaEndpoints, BenzingaEndpoints, DataProviderConfig, DataProviderEnvironment,
|
|
DatabentoEndpoints, IBGatewayConfig,
|
|
};
|
|
pub use database::{DatabaseConfig, PoolConfig, TransactionConfig};
|
|
#[cfg(feature = "postgres")]
|
|
pub use database::{
|
|
PostgresAssetClassificationLoader, PostgresConfigLoader, PostgresSymbolConfigLoader,
|
|
};
|
|
pub use error::{ConfigError, ConfigResult};
|
|
pub use jwt_config::JwtConfig;
|
|
pub use manager::{ConfigManager, ConfigManagerBuilder, ServiceConfig};
|
|
pub use ml_config::{
|
|
MLConfig, Mamba2Config, MarketState, ModelArchitectureConfig, SimulationConfig,
|
|
SymbolConfig as MLSymbolConfig, TrainingConfig,
|
|
};
|
|
pub use risk_config::{
|
|
AssetClass as RiskAssetClass, AssetClassMapping, RiskConfig, StressScenarioConfig,
|
|
};
|
|
pub use runtime::{
|
|
CacheRuntimeConfig, DatabaseRuntimeConfig, Environment, LimitsConfig, RuntimeConfig,
|
|
TimeoutConfig,
|
|
};
|
|
pub use schemas::*;
|
|
pub use storage_config::{ModelArchitecture, ModelRegistryEntry, StorageConfig, TrainingMetrics};
|
|
pub use structures::{
|
|
AssetClass as SimpleAssetClass, AssetClassificationConfig, BacktestingDatabaseConfig,
|
|
BacktestingPerformanceConfig, BacktestingStrategyConfig, BrokerConfig, BrokerRoutingRule,
|
|
CommissionConfig, EncryptionConfig, MarketDataConfig, TlsConfig, TradingConfig,
|
|
VolatilityProfile as SimpleVolatilityProfile,
|
|
};
|
|
pub use symbol_config::{
|
|
AssetClassification, SymbolConfig, SymbolConfigManager, SymbolMetadata, TradingHours,
|
|
VolatilityProfile, VolatilityRegime,
|
|
};
|
|
pub use vault::VaultConfig;
|
|
|
|
/// Configuration categories for organizing different aspects of the trading system.
|
|
///
|
|
/// This enum categorizes different types of configurations to enable organized
|
|
/// access and management of system settings across various functional domains.
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
pub enum ConfigCategory {
|
|
/// Trading system configuration including order management and execution
|
|
Trading,
|
|
/// Risk management configuration including position limits and VaR settings
|
|
Risk,
|
|
/// Market data configuration for data providers and feeds
|
|
MarketData,
|
|
/// Machine learning model configuration and training parameters
|
|
MachineLearning,
|
|
/// Broker connectivity and execution configuration
|
|
Brokers,
|
|
/// Performance monitoring and optimization configuration
|
|
Performance,
|
|
/// Symbol classification and trading parameters configuration
|
|
Symbols,
|
|
/// Comprehensive asset classification with advanced features
|
|
AssetClassification,
|
|
}
|
|
|
|
/// Production-ready asset classification system integration.
|
|
///
|
|
/// This module provides a comprehensive asset classification system that integrates
|
|
/// with the existing config infrastructure while offering advanced features like:
|
|
/// - Dynamic pattern-based classification
|
|
///
|
|
/// - Regime-aware volatility profiling
|
|
/// - Hot-reload configuration management
|
|
///
|
|
/// - Performance caching and audit trails
|
|
///
|
|
/// # Usage
|
|
///
|
|
/// ```rust,no_run
|
|
/// use config::{AssetClassificationManager, create_default_configurations};
|
|
///
|
|
/// # async fn example() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|
/// let mut manager = AssetClassificationManager::new();
|
|
/// let configs = create_default_configurations();
|
|
/// manager.load_configurations(configs).await?;
|
|
///
|
|
/// // Classify a symbol
|
|
/// let asset_class = manager.classify_symbol("AAPL");
|
|
///
|
|
/// // Get trading parameters
|
|
/// if let Some(params) = manager.get_trading_parameters("AAPL") {
|
|
/// let max_position = params.position_limits.max_position_fraction;
|
|
/// println!("Max position fraction for AAPL: {}", max_position);
|
|
/// }
|
|
/// # Ok(())
|
|
/// # }
|
|
/// ```
|
|
pub mod asset_classification_integration {
|
|
pub use crate::asset_classification::*;
|
|
|
|
/// Convenience function to create a fully configured asset classification manager
|
|
/// with default configurations suitable for production use.
|
|
///
|
|
/// # Errors
|
|
/// Returns error if the operation fails
|
|
pub async fn create_production_manager(
|
|
database_pool: Option<sqlx::PgPool>,
|
|
) -> Result<AssetClassificationManager, Box<dyn std::error::Error + Send + Sync>> {
|
|
let mut manager = AssetClassificationManager::new();
|
|
|
|
// Load configurations from database if available, otherwise use defaults
|
|
let configs = if let Some(_pool) = database_pool {
|
|
// In production, load from database
|
|
// let loader = crate::database::PostgresAssetClassificationLoader::with_pool(pool);
|
|
// loader.load_asset_configurations().await?
|
|
create_default_configurations()
|
|
} else {
|
|
create_default_configurations()
|
|
};
|
|
|
|
manager.load_configurations(configs).await?;
|
|
Ok(manager)
|
|
}
|
|
}
|