Skip to main content

Module position

Module position 

Source
Expand description

§Module: position

§Responsibility

Tracks individual positions per symbol and a multi-position ledger with cash accounting. Computes realized and unrealized P&L from fills.

§Guarantees

  • Position::apply_fill returns realized PnL (non-zero only when reducing position)
  • PositionLedger::apply_fill debits/credits cash correctly including commissions
  • Position::is_flat is true iff quantity == 0

§NOT Responsible For

  • Risk checks (see risk module)
  • Order management

Structs§

Fill
A single trade execution event.
Position
A single-symbol position tracking quantity, average cost, and realized P&L.
PositionLedger
A multi-symbol ledger tracking positions and a cash balance.

Enums§

PositionDirection
Direction of an open position.