Back to Nautilus Trader

FundingRateUpdate

docs/concepts/data/funding_rate_update.md

1.231.02.4 KB
Original Source

FundingRateUpdate

FundingRateUpdate represents the funding rate for a perpetual swap instrument. It can also include the funding interval and next funding timestamp when the venue publishes them.

Fields

FieldRust typePython typeRequired/defaultNotes
instrument_idInstrumentIdInstrumentIdRequiredPerpetual instrument for the rate.
rateDecimalDecimalRequiredCurrent funding rate.
intervalOption<u16>int | NoneNoneFunding interval in minutes.
next_funding_nsOption<UnixNanos>int | NoneNoneNext funding timestamp in nanoseconds.
ts_eventUnixNanosintRequiredEvent timestamp in nanoseconds.
ts_initUnixNanosintRequiredInitialization timestamp in nanoseconds.

Behavior

  • Equality and hashing use instrument ID, rate, interval, and next funding time.
  • Funding rates are reference data and do not imply a payment was applied.
  • Use interval and next_funding_ns only when the venue publishes them.

Example

rust
use nautilus_core::UnixNanos;
use nautilus_model::{data::FundingRateUpdate, identifiers::InstrumentId};
use rust_decimal::Decimal;

let funding = FundingRateUpdate::new(
    InstrumentId::from("BTCUSDT-PERP.BINANCE"),
    Decimal::new(1, 4),
    Some(480),
    Some(UnixNanos::from(1_000_008_000)),
    UnixNanos::from(1_000_000_000),
    UnixNanos::from(1_000_000_100),
);
python
from decimal import Decimal

from nautilus_trader.model import FundingRateUpdate
from nautilus_trader.model import InstrumentId

funding = FundingRateUpdate(
    instrument_id=InstrumentId.from_str("BTCUSDT-PERP.BINANCE"),
    rate=Decimal("0.0001"),
    ts_event=1_000_000_000,
    ts_init=1_000_000_100,
    interval=480,
    next_funding_ns=1_000_008_000,
)