Skip to main content

Module costs

Module costs 

Source
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§

CostCharge
One computed signed charge before any account conversion.
InstrumentCosts
Complete cost specification for one instrument.
SwapSchedule
Nightly swap magnitude plus the rollover calendar that charges it.

Enums§

CommissionModel
How commission is charged for one instrument.
CostBasis
Which currency a computed charge is denominated in.
CostKind
What produced one charge.
CostValidationError
Configuration failures detected before a run starts.
SwapAmount
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 previous and at or before current.