#[repr(C)]pub struct AlgoState {
pub position_1e8: i64,
pub avg_entry_1e9: u64,
pub realized_pnl_1e9: i64,
pub unrealized_pnl_1e9: i64,
pub orders: [OpenOrder; 32],
pub order_ct: u8,
pub _pad: [u8; 7],
pub session_pnl_1e9: i64,
pub total_fill_count: u64,
pub symbol: SymbolMeta,
pub risk: RiskSnapshot,
}Expand description
Algo state: position, orders, session stats, symbol metadata, and risk limits. All managed by server — read-only from algo’s perspective.
New fields (v0.2+) are appended after _pad for ABI backward compatibility.
Old WASM binaries compiled with v0.1.x read only up to _pad and ignore the rest.
Fields§
§position_1e8: i64§avg_entry_1e9: u64§realized_pnl_1e9: i64§unrealized_pnl_1e9: i64§orders: [OpenOrder; 32]§order_ct: u8§_pad: [u8; 7]§session_pnl_1e9: i64§total_fill_count: u64§symbol: SymbolMeta§risk: RiskSnapshotImplementations§
Source§impl AlgoState
impl AlgoState
pub fn is_flat(&self) -> bool
pub fn is_long(&self) -> bool
pub fn is_short(&self) -> bool
pub fn has_orders(&self) -> bool
pub fn live_order_count(&self) -> usize
pub fn find_order(&self, order_id: u64) -> Option<&OpenOrder>
pub fn open_buy_qty_1e8(&self) -> i64
pub fn open_sell_qty_1e8(&self) -> i64
pub fn total_pnl_1e9(&self) -> i64
Sourcepub fn get_pnl(&self) -> PnlSnapshot
pub fn get_pnl(&self) -> PnlSnapshot
Ergonomic PnL accessor for strategies that want a single call.
Sourcepub fn realized_pnl_usd(&self) -> f64
pub fn realized_pnl_usd(&self) -> f64
Realized PnL as USD float.
Sourcepub fn unrealized_pnl_usd(&self) -> f64
pub fn unrealized_pnl_usd(&self) -> f64
Unrealized PnL as USD float.
Sourcepub fn total_pnl_usd(&self) -> f64
pub fn total_pnl_usd(&self) -> f64
Total PnL as USD float.
Sourcepub fn session_pnl_usd(&self) -> f64
pub fn session_pnl_usd(&self) -> f64
Session realized PnL as USD float. Resets at UTC midnight.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AlgoState
impl RefUnwindSafe for AlgoState
impl Send for AlgoState
impl Sync for AlgoState
impl Unpin for AlgoState
impl UnsafeUnpin for AlgoState
impl UnwindSafe for AlgoState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more