Repository navigation
[FR] Add Bank of Canada Valet API as a new provider extension #7490
Description
What's the problem of not having this feature?
OpenBB doesn't have a Bank of Canada provider today. The European Central Bank is already covered through openbb-ecb and the US Fed through openbb-federal-reserve, so Canadian central bank data stands out as a gap. The Bank of Canada Valet API is the obvious source for filling it. It's free, public, requires no API key, and has been stable with versioned endpoints since 2017.
Describe the solution you would like
I'd like to add a new openbb-bank-of-canada community provider extension. To keep the first PR focused, I'd propose starting with three endpoints.
The first is daily exchange rates from the Valet series FX_RATES_DAILY, which would map to the existing currency_historical standard model. Valet publishes a single daily rate per pair, so the close field gets populated and the OHLC fields stay as None. This matches the pattern that other rate-only providers already use.
The second is the overnight rate target from Valet series CBC20210, mapping to the existing country_interest_rates standard model with country="canada".
The third is Government of Canada benchmark bond yields from the Valet group BD.CDN.*.DQ.YLD, mapping to the existing treasury_rates standard model. The maturity fields line up cleanly across year_2, year_3, year_5, year_7, year_10, and year_30. BoC doesn't publish sub-1Y benchmarks, so those fields would stay as None. I'm happy to discuss whether treasury_rates is the right home for a non-US sovereign curve, or whether a more generically-named model would be preferred. I went with the existing one to keep this first PR scoped, but I'm open to redirection here.
Example usage once implemented:
from openbb import obb
obb.currency.price.historical("USDCAD", provider="bank_of_canada")
obb.fixedincome.government.treasury_rates(provider="bank_of_canada")
Describe alternatives you've considered
One alternative would be broader BoC coverage in a single PR, including CORRA metrics, money aggregates, auction data, and other financial market statistics. I think those are better as follow-up PRs so the initial review stays small and easy to validate.
Another alternative would be publishing this as a third-party PyPI package without contributing upstream. That's possible, but it would lose the pip install openbb[all] experience that makes the platform easy to adopt.
Additional information
The shape would mirror openbb-ecb: focused fetchers, VCR-backed tests, and no credentials needed. I'd suggest community placement in the [all] extras and as a named extra, matching the ECB pattern already in openbb_platform/pyproject.toml.
I'm happy to implement and maintain this. I'll wait for sign-off on scope before opening a PR.
Activity
deeleeramone commentedon May 6, 2026
Ya, this has been on my perpetual to-do list. 😆 You can actually get the finer tenors through a different endpoint in the API. A lot of the datasets appear to be abandoned, and gaps are filled by the Statscan SDMX. They could reasonably be combined as a
government_caprovider.rohanjethwani17 commentedon May 6, 2026
Thanks for the context. Happy to fold the Statscan SDMX integration in and structure this as a
government-caprovider. Before I start, I have a few clarifying questions to make sure my first PR aligns with what you're picturing.Provider naming. Would you prefer
openbb-government-ca/government_ca, or something likeopenbb-canada? I want to match your conventions exactly.First PR scope. I'd still like to keep the initial PR small for review. Here's what I was thinking for the three endpoints:
BD.CDN.ALL.DQ.YLD, but I'd rather pick the one you'd actually want as the canonical source.Follow-up PRs would expand each of these sections incrementally.
Standard model mapping for Can't install with python 3.7.4 on Windows 10 #1 and requirements.txt errors on OSX Python2 and Python3 #3. I was planning to use
country_interest_ratesfor the policy rate andtreasury_ratesfor the yield curve. Do those still feel like the right homes given the broader scope, or would you prefer different standard models since the provider isn't strictly a central-bank one anymore?I'll wait for your input before opening a PR.
deeleeramone commentedon May 9, 2026
This might take a bit of imagination, but the way forward is going to look like #7489, which will prefer extensions that are self-contained (
pip install openbb-government-cawould contain both provider and router modules and entrypoints). Namespaces might look something like,obb.bocobb.statscan. Views that fit into the existing topical hierarchy are a happy side-effect of the overall intent, surfacing all useful time series and presentation tables with their metadata and data availability constraints. Endpoints likecountry_interest_ratesare intended more for where the provider supplies rates across all countries. From BOC, the main points of interests are the yield curves, open market operations, and balance sheet.IMF and OECD providers will be refactored to build the shipped metadata assets via Hatchling build hooks. These assets do the heavy work of digesting the metadata into a format that can be used efficiently on-demand, without network requests, when searching for, and describing, time series or tables and their parameters (dimensions + query params).
economy.calendar: https://www150.statcan.gc.ca/n1/dai-quo/cal3-eng.htmeconomy.available_indicators: https://www150.statcan.gc.ca/n1/dai-quo/ssi/homepage/ind-econ.jsonI think the first step with the SDMX is going to be probing it for the data structure definitions and the hierarchical code lists, then organizing into datasets -> dimensions -> table or time series -> query parameters -> validation against data availability endpoint. Once we have a catalog of what's there, then we can start shaping the general client and curated views.
rohanjethwani17 commentedon May 12, 2026
Thankyou for the direction. I also went on and read #7413 and the v5 branch to understand the shape better. Two quick specific clarifying questions before I start so I don't build against a moving target:
Should
openbb-government-cafollow the current Poetry plugin entrypoint pattern (as on v5 with cftc, federal_reserve, etc.) or the new Hatchling build hooks pattern being introduced in [V5] Refactoropenbb-oecdfor full SDMX 2 API Exposure and V5 Packaging #7413? I noticed [V5] Refactoropenbb-oecdfor full SDMX 2 API Exposure and V5 Packaging #7413 is still iterating on the cache format and module structure (binary → msgpack → JSON in recent commits), so I'd rather not mirror a pattern that's still in flux unless you'd prefer I do.Should I branch off
v5directly, or is there a specific feature branch I should base off (e.g., feature/v5-platform-api which [V5] Refactoropenbb-oecdfor full SDMX 2 API Exposure and V5 Packaging #7413 was rebased onto)?deeleeramone commentedon May 13, 2026
Great questions, and I think if you pull the latest changes from that PR you will see the full workflow pipeline for cache generation and build hooks - https://github.com/OpenBB-finance/OpenBB/pull/7413/changes#diff-4778f086c4e498eeeb3b6359b2fb122fe617e5f74a7e2c97719e9082fcc7788b - so the generated asset is a compressed JSON that is not part of version control. Other providers will get refactored to fit this pattern, so it's best to go with the Hatchling formula.
Please note that the
dev_install.pyscript has not been reconfigured on any branch yet, but entries undertool.uv.sourcesmaps to the local files in the individual pyproject.toml.PRs following the Hatchling methods should come in under the feature/* pattern, and branched off of
v5.You may not be able to open a PR against V5 directly but: a) shouldn't matter much beyond the local dev because touched files are contained to untracked folders. b) I'll fix it upstream if it's a problem.
Don't worry about the existing tests or CI linters for V4, but the goal is
ruff --format+ruff --check+ty --check+ 100% test coverage across Linux, macOS, and Windows.The reason I have PRs opened that point to
feature/cli-2, etc. instead ofv5is so that the forward functionality of the interfaces exist within the branch. All of the established V4 patterns should continue to work in V5, allegedly.I realize I've dumped a lot of info that assumes a lot of context, so feel free to probe me for clarity.