{"record":{"id":"d01ffec3e116f832","repo":"nautechsystems/nautilus_trader","slug":"binance-spot-supports-only-the-1s-kline-interval","errorCode":null,"errorMessage":"Binance Spot supports only the 1s kline interval","messagePattern":"Binance Spot supports only the 1s kline interval","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":2979,"sourceCode":"    /// or the request fails.\n    pub async fn request_binance_bars(\n        &self,\n        bar_type: BarType,\n        start: Option<Timestamp>,\n        end: Option<Timestamp>,\n        limit: Option<u32>,\n    ) -> anyhow::Result<Vec<crate::common::bar::BinanceBar>> {\n        anyhow::ensure!(\n            bar_type.aggregation_source() == AggregationSource::External,\n            \"Only EXTERNAL aggregation is supported\"\n        );\n\n        let spec = bar_type.spec();\n        let step = spec.step.get();\n        let interval = match spec.aggregation {\n            BarAggregation::Second if step == 1 => \"1s\".to_string(),\n            BarAggregation::Second => {\n                anyhow::bail!(\"Binance Spot supports only the 1s kline interval\")\n            }\n            BarAggregation::Minute => format!(\"{step}m\"),\n            BarAggregation::Hour => format!(\"{step}h\"),\n            BarAggregation::Day => format!(\"{step}d\"),\n            BarAggregation::Week => format!(\"{step}w\"),\n            BarAggregation::Month => format!(\"{step}M\"),\n            a => anyhow::bail!(\"Binance does not support {a:?} aggregation\"),\n        };\n\n        let instrument_id = bar_type.instrument_id();\n        let symbol = instrument_id.symbol;\n        let instrument = self.instrument_from_cache_by_id(instrument_id)?;\n        let klines = self\n            .inner\n            .klines(\n                symbol.as_str(),\n                &interval,\n                start.map(|dt| dt.as_millisecond()),","sourceCodeStart":2961,"sourceCodeEnd":2997,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L2961-L2997","documentation":"When mapping a BarType specification to a Binance Spot kline interval, second-based aggregation is only supported with a step of exactly 1 (mapped to Binance's \"1s\" interval). Any other second step bails, because Binance Spot offers no 2s/5s/... kline intervals.","triggerScenarios":"Calling the Spot kline request path (bar request/load via the HTTP client) with a BarAggregation::Second whose spec step is not 1, e.g. SECOND[5] or SECOND[15] bars.","commonSituations":"Configuring a strategy on sub-minute bars with step > 1 assuming arbitrary second bars are supported; bar specs generated programmatically from configs that aggregate seconds.","solutions":["Use SECOND[1] bars and aggregate to higher steps locally in the strategy","Switch the bar spec to Minute aggregation (e.g. MINUTE[1]) which Binance Spot supports natively","Adjust the BarType in the data subscription/request config to a supported interval"],"exampleFix":"// before\nlet bar_type = BarType::from_str(\"BTCUSDT.BINANCE-SECOND-5-INTERNAL\")?;\n// after\nlet bar_type = BarType::from_str(\"BTCUSDT.BINANCE-SECOND-1-INTERNAL\")?;","handlingStrategy":"validation","validationCode":"if bar_type.aggregation() == BarAggregation::Second && bar_type.spec().step.get() != 1 {\n    return Err(\"Binance Spot requires SECOND[1]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize sub-minute subscriptions on SECOND[1]","Resample 1s bars locally for coarser second intervals","Review bar specs in strategy configs before pointing them at Binance Spot"],"tags":["binance","spot","klines","bars","interval"],"backgroundTag":"unsupported-operation","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"}