bot_engine/simulation/mod.rs
1//! Simulation Layer: Shared margin-aware accounting for paper trading and backtesting.
2//!
3//! This module provides accurate perpetual futures simulation including:
4//! - Per-instrument isolated margin positions
5//! - Margin-aware order admission (instead of full-notional checks)
6//! - Proper fill settlement with margin reserve/release
7//! - Unrealized PnL tracking at mark prices
8//! - Liquidation price computation
9//!
10//! Used by `PaperExchange` to provide realistic simulation that matches
11//! how Hyperliquid actually handles margin and positions.
12//!
13//! **Note**: This module is ONLY used in the simulation path (paper/backtest).
14//! Live trading uses the real exchange which handles all margin math server-side.
15
16pub mod account;
17
18pub use account::{IsolatedPosition, MarginLedger};