#![deny(clippy::all)]

// Domain modules
pub mod domain;
pub mod events;
pub mod modes;

// Core functionality modules
pub mod core;
pub mod orderbook;
pub mod risk;
pub mod positions;
pub mod analytics;
pub mod indicators;
pub mod backtest;
pub mod strategies;

// API layer
pub mod api;

// Re-export commonly used types from domain
pub use domain::{
    // Market types
    Quote, Bar, Trade, MarketUpdate, MarketDataType,
    // Order types
    Order, OrderType, OrderStatus, TimeInForce, Side, Fill,
    // Position types
    Position, PositionUpdate,
    // Event types
    Event, EventType, EventHandler,
};

// Re-export mode types
pub use modes::{TradingMode, TradingEngine};

// Re-export other commonly used types
pub use positions::{PositionTracker, TradeRecord, ClosedTrade};
pub use risk::{RiskLimits, RiskCheckResult, RiskMetrics};

// Core traits that define the system's abstractions
use chrono::{DateTime, Utc};
use std::sync::Arc;
use async_trait::async_trait;

#[async_trait]
pub trait MarketDataSource: Send + Sync {
    async fn get_next_update(&mut self) -> Option<MarketUpdate>;
    fn seek_to_time(&mut self, timestamp: DateTime<Utc>) -> Result<(), String>;
    fn as_any(&self) -> &dyn std::any::Any;
    fn as_any_mut(&mut self) -> &mut dyn std::any::Any;
}

#[async_trait]
pub trait ExecutionHandler: Send + Sync {
    async fn submit_order(&self, order: &Order) -> Result<String, String>;
    async fn cancel_order(&self, order_id: &str) -> Result<(), String>;
    async fn get_order_status(&self, order_id: &str) -> Result<OrderStatus, String>;
}

pub trait TimeProvider: Send + Sync {
    fn now(&self) -> DateTime<Utc>;
    fn as_any(&self) -> &dyn std::any::Any;
}

pub trait FillSimulator: Send + Sync {
    fn simulate_fill(&self, order: &Order, market_price: f64) -> Option<Fill>;
}