NautilusTrader
ConceptsInstruments

Commodity

Commodity represents a spot commodity market such as gold, silver, oil, or another physical asset quoted in a currency. It models a spot market, not a dated futures contract.

Examples include XAUUSD.IDEALPRO and venue-specific commodity cash symbols.

Fields

FieldRust typePython typeRequired/defaultNotes
instrument_idInstrumentIdInstrumentIdRequiredStored as id in Rust.
raw_symbolSymbolSymbolRequiredNative venue symbol.
asset_classAssetClassAssetClassRequiredCommodity asset classification.
quote_currencyCurrencyCurrencyRequiredCurrency used to price the commodity.
price_precisionu8intRequiredDecimal places allowed for prices.
size_precisionu8intRequiredDecimal places allowed for order sizes.
price_incrementPricePriceRequiredSmallest valid price step.
size_incrementQuantityQuantityRequiredSmallest valid size step.
ts_eventUnixNanosintRequiredEvent timestamp in nanoseconds.
ts_initUnixNanosintRequiredInitialization timestamp in nanoseconds.
base_currencyN/ACurrency | NoneNonePython‑only base asset currency, if known.
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.

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

Behavior

  • Commodity has instrument class Spot.
  • It is never inverse, and its cost currency is the quote currency.
  • It has no activation timestamp, expiry, strike, option kind, or settlement currency field.
  • Use FuturesContract for dated exchange-traded commodity futures.

Example

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

let gold = Commodity::new(
    InstrumentId::from("GOLD.COMEX"),
    Symbol::from("GOLD"),
    AssetClass::Commodity,
    Currency::from("USD"),
    2,
    0,
    Price::from("0.01"),
    Quantity::from("1"),
    Some(Quantity::from("1")),
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    UnixNanos::default(),
    UnixNanos::default(),
);

Adapters

Representative adapters that create or consume Commodity instruments include:

  • Futures Contract covers dated futures on commodity underlyings.
  • Data explains market data that references instruments.

On this page