NautilusTrader
ConceptsInstruments

Cfd

Cfd represents a contract for difference that tracks an underlying asset without transferring ownership of the underlying. The venue defines the quote currency, precision, increments, limits, margins, and fees.

Examples include CFD contracts on FX, equities, indexes, and commodities.

Fields

FieldRust typePython typeRequired/defaultNotes
instrument_idInstrumentIdInstrumentIdRequiredStored as id in Rust.
raw_symbolSymbolSymbolRequiredNative venue symbol.
asset_classAssetClassAssetClassRequiredAsset class of the underlying.
base_currencyOption<Currency>Currency | NoneNoneBase currency when the CFD tracks one.
quote_currencyCurrencyCurrencyRequiredCurrency used to quote and value prices.
price_precisionu8intRequiredDecimal places allowed for prices.
size_precisionu8intRequiredDecimal places allowed for order sizes.
price_incrementPricePriceRequiredSmallest valid price step.
size_incrementQuantityQuantityRequiredSmallest valid size step.
lot_sizeOption<Quantity>Quantity | NoneNoneRounded lot or board size.
max_quantityOption<Quantity>Quantity | NoneNoneMaximum order quantity.
min_quantityOption<Quantity>Quantity | NoneNoneMinimum order quantity.
max_notionalOption<Money>Money | NoneNoneMaximum order notional value.
min_notionalOption<Money>Money | NoneNoneMinimum order notional value.
max_priceOption<Price>Price | NoneNoneMaximum valid quote or order price.
min_priceOption<Price>Price | NoneNoneMinimum valid quote or order price.
margin_initOption<Decimal>Decimal | None0Initial margin rate.
margin_maintOption<Decimal>Decimal | None0Maintenance margin rate.
maker_feeOption<Decimal>Decimal | None0Maker fee rate. Negative values rebate.
taker_feeOption<Decimal>Decimal | None0Taker fee rate. Negative values rebate.
tick_scheme_nameN/Astr | NoneNoneRegistered variable tick scheme name.
infoOption<Params>dict | NoneNoneAdapter metadata.
ts_eventUnixNanosintRequiredEvent timestamp in nanoseconds.
ts_initUnixNanosintRequiredInitialization timestamp in nanoseconds.

Note: Python constructors use instrument_id; Rust stores the same value as id.

Behavior

  • Cfd has instrument class Cfd.
  • It is never inverse and uses a multiplier of one.
  • It has no activation timestamp, expiration timestamp, strike, or option kind.
  • Use the source market type when a venue offers both cash instruments and CFDs.

Example

use nautilus_core::UnixNanos;
use nautilus_model::{
    enums::AssetClass,
    identifiers::{InstrumentId, Symbol},
    instruments::Cfd,
    types::{Currency, Price, Quantity},
};
use rust_decimal_macros::dec;

let audusd = Cfd::new(
    InstrumentId::from("AUDUSD.OANDA"),
    Symbol::from("AUD/USD"),
    AssetClass::FX,
    Some(Currency::from("AUD")),
    Currency::from("USD"),
    5,
    0,
    Price::from("0.00001"),
    Quantity::from("1"),
    Some(Quantity::from("1000")),
    None,
    None,
    None,
    None,
    None,
    None,
    Some(dec!(0.03)),
    Some(dec!(0.03)),
    Some(dec!(0.00002)),
    Some(dec!(0.00002)),
    None,
    UnixNanos::default(),
    UnixNanos::default(),
);

Adapters

Representative adapters that create or consume Cfd instruments include:

On this page