use async_trait::async_trait;
use std::collections::HashMap;
use crate::scar::ScarSeverity;
#[derive(Debug, Clone)]
pub struct PricePoint {
pub symbol: String,
pub price: f64,
pub timestamp: i64,
pub volatility: f64, }
#[derive(Debug, Clone)]
pub struct MarketSnapshot {
pub prices: HashMap<String, PricePoint>,
pub timestamp: i64,
}
#[async_trait]
pub trait TradingStrategy: Send + Sync {
async fn decide_trade(&self, market: &MarketSnapshot) -> TradeDecision;
fn on_loss(&mut self, _drawdown: f32, _loss_amount: u64) {}
fn on_win(&mut self, _gain_amount: u64) {}
fn name(&self) -> &str;
}
#[derive(Debug, Clone)]
pub struct TradeDecision {
pub should_trade: bool,
pub symbol: String,
pub allocation_percentage: f32,
pub direction: String,
}
#[async_trait]
pub trait MarketDataProvider: Send + Sync {
async fn fetch_prices(&self, symbols: &[&str]) -> Result<MarketSnapshot, String>;
async fn get_volatility(&self, symbol: &str, period_days: u32) -> Result<f64, String>;
fn name(&self) -> &str;
fn requires_auth(&self) -> bool {
false
}
}
#[derive(Debug, Clone)]
pub enum AgentEvent {
TradeExecuted { symbol: String, success: bool, pnl: i64 },
ScarInflicted { drawdown: f32, severity: ScarSeverity },
OffspringSpawned { parent_id: String, generation: u32 },
Terminated { reason: String },
}
#[async_trait]
pub trait EventHandler: Send + Sync {
async fn on_event(&self, event: AgentEvent);
}
#[derive(Debug, Clone, Copy)]
pub enum VisualizationFormat {
ASCII,
HTML,
CSV,
JSON,
}
#[async_trait]
pub trait VisualizationProvider: Send + Sync {
async fn visualize(&self, results: &str, format: VisualizationFormat) -> Result<Vec<u8>, String>;
fn name(&self) -> &str;
}