#![allow(unused_crate_dependencies)] //! Basic adaptive strategy example //! //! This example demonstrates how to set up and run a basic adaptive trading strategy //! with ensemble models, risk management, and execution algorithms. use adaptive_strategy::config::AdaptiveStrategyConfig; use adaptive_strategy::AdaptiveStrategy; use std::time::Duration; use tokio::time::sleep; use tracing::info; #[tokio::main] async fn main() -> Result<(), Box> { // Initialize logging // DISABLED: tracing_subscriber not in dependencies - uncomment when added // tracing_subscriber::fmt().with_max_level(Level::INFO).init(); info!("Starting basic adaptive strategy example"); // Create configuration let config = create_strategy_config(); // Initialize the adaptive strategy let strategy = AdaptiveStrategy::new(config).await?; info!("Strategy initialized successfully"); // Get initial state let initial_state = strategy.get_state().await; info!( "Initial strategy state: active={}, regime={}", initial_state.active, initial_state.current_regime ); // Simulate running for a short period (in production, this would run continuously) info!("Running strategy simulation for 10 seconds..."); // Start the strategy (this would run indefinitely in production) // For demo purposes, we'll use a timeout let strategy_task = tokio::spawn(async move { if let Err(e) = strategy.start().await { eprintln!("Strategy error: {}", e); } }); // Let it run for 10 seconds sleep(Duration::from_secs(10)).await; info!("Stopping strategy simulation"); strategy_task.abort(); info!("Example completed successfully"); Ok(()) } /// Create a comprehensive strategy configuration fn create_strategy_config() -> AdaptiveStrategyConfig { let mut config = AdaptiveStrategyConfig::default(); // Customize the execution interval for demo config.general.execution_interval = Duration::from_millis(500); config.general.error_backoff_duration = Duration::from_secs(2); config }