Expand description
Engine-owned position tracking.
This module provides EnginePosition, the engine’s internal representation
of a single position in a given instrument. It tracks the current quantity
(positive for long, negative for short) and a weighted-average entry price.
The core operation is EnginePosition::apply_fill, which handles all
position lifecycle transitions: opening, adding, partial close, full close,
and direction flip. It returns the realized PnL for any reducing portion
of the fill.
All arithmetic uses [rust_decimal::Decimal] for exact results. No floating
point is used anywhere in position or PnL calculations.
Structs§
- Engine
Position - A single position in the engine’s internal state.
- Position
Fill Transition
Type Aliases§
- Engine
Position Map - The engine’s position map, keyed by
(wallet, instrument_symbol).