nautechsystems/nautilus_trader · error · anyhow::Error

Funding rates are only available for perpetual instruments

Error message

Funding rates are only available for perpetual instruments

What it means

The Hyperliquid data adapter only serves funding rates for perpetual instruments, since funding rates are a perpetual-futures concept (periodic payments between longs and shorts). The adapter checks that the requested instrument is a CryptoPerpetual and bails with this error otherwise (spot tokens, outcomes, etc. are rejected).

Source

Thrown at crates/adapters/hyperliquid/src/data.rs:1435

                log::error!("Failed to send public trades response: {e}");
            }
            Ok(())
        });

        Ok(())
    }

    fn request_funding_rates(&self, request: RequestFundingRates) -> anyhow::Result<()> {
        let instrument_id = request.instrument_id;
        log::debug!("Requesting funding rates for {instrument_id}");

        let instruments = self.instruments.load();
        let instrument = instruments
            .get(&instrument_id)
            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;

        if !matches!(instrument, InstrumentAny::CryptoPerpetual(_)) {
            anyhow::bail!("Funding rates are only available for perpetual instruments");
        }

        let coin = instrument.raw_symbol().to_string();
        let http = self.http_client.clone();
        let sender = self.data_sender.clone();
        let client_id = request.client_id.unwrap_or(self.client_id);
        let request_id = request.request_id;
        let params = request.params;
        let clock = self.clock;
        let limit = request.limit.map(|n| n.get());
        let start_dt = request.start;
        let end_dt = request.end;
        let start_nanos = datetime_to_unix_nanos(start_dt);
        let end_nanos = datetime_to_unix_nanos(end_dt);

        let now_ms = Timestamp::now().as_millisecond() as u64;

        // Hyperliquid requires a startTime; default to a 7-day lookback when none given

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the instrument is a CryptoPerpetual before requesting funding rates (check instrument type in the cache/catalog).
  2. Use the perpetual symbol (e.g. the raw symbol without spot suffix) when requesting funding rates.
  3. Route spot instruments to a different data request (trades/bars) instead of funding rates.
  4. If the symbol genuinely trades as a perp on Hyperliquid, confirm the adapter's instrument loading picked up the perpetual definition, not a spot one.

Example fix

// before
let rates = adapter.request_funding_rates(request).await?;
// after
let instrument = adapter.instruments().get(&request.instrument_id)?;
if matches!(instrument, nautilus_model::instruments::InstrumentAny::CryptoPerpetual(_)) {
    let rates = adapter.request_funding_rates(request).await?;
} else {
    log::warn!("skipping funding rates for non-perp {instrument}");
}
Defensive patterns

Strategy: validation

Validate before calling

fn is_perp(instrument: &InstrumentAny) -> bool {
    matches!(instrument, InstrumentAny::CryptoPerpetual(_))
}

Type guard

fn as_perp(instrument: &InstrumentAny) -> Option<&CryptoPerpetual> {
    match instrument { InstrumentAny::CryptoPerpetual(p) => Some(p), _ => None }
}

Prevention

When it happens

Trigger: Calling request_funding_rates with an instrument_id that resolves to a non-perpetual instrument — e.g. a Hyperliquid spot token like ARB/USDC or a HIP-4 outcome token — after the instrument has been successfully loaded into the adapter's instrument cache.

Common situations: Requesting funding rates for every instrument in a portfolio that mixes spot and perp positions; using a spot symbol string that looks valid but has no perpetual equivalent; subscribing funding data for a symbol that only trades spot on Hyperliquid.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/122c8b51303ca120. Report an issue: GitHub.