NautilusTrader
ConceptsInstruments

Betting Instrument

BettingInstrument represents one selection in a sports or gaming market. It carries event, competition, market, and selection metadata so Nautilus can treat the selection as an instrument with prices, sizes, limits, margins, and fees.

Examples include Betfair match-odds selections and handicap market selections.

Fields

FieldRust typePython typeRequired/defaultNotes
instrument_idInstrumentIdN/ARust onlyStored as id in Rust.
raw_symbolSymbolN/ARust onlyNative or generated venue symbol.
venue_nameN/AstrPython onlyVenue used to construct the instrument ID.
event_type_idu64intRequiredEvent type identifier.
event_type_nameUstrstrRequiredEvent type name, such as a sport.
competition_idu64intRequiredCompetition identifier.
competition_nameUstrstrRequiredCompetition name.
event_idu64intRequiredEvent identifier.
event_nameUstrstrRequiredEvent name.
event_country_codeUstrstrRequiredEvent country code.
event_open_dateUnixNanosdatetimeRequiredEvent open time.
betting_typeUstrstrRequiredBetting type published by the venue.
market_idUstrstrRequiredMarket identifier.
market_nameUstrstrRequiredMarket name.
market_typeUstrstrRequiredMarket type, such as match odds.
market_start_timeUnixNanosdatetimeRequiredMarket start time.
selection_idu64intRequiredSelection or runner identifier.
selection_nameUstrstrRequiredSelection or runner name.
selection_handicapf64floatRequiredHandicap value for handicap markets.
currencyCurrencystrRequiredQuote and settlement currency.
price_precisionu8intRequiredDecimal places allowed for prices.
size_precisionu8intRequiredDecimal places allowed for order sizes.
price_incrementPricePrice | NoneRequired/RustPrice step, often set by a tick scheme.
size_incrementQuantityQuantityRequired/RustMinimum size step.
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 | None1Initial margin rate.
margin_maintOption<Decimal>Decimal | None1Maintenance 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 | None{}/NoneAdapter metadata.
ts_eventUnixNanosintRequiredEvent timestamp in nanoseconds.
ts_initUnixNanosintRequiredInitialization timestamp in nanoseconds.

Note: Python builds the instrument ID and raw symbol from the venue, market, selection, and handicap fields. Rust receives them as instrument_id and raw_symbol.

Behavior

  • BettingInstrument has asset class Alternative and instrument class SportsBetting.
  • Each selection or runner is modeled as its own instrument.
  • Betting instruments commonly use a registered tick scheme for valid odds steps.
  • Margin defaults to one because staking a bet typically reserves the full stake.

Example

use chrono::{TimeZone, Utc};
use nautilus_core::UnixNanos;
use nautilus_model::{
    identifiers::{InstrumentId, Symbol},
    instruments::BettingInstrument,
    types::{Currency, Money, Price, Quantity},
};
use rust_decimal_macros::dec;
use ustr::Ustr;

let event_open = Utc.with_ymd_and_hms(2022, 2, 7, 23, 30, 0).unwrap();
let market_start = Utc.with_ymd_and_hms(2022, 2, 7, 23, 30, 0).unwrap();

let selection = BettingInstrument::new(
    InstrumentId::from("1-123456789.BETFAIR"),
    Symbol::from("1-123456789"),
    6423,
    Ustr::from("American Football"),
    12_282_733,
    Ustr::from("NFL"),
    29_678_534,
    Ustr::from("NFL"),
    Ustr::from("GB"),
    UnixNanos::from(event_open.timestamp_nanos_opt().unwrap() as u64),
    Ustr::from("ODDS"),
    Ustr::from("1-123456789"),
    Ustr::from("AFC Conference Winner"),
    Ustr::from("SPECIAL"),
    UnixNanos::from(market_start.timestamp_nanos_opt().unwrap() as u64),
    50214,
    Ustr::from("Kansas City Chiefs"),
    0.0,
    Currency::from("GBP"),
    2,
    2,
    Price::from("0.01"),
    Quantity::from("0.01"),
    Some(Quantity::from("1000")),
    Some(Quantity::from("1")),
    Some(Money::from("10000 GBP")),
    Some(Money::from("10 GBP")),
    Some(Price::from("100.00")),
    Some(Price::from("1.00")),
    Some(dec!(1)),
    Some(dec!(1)),
    Some(dec!(0)),
    Some(dec!(0)),
    None,
    UnixNanos::default(),
    UnixNanos::default(),
);

Adapters

Representative adapters that create or consume BettingInstrument instruments include:

  • Accounting covers betting account behavior.
  • Data explains market data that references instruments.

On this page