{"record":{"id":"c77f4fe84b08b532","repo":"nautechsystems/nautilus_trader","slug":"dydx-only-supports-last-price-type-was","errorCode":null,"errorMessage":"dYdX only supports LAST price type, was {:?}","messagePattern":"dYdX only supports LAST price type, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/http/client.rs","lineNumber":124,"sourceCode":"const DYDX_MAX_BARS_PER_REQUEST: u32 = 1_000;\n\n/// Perpetual markets endpoint (shared between `get_markets` and `get_market`).\nconst ENDPOINT_PERPETUAL_MARKETS: &str = \"/v4/perpetualMarkets\";\n\nconst QUERY_MARKET_TYPE_PERPETUAL: &str = \"marketType=PERPETUAL\";\nconst DYDX_INDEXER_REPORT_LIMIT: u32 = 1_000;\n\nfn bar_type_to_resolution(bar_type: &BarType) -> anyhow::Result<DydxCandleResolution> {\n    if bar_type.aggregation_source() != AggregationSource::External {\n        anyhow::bail!(\n            \"dYdX only supports EXTERNAL aggregation, was {:?}\",\n            bar_type.aggregation_source()\n        );\n    }\n\n    let spec = bar_type.spec();\n    if spec.price_type != PriceType::Last {\n        anyhow::bail!(\n            \"dYdX only supports LAST price type, was {:?}\",\n            spec.price_type\n        );\n    }\n\n    DydxCandleResolution::from_bar_spec(&spec)\n}\n\n/// Default dYdX Indexer REST API rate limit.\n///\n/// The dYdX Indexer API rate limit is 100 requests per 10 seconds per IP.\n/// We use 9 req/s (vs the exact 10) to avoid edge-case 429s from\n/// GCRA vs server sliding-window misalignment at the boundary.\npub static DYDX_REST_QUOTA: LazyLock<Quota> = LazyLock::new(|| {\n    Quota::per_second(NonZeroU32::new(9).expect(\"non-zero\")).expect(\"valid constant\")\n});\n\ntype DydxRestRateLimiter = Arc<RateLimiter<Ustr, MonotonicClock>>;","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/http/client.rs#L106-L142","documentation":"bar_type_to_resolution received a bar type whose price type (from PriceType on the bar spec) is not LAST; the dYdX v4 indexer only serves candles computed from last-trade prices, so any other price source cannot be requested.","triggerScenarios":"Calling `request_bars` with a bar spec using `PriceType::Bid`, `PriceType::Ask`, `PriceType::Mid`, or `PriceType::Vwap` instead of `PriceType::Last`.","commonSituations":"Requesting bid/ask candles as one would from a broker with quote data; building bar specs generically from user config without restricting price type for dYdX.","solutions":["Change the bar spec price type to `PriceType::Last`","If bid/ask bars are required, source them from a different adapter or compute them client-side from trade data"],"exampleFix":"// before\nlet spec = BarSpecification::new(1, BarAggregation::Minute, PriceType::Mid);\n// after\nlet spec = BarSpecification::new(1, BarAggregation::Minute, PriceType::Last);","handlingStrategy":"validation","validationCode":"assert_eq!(bar_type.spec().price_type, PriceType::Last, \"dYdX requires LAST price type\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix PriceType::Last in the dYdX data client config","Document the price-type restriction next to where bar requests are built"],"tags":["rust","dydx","bars","price-type"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}