Back to Nautilus Trader

Binary Option

docs/concepts/instruments/binary_option.md

1.230.09.7 KB
Original Source

Binary Option

BinaryOption represents a binary outcome instrument that settles to a fixed payoff based on whether a condition is true. It can model prediction markets, binary options, or venue-specific yes/no contracts.

Examples include prediction market outcomes and binary event contracts.

Fields

<Tabs items={["Rust", "Python"]}> <Tab value="Rust">

FieldTypeRequired/defaultNotes
instrument_idInstrumentIdRequiredStored as id in Rust.
raw_symbolSymbolRequiredNative venue symbol.
asset_classAssetClassRequiredAsset class of the outcome market.
currencyCurrencyRequiredQuote and settlement currency.
activation_nsUnixNanosRequiredContract activation timestamp.
expiration_nsUnixNanosRequiredContract expiration timestamp.
price_precisionu8RequiredDecimal places allowed for prices.
size_precisionu8RequiredDecimal places allowed for order sizes.
price_incrementPriceRequiredSmallest valid price step.
size_incrementQuantityRequiredSmallest valid size step.
outcomeOption<Ustr>NoneOutcome label when the venue provides it.
descriptionOption<Ustr>NoneHuman‑readable market description.
max_quantityOption<Quantity>NoneMaximum order quantity.
min_quantityOption<Quantity>NoneMinimum order quantity.
max_notionalOption<Money>NoneMaximum order notional value.
min_notionalOption<Money>NoneMinimum order notional value.
max_priceOption<Price>NoneMaximum valid quote or order price.
min_priceOption<Price>NoneMinimum valid quote or order price.
margin_initOption<Decimal>0Initial margin rate.
margin_maintOption<Decimal>0Maintenance margin rate.
maker_feeOption<Decimal>0Maker fee rate. Negative values rebate.
taker_feeOption<Decimal>0Taker fee rate. Negative values rebate.
tick_schemeOption<Ustr>NoneRegistered variable tick scheme name.
infoOption<Params>NoneAdapter metadata.
ts_eventUnixNanosRequiredEvent timestamp in nanoseconds.
ts_initUnixNanosRequiredInitialization timestamp in nanoseconds.
</Tab> <Tab value="Python">
FieldTypeRequired/defaultNotes
instrument_idInstrumentIdRequired
raw_symbolSymbolRequiredNative venue symbol.
asset_classAssetClassRequiredAsset class of the outcome market.
currencyCurrencyRequiredQuote and settlement currency.
activation_nsintRequiredContract activation timestamp.
expiration_nsintRequiredContract expiration timestamp.
price_precisionintRequiredDecimal places allowed for prices.
size_precisionintRequiredDecimal places allowed for order sizes.
price_incrementPriceRequiredSmallest valid price step.
size_incrementQuantityRequiredSmallest valid size step.
outcomestr | NoneNoneOutcome label when the venue provides it.
descriptionstr | NoneNoneHuman‑readable market description.
max_quantityQuantity | NoneNoneMaximum order quantity.
min_quantityQuantity | NoneNoneMinimum order quantity.
max_notionalMoney | NoneNoneMaximum order notional value.
min_notionalMoney | NoneNoneMinimum order notional value.
max_pricePrice | NoneNoneMaximum valid quote or order price.
min_pricePrice | NoneNoneMinimum valid quote or order price.
margin_initDecimal | None0Initial margin rate.
margin_maintDecimal | None0Maintenance margin rate.
maker_feeDecimal | None0Maker fee rate. Negative values rebate.
taker_feeDecimal | None0Taker fee rate. Negative values rebate.
tick_schemestr | NoneNoneRegistered variable tick scheme name.
infodict | NoneNoneAdapter metadata.
ts_eventintRequiredEvent timestamp in nanoseconds.
ts_initintRequiredInitialization timestamp in nanoseconds.
</Tab> </Tabs>

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

Behavior

  • BinaryOption has instrument class BinaryOption.
  • It is never inverse and uses a multiplier and lot size of one.
  • Many venues quote binary outcomes between zero and one, but the venue defines the allowed price range and tick size.
  • outcome and description provide human-readable context for the contract.

Example

rust
use chrono::{TimeZone, Utc};
use nautilus_core::UnixNanos;
use nautilus_model::{
    enums::AssetClass,
    identifiers::{InstrumentId, Symbol, Venue},
    instruments::BinaryOption,
    types::{Currency, Price, Quantity},
};
use rust_decimal_macros::dec;
use ustr::Ustr;

let raw_symbol = Symbol::from(
    "0x12a0cb60174abc437bf1178367c72d11f069e1a3add20b148fb0ab4279b772b2-92544998123698303655208967887569360731013655782348975589292031774495159624905",
);
let expiration = Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap();

let yes_outcome = BinaryOption::builder()
    .instrument_id(InstrumentId::new(raw_symbol, Venue::from("POLYMARKET")))
    .raw_symbol(raw_symbol)
    .asset_class(AssetClass::Alternative)
    .currency(Currency::from("USDC"))
    .activation_ns(UnixNanos::default())
    .expiration_ns(UnixNanos::from(expiration.timestamp_nanos_opt().unwrap() as u64))
    .price_precision(3)
    .size_precision(2)
    .price_increment(Price::from("0.001"))
    .size_increment(Quantity::from("0.01"))
    .outcome(Ustr::from("Yes"))
    .description(Ustr::from("Will the outcome of this market be 'Yes'?"))
    .min_quantity(Quantity::from("5"))
    .maker_fee(dec!(0))
    .taker_fee(dec!(0))
    .ts_event(UnixNanos::default())
    .ts_init(UnixNanos::default())
    .build()
    .unwrap();
python
from decimal import Decimal

import pandas as pd

from nautilus_trader.model import AssetClass
from nautilus_trader.model import BinaryOption
from nautilus_trader.model import Currency
from nautilus_trader.model import InstrumentId
from nautilus_trader.model import Price
from nautilus_trader.model import Quantity
from nautilus_trader.model import Symbol
from nautilus_trader.model import Venue

raw_symbol = Symbol(
    "0x12a0cb60174abc437bf1178367c72d11f069e1a3add20b148fb0ab4279b772b2-92544998123698303655208967887569360731013655782348975589292031774495159624905",
)
price_increment = Price.from_str("0.001")
size_increment = Quantity.from_str("0.01")

yes_outcome = BinaryOption(
    instrument_id=InstrumentId(raw_symbol, Venue("POLYMARKET")),
    raw_symbol=raw_symbol,
    asset_class=AssetClass.ALTERNATIVE,
    currency=Currency.from_str("USDC"),
    activation_ns=0,
    expiration_ns=pd.Timestamp("2024-01-01", tz="UTC").value,
    price_precision=price_increment.precision,
    size_precision=size_increment.precision,
    price_increment=price_increment,
    size_increment=size_increment,
    min_quantity=Quantity.from_int(5),
    maker_fee=Decimal(0),
    taker_fee=Decimal(0),
    outcome="Yes",
    description="Will the outcome of this market be 'Yes'?",
    ts_event=0,
    ts_init=0,
)

Adapters

Representative adapters that create or consume BinaryOption instruments include:

  • Hyperliquid for binary and prediction-style markets.
  • OKX for venue-defined binary outcome products.
  • Polymarket for prediction market outcomes.
  • Order Book covers binary market order book behavior.
  • Data explains market data that references instruments.