Back to Nautilus Trader

Crypto Perpetual

docs/concepts/instruments/crypto_perpetual.md

1.228.08.0 KB
Original Source

Crypto Perpetual

CryptoPerpetual represents a crypto perpetual futures contract, also known as a perpetual swap. It has no expiry, tracks a crypto base asset, and settles in a crypto, stablecoin, or other venue-defined settlement currency.

Examples include ETHUSDT-PERP.BINANCE, XBTUSD.BITMEX, and BTC-USD-SWAP.OKX.

Fields

FieldRust typePython typeRequired/defaultNotes
instrument_idInstrumentIdInstrumentIdRequiredStored as id in Rust.
raw_symbolSymbolSymbolRequiredNative venue symbol.
base_currencyCurrencyCurrencyRequiredBase crypto asset.
quote_currencyCurrencyCurrencyRequiredPrice quote currency.
settlement_currencyCurrencyCurrencyRequiredCurrency used to settle PnL and fees.
is_inverseboolboolRequiredTrue when sizing/costing is inverse.
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.
multiplierQuantityQuantity1Contract multiplier.
lot_sizeQuantityQuantity1Rounded 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

  • CryptoPerpetual has asset class Cryptocurrency and instrument class Swap.
  • It has no activation or expiration timestamp.
  • Linear contracts typically set is_inverse=False and settle in the quote currency.
  • Inverse contracts set is_inverse=True and typically settle in the base currency.
  • Quanto contracts settle in a third currency that differs from both base and quote.
  • The cost currency is base for inverse contracts, settlement for quanto contracts, and quote otherwise.

:::note Funding payments are not fields on the instrument. They arrive as data, such as FundingRateUpdate, and reference the instrument ID. :::

Example

rust
use nautilus_core::UnixNanos;
use nautilus_model::{
    identifiers::{InstrumentId, Symbol},
    instruments::{CryptoPerpetual, InstrumentAny},
    types::{Currency, Money, Price, Quantity},
};
use rust_decimal_macros::dec;

let ethusdt_perp = CryptoPerpetual::new(
    InstrumentId::from("ETHUSDT-PERP.BINANCE"),
    Symbol::from("ETHUSDT"),
    Currency::from("ETH"),
    Currency::from("USDT"),
    Currency::from("USDT"),
    false,
    2,
    3,
    Price::from("0.01"),
    Quantity::from("0.001"),
    None,
    None,
    Some(Quantity::from("10000.000")),
    Some(Quantity::from("0.001")),
    None,
    Some(Money::from("10.00 USDT")),
    Some(Price::from("15000.00")),
    Some(Price::from("1.00")),
    Some(dec!(1.0)),
    Some(dec!(0.35)),
    Some(dec!(0.0002)),
    Some(dec!(0.0004)),
    None,
    UnixNanos::default(),
    UnixNanos::default(),
);

let instrument = InstrumentAny::CryptoPerpetual(ethusdt_perp);
python
from decimal import Decimal

from nautilus_trader.model.currencies import ETH
from nautilus_trader.model.currencies import USDT
from nautilus_trader.model.identifiers import InstrumentId
from nautilus_trader.model.identifiers import Symbol
from nautilus_trader.model.instruments import CryptoPerpetual
from nautilus_trader.model.objects import Money
from nautilus_trader.model.objects import Price
from nautilus_trader.model.objects import Quantity

ethusdt_perp = CryptoPerpetual(
    instrument_id=InstrumentId.from_str("ETHUSDT-PERP.BINANCE"),
    raw_symbol=Symbol("ETHUSDT"),
    base_currency=ETH,
    quote_currency=USDT,
    settlement_currency=USDT,
    is_inverse=False,
    price_precision=2,
    size_precision=3,
    price_increment=Price.from_str("0.01"),
    size_increment=Quantity.from_str("0.001"),
    ts_event=0,
    ts_init=0,
    max_quantity=Quantity.from_str("10000.000"),
    min_quantity=Quantity.from_str("0.001"),
    min_notional=Money.from_str("10.00 USDT"),
    max_price=Price.from_str("15000.00"),
    min_price=Price.from_str("1.00"),
    margin_init=Decimal("1.0"),
    margin_maint=Decimal("0.35"),
    maker_fee=Decimal("0.0002"),
    taker_fee=Decimal("0.0004"),
)

Adapters

Representative adapters that create or consume CryptoPerpetual instruments include:

  • Binance for USD-M and COIN-M perpetual futures.
  • BitMEX for inverse and linear perpetual contracts.
  • Bybit for linear and inverse perpetual products.
  • dYdX for perpetual markets.
  • Hyperliquid for perpetual markets.
  • Kraken for futures venue perpetual markets.
  • OKX for swap markets.
  • Tardis for crypto perpetual metadata.
  • Data covers mark prices, index prices, and funding rate updates.
  • Options covers option-specific instrument types.
  • Execution explains precision and notional checks before orders reach a venue.