{"record":{"id":"bb8840b1e8e57394","repo":"nautechsystems/nautilus_trader","slug":"load-funding-rates-not-implemented-for-postgresql","errorCode":null,"errorMessage":"load_funding_rates not implemented for PostgreSQL cache adapter","messagePattern":"load_funding_rates not implemented for PostgreSQL cache adapter","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/cache.rs","lineNumber":1059,"sourceCode":"                        log::error!(\n                            \"Failed to send empty trades for instrument {instrument_id}: {e:?}\"\n                        );\n                    }\n                }\n            }\n        });\n        Ok(rx.recv()?)\n    }\n\n    fn add_funding_rate(&self, _funding_rate: &FundingRateUpdate) -> anyhow::Result<()> {\n        anyhow::bail!(\"add_funding_rate not implemented for PostgreSQL cache adapter\")\n    }\n\n    fn load_funding_rates(\n        &self,\n        _instrument_id: &InstrumentId,\n    ) -> anyhow::Result<Vec<FundingRateUpdate>> {\n        anyhow::bail!(\"load_funding_rates not implemented for PostgreSQL cache adapter\")\n    }\n\n    fn add_bar(&self, bar: &Bar) -> anyhow::Result<()> {\n        let query = DatabaseQuery::AddBar(bar.to_owned());\n        self.tx.send(query).map_err(|e| {\n            anyhow::anyhow!(\"Failed to send query add_bar to database message handler: {e}\")\n        })\n    }\n\n    fn load_bars(&self, instrument_id: &InstrumentId) -> anyhow::Result<Vec<Bar>> {\n        let pool = self.pool.clone();\n        let instrument_id = instrument_id.to_owned();\n        let (tx, rx) = std::sync::mpsc::channel();\n\n        tokio::spawn(async move {\n            let result = DatabaseQueries::load_bars(&pool, &instrument_id).await;\n            match result {\n                Ok(bars) => {","sourceCodeStart":1041,"sourceCodeEnd":1077,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/cache.rs#L1041-L1077","documentation":"The PostgreSQL cache adapter implements the CacheDatabaseAdapter trait but load_funding_rates() is an explicit stub: it unconditionally calls anyhow::bail! instead of querying the database. Funding-rate history reads are simply not implemented for this adapter, so any attempt to load them fails immediately.","triggerScenarios":"Calling cache.load_funding_rates(instrument_id) (or any higher-level data path that reads funding rates back) while the backing cache database is the PostgreSQL adapter created via the sql/cache.rs adapter in nautilus_infrastructure.","commonSituations":"Developers persisting market data to Postgres and later replaying/backtesting from it, assuming funding rates round-trip like bars/quotes do; switching the cache backend from an in-memory or other adapter that supports funding rates to Postgres; feature parity gaps after adopting the SQL adapter.","solutions":["Do not read funding rates through the PostgreSQL cache adapter; load them from the source exchange adapter instead","Check the nautilus_trader version/release notes and upgrade if a newer version implements load_funding_rates for the Postgres adapter","Contribute or patch the adapter: implement the query in load_funding_rates alongside the existing add_* implementations in crates/infrastructure/src/sql/cache.rs","Catch the anyhow error and fall back to an alternative data source at the call site"],"exampleFix":"// before\nlet updates = cache.load_funding_rates(&instrument_id)?;\n// after\nlet updates = match cache.load_funding_rates(&instrument_id) {\n    Ok(u) => u,\n    Err(e) if e.to_string().contains(\"not implemented\") => {\n        // fall back to exchange adapter or an empty/partial set\n        Vec::new()\n    }\n};","handlingStrategy":"fallback","validationCode":"// feature check before calling\nfn postgres_supports_funding_rates() -> bool { false } // current adapter capability\nif !postgres_supports_funding_rates() {\n    log::warn!(\"load_funding_rates unsupported on Postgres cache; using exchange source\");\n}","typeGuard":null,"tryCatchPattern":"match cache.load_funding_rates(&instrument_id) {\n    Ok(updates) => updates,\n    Err(e) => { log::warn!(\"funding rates unavailable: {e}\"); Vec::new() }\n}","preventionTips":["Check adapter capability (which CacheDatabaseAdapter methods are implemented) before choosing the Postgres cache for a workflow needing funding-rate reads","Read the stub source in crates/infrastructure/src/sql/cache.rs before relying on a read method","Route funding-rate reads to the exchange/data adapter and use Postgres only for writes"],"tags":["rust","postgresql","not-implemented","funding-rates","cache-adapter"],"backgroundTag":"method-not-implemented","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"}