Files
foxhunt/adaptive-strategy/examples/basic_strategy.rs
jgrusewski 95366b1341 ⚠️ Wave 38: Emergency Recovery - 56% Error Reduction (98→43)
MISSION: Emergency response to Wave 37 catastrophic regression
RESULT: Partial success - significant progress but goals not fully met

## Key Metrics

COMPILATION: 98 → 43 errors (56% reduction, but 2.7x worse than Wave 36)
TEST EXECUTION: Still blocked 
WARNINGS: 100+ → 60 (40% reduction) 

## Achievements

 Position type synchronized (18+ errors fixed)
 AssetClass Hash derive (5 errors fixed)
 Helper functions added (127 lines)
 Comprehensive documentation

## Remaining Work (43 errors)

 Decimal conversions (9 errors)
 StressScenario type (14 errors)
 Other type fixes (20 errors)

## Wave 39 Decision: NO-GO

Emergency continuation required to complete recovery
Target: 0 errors, restore testing (2-3 hours)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 08:44:08 +02:00

67 lines
2.1 KiB
Rust

//! 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, Level};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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 mut 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
}