Skip to main content

Module contract

Module contract 

Source
Expand description

Contract specifications, currencies, and linear contract valuation models. Provider-neutral instrument contract specifications, currency definitions, and valuation models.

Provides explicit contract units (multiplier, lot size, currencies) and FX conversion so position sizing, notionals, and P&L can be computed consistently in an account currency.

Structs§

ContractSpec
Detailed operative contract specifications complementing crate::model::InstrumentMeta.
Currency
An ISO currency code or currency symbol identifier (e.g. “EUR”, “USD”, “GBP”, “JPY”).
FxRate
An FX quote between two currencies: base_currency / quote_currency = rate.

Enums§

ContractSpecError
Errors when validating a ContractSpec.
FxConversionError
Errors during foreign exchange currency conversion.
InstrumentType
Category of traded financial contract.
ValuationError
Errors during contract valuation and sizing calculations.

Functions§

contract_pnl
Computes the realized or unrealized P&L in account currency: (exit - entry) * direction * quantity * multiplier * fx_rate.
contract_tick_value
Computes the single-tick value in account currency: tick_size * multiplier * fx_rate.
notional_value
Computes the total notional value of a position in account currency: quantity * price * multiplier * fx_rate.
stop_risk_amount
Computes the stop risk amount in account currency: quantity * |entry - stop| * multiplier * fx_rate.