This little-known Python package lets analysts tap into vast economic and financial data
A single data feed to automate your reports, dashboards, and models—without paying for expensive data terminals.
Finding all the necessary data for your research or prediction model can feel like a scavenger hunt. You might spend hours hunting down the right API, importing several libraries into your Python code, and then wrestle with different functions and output formats for each API.
Analysts and traders at investment banks have access to expensive platforms like Bloomberg (~$30K USD per year) to avoid this headache.
But those in the know use a powerful open-source Python package to solve this—OpenBB. With it, any analyst can get direct access to a vast selection of economic and financial series through a single unified library. Everything from macroeconomic data, stock prices, and financial statements to port volumes, and Bitcoin prices.
Since the API is accesible via Python, you can programmatically automate reports that refresh themselves, create bespoke Streamlit dashboards, or build AI agents that deliver you company insights via email each morning.
Here's what we'll cover today:
What is OpenBB?
Setup in Python
How to find and extract data
Example code snippet for creating company profiles (financial statements, breaking news) [Bonus for paid subscribers]
Don't worry if you're relatively new to Python—I’ll explain it step-by-step with examples.
Autonomous Econ is a newsletter that empowers economists and data analysts with easy-to-follow Python tutorials that deliver big results.
Subscribe and join 3.8k+ others to work smarter through automation and become a savvier analyst.
(1) What Is OpenBB?
At its core, OpenBB is an open-source data router and toolbox.
It gives you streamlined access to multiple data sources (FRED, Yahoo Finance, Alpha Vantage, IMF, and more) under a single, consistent API.
With OpenBB, you:
Import one module (
from openbb import obb
) to unlock multiple providers.Call a high-level function (e.g.,
obb.equity.price.historical
orobb.economy.fred_series
).OpenBB picks the best data source based on the API credentials you configure and sensible defaults.
Receive clean pandas DataFrames ready for immediate plotting, modeling, or exporting.
Additionally, the package includes tools for technical analysis and charting.
(2) Setup in Python
Setup the work evironment
To get started, you'll need:
A code editor to write and run code efficiently—I highly recommend VS Code. See my installation guide here.
A Python virtual environment (using venv or Conda)—this is a best practice to keep your projects and their packages isolated. I have a walkthrough on setting up virtual environments here.
Install the core package
In the terminal window of your virtual environment, install the package using pip:
pip install openbb
There are additional community data and toolkit extensions that are not installed by default—for example, openbb-federal-reserve
. Refer to the full list of available extensions in their docs.
Add your API keys
Some data providers require an API key (e.g., FRED), while others don’t (e.g., Yahoo Finance). You can check which ones require keys in this table.
Premium APIs: A lot of core data from APIs is free. However, serious analysts or traders might consider paid API tiers from providers like FMP and Polygon. These give access to unlimited API calls per minute, extended historical data, real-time data, and premium indicators.
These API keys need to be stored so that OpenBB can automatically read them when you call a data endpoint.
The simplest way is to add them all to a central JSON file locally, typically located in your file path like: C:\Users\john\.openbb_platform\user_settings.json.
Add the keys to the file using the format below. Refer to the OpenBB documentation for a detailed guide.
{
"credentials": {
"fred_api_key": "APIKEY",
"fmp_api_key": "APIKEY"
}
}
Alternatively, you can add the keys locally via Python code by running these commands:
from openbb import obb
# Set and save your FRED API key
obb.user.credentials.fred_api_key = "<YOUR_FRED_API_KEY>"
obb.account.save() # writes back to user_settings.json
There's also a way to manage your API keys through an OpenBB Hub account, if you prefer using a browser and storing keys in the cloud.
(3) How to find and extract data
Choose an endpoint to call
To find the right endpoint for data retrieval, navigate to the OpenBB Platform Reference to explore available data categories:
For example, if we’re looking for Microsoft's closing price, we would find it under Equity → Price → Historical.
You can view all available data in this endpoint by running:
from openbb import obb
obb.equity.price.historical?
Here’s a partial snippet of what's available:
How to call data and return a pandas dataframe
Once we know the endpoint, we can call it with our parameters, and it will return an OpenBB return object (OBBject).
msft=obb.equity.price.historical(
symbol="MSFT", start_date="2022-01-01", end_date="2025-05-09"
)
The OBBject stores the results of our query along with additional information, such as the data provider.
msft.provider
-> 'yfinance'
We can directly convert the OBBject into a pandas DataFrame by adding .to_df() at the end.
msft_df = obb.equity.price.historical(
symbol="MSFT", start_date="2022-01-01", end_date="2025-05-03"
).to_df()
How do we know what parameters to use?
To check this, we can once again use the help command. This time, I’m checking which parameters are allowed for real GDP data.
obb.economy.gdp.real?
Given these allowed parameters, we can extract GDP data for New Zealand like so:
nz_gdp_real_df=obb.economy.gdp.real(
provider="oecd",
start_date='1990-01-01',
end_date="2025-01-01",
country='new_zealand',
frequency='quarter',
).to_df()
When should I choose a different provider?
OpenBB will automatically select from its built-in list of data providers when you omit the explicit provider argument.
For example, when you use the help command on CPI data, the default priority is FRED, followed by OECD. So, if you’ve configured your FRED API key, OpenBB will use FRED first; otherwise, it will fall back to OECD.
You may want to override the default provider if the data you need is only available from a specific source. For instance, it's possible to get the expenditure components of CPI—but only if you use the OECD data provider.
In this cases, you should adapt your data query accordingly.
us_rental_cpi = obb.economy.cpi(
provider="oecd",
start_date='2020-01-01',
end_date='2025-03-01',
country='United States',
frequency='quarter',
expenditure="actual_rentals"
).to_df()
How to search for tickers
Some endpoints (e.g., equities, ETFs, crypto) include a helpful search feature for finding tickers or symbols—these are often required as input parameters for other data sources.
Here’s how you can search for the symbol of the iShares MSCI World ETF.
ishares_search_df=obb.etf.search(query="iShares MSCI World").to_df()
And here’s an example for equities.
nividia_search_df=obb.equity.search(query="nvidia").to_df()
What’s coming up…
What I’ve shown here only scratches the surface of what’s possible with OpenBB. This guide should serve as a solid starting point for integrating OpenBB into your data workflows.
In future posts, I plan to cover some of OpenBB’s built-in tools for interactive charting and quantitative analysis, as well as how to create bespoke interactive dashboards.
Consider upgrading to a paid subscription—it's great motivation for me to keep investing time and energy into these posts.
The core of my articles are free to read, but paid subscribers will occasionally get extra perks, including code templates for useful extensions and larger projects.
(4) Bonus code snippet: How to create a company profile
Below is a complete code example showing how you can print a comprehensive company profile by simply providing a company’s stock ticker symbol as input.
The output includes:
Headline metrics and company details
The income statement for the past 4 years
The balance sheet for the past 4 years
The 10 most recent news articles about the company
Full code snippet…
Keep reading with a 7-day free trial
Subscribe to Autonomous Econ to keep reading this post and get 7 days of free access to the full post archives.