Skip to main content

Module margin

Module margin 

Source
Expand description

A margin account capable of holding leveraged positions and tracking instrument-specific leverage ratios.

§PnL calculation

The account calculates PnL differently based on instrument type:

  • Premium instruments (options, option spreads, binary options, warrants): Realize the notional value as a cash flow on every fill. BUY = negative (premium paid), SELL = positive (premium received).

  • Other instruments: Only realize PnL on position reduction (fill side opposite to entry). Use the minimum of fill and position quantity to avoid double-counting.

Structs§

MarginAccount