{"record":{"id":"42f4f1f701699816","repo":"nautechsystems/nautilus_trader","slug":"lighter-funding-rate-requests-require-a-perpetual","errorCode":null,"errorMessage":"Lighter funding-rate requests require a perpetual instrument: {instrument_id}","messagePattern":"Lighter funding-rate requests require a perpetual instrument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/data/mod.rs","lineNumber":1697,"sourceCode":"                Err(e) => {\n                    log::error!(\"Lighter trades request failed for {instrument_id}: {e}\");\n                }\n            }\n        });\n\n        Ok(())\n    }\n\n    fn request_funding_rates(&self, request: RequestFundingRates) -> anyhow::Result<()> {\n        let instrument_id = request.instrument_id;\n        log::debug!(\"Requesting Lighter funding rates for {instrument_id}\");\n\n        let instrument = self\n            .instruments\n            .get_cloned(&instrument_id)\n            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;\n\n        anyhow::ensure!(\n            matches!(instrument, InstrumentAny::CryptoPerpetual(_)),\n            \"Lighter funding-rate requests require a perpetual instrument: {instrument_id}\",\n        );\n\n        let http = self.http_client.clone();\n        let sender = self.data_sender.clone();\n        let request_id = request.request_id;\n        let client_id = request.client_id.unwrap_or(self.client_id);\n        let start = request.start;\n        let end = request.end;\n        let limit = request.limit.map(|n| n.get());\n        let start_nanos = datetime_to_unix_nanos(start);\n        let end_nanos = datetime_to_unix_nanos(end);\n        let params = request.params;\n        let clock = self.clock;\n\n        self.spawn_task(async move {\n            match http","sourceCodeStart":1679,"sourceCodeEnd":1715,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/data/mod.rs#L1679-L1715","documentation":"Funding-rate requests in the Lighter adapter are only valid for perpetual instruments. The adapter looks up the instrument and asserts it is a CryptoPerpetual before issuing the HTTP funding-rate request; any other instrument type (spot, etc.) is rejected.","triggerScenarios":"Calling request_funding_rates() with an instrument_id that resolves to a non-perpetual instrument (e.g. a spot instrument), or with an instrument_id registered as something other than InstrumentAny::CryptoPerpetual.","commonSituations":"Requesting funding rates for a spot pair by mistake; a misconfigured instrument ID that matches a spot market instead of the -PERP market.","solutions":["Use a perpetual instrument ID (e.g. ending in -PERP) for funding-rate requests.","Verify which instruments were loaded/registered by the client — funding is defined only for perps.","Check your config/instrument catalog so the requested ID maps to a CryptoPerpetual.","If you genuinely need funding-like data for another product, confirm whether the venue even provides it."],"exampleFix":"// before\nclient.request_funding_rates(RequestFundingRates::new(InstrumentId::from(\"ETH-USDC.LIGHTER\")));\n// after\nclient.request_funding_rates(RequestFundingRates::new(InstrumentId::from(\"ETH-USDC-PERP.LIGHTER\")));","handlingStrategy":"validation","validationCode":"if !instrument_id.to_string().ends_with(\"-PERP\") {\n    return Err(anyhow!(\"funding rates require a perpetual instrument: {instrument_id}\"));\n}","typeGuard":"fn is_perp(inst: &InstrumentAny) -> bool {\n    matches!(inst, InstrumentAny::CryptoPerpetual(_))\n}","tryCatchPattern":"match client.request_funding_rates(req).await {\n    Err(e) if e.to_string().contains(\"require a perpetual instrument\") => {\n        log::warn!(\"skipping funding-rate request for non-perp {id}\");\n    }\n    r => r?,\n}","preventionTips":["Only request funding for instrument IDs ending in -PERP.","Validate instrument type against the loaded catalog before requesting.","Keep spot and perp instrument IDs clearly separated in config."],"tags":["funding-rate","instrument-type","validation","request"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}