Expand description
Pure trading-cost arithmetic for commission and overnight swap.
This module owns how much a cost is, never when it is charged. A replay or live consumer decides the timing, supplies the fill or rollover facts, and applies the returned signed charge to its own ledger.
Every charge is signed so that a positive amount reduces the account balance and a negative amount increases it. Commission is always a cost. Swap follows broker convention, where a negative configured value is a nightly charge and a positive value is a nightly credit.
Each charge also carries the currency basis it was computed in. Per-lot commission and per-lot swap are expressed directly in the account currency, while notional-rate commission and point-based swap are expressed in the instrument’s native profit-and-loss currency and must be converted by the consumer.
Structs§
- Cost
Charge - One computed signed charge before any account conversion.
- Instrument
Costs - Complete cost specification for one instrument.
- Swap
Schedule - Nightly swap magnitude plus the rollover calendar that charges it.
Enums§
- Commission
Model - How commission is charged for one instrument.
- Cost
Basis - Which currency a computed charge is denominated in.
- Cost
Kind - What produced one charge.
- Cost
Validation Error - Configuration failures detected before a run starts.
- Swap
Amount - Nightly swap magnitude for one instrument, in broker sign convention where negative charges and positive credits.
Constants§
- MAX_
NOTIONAL_ COMMISSION_ RATE - Largest accepted notional commission rate per side.
- MAX_
PER_ LOT_ COST - Largest accepted absolute per-lot commission or swap magnitude.
- MAX_
SWAP_ POINTS - Largest accepted absolute swap magnitude expressed in price points.
Functions§
- rollover_
instants - Rollover instants strictly after
previousand at or beforecurrent.