How to pull stock price history into a DataFrame with OpenBB
OpenBB gives you one Python interface for market data from many providers. Here is the shortest path from install to a table of prices you can explore or feed into a backtest.
What you need
- Python 3.11 to 3.14, the versions the project's README lists for running its backend.
- OpenBB, open source under Apache-2.0.
- pandas, which you will use to explore the result.
Step by step
- Install it. In a fresh virtual environment run
pip install openbb. - Fetch prices. The README's example is three lines:
from openbb import obb, thenoutput = obb.equity.price.historical("AAPL"), thendf = output.to_dataframe(). - Look at the table. Print
df.head()and check the columns and dates before you use them anywhere. - Try another ticker. Change the symbol and compare. Some providers behind OpenBB need their own account or API key, so check each provider's terms and limits.
- Optional: start a local API. Run
openbb-api. The README says it launches a FastAPI server at 127.0.0.1:6900 that other tools on your computer can call.
Ideas for what to do next
- Want the simplest free route? Follow the yfinance CSV guide.
- Need company fundamentals? See FinanceToolkit.
- Test an idea on the data with the backtesting guide; any example is illustrative and promises no returns.
- Browse more use cases.
Good to know
OpenBB is a connection layer, so what you get depends on the provider behind each call. The README warns that the data is not necessarily accurate, so cross-check it before relying on it. The command-line tool is a separate install (pip install openbb-cli) and the wide scope means a learning curve for beginners.
See more ideas
Browse the tool directory. Custom trading bots are coming soon: tell me when it opens.
Before you start
What does OpenBB cost and what licence does it use?
Free (open source). Licence: Apache-2.0. Prices change, so check the official website before you decide.
What should I know before using OpenBB?
It is a connection layer: many underlying data providers need their own accounts or API keys, so check each provider's terms and limits. The command-line tool is a separate install (pip install openbb-cli). Broad scope means a learning curve for beginners. The README warns that the data is not necessarily accurate, so cross-check before relying on it.
What does yfinance cost and what licence does it use?
Free (open source). Licence: Apache-2.0. Prices change, so check the official website before you decide.
What should I know before using yfinance?
Not affiliated with or endorsed by Yahoo. Its own documentation says the tool is intended for research and educational purposes and that the Yahoo Finance API is for personal use only: read their terms. Since it is not an official API, it can stop working whenever Yahoo changes something.
What does FinanceToolkit cost and what licence does it use?
Free and open source (MIT). Install with pip. The main workflow needs a Financial Modeling Prep API key, which has a free plan; check the official website for current limits and paid plans. Licence: MIT. Prices change, so check the official website before you decide.
What should I know before using FinanceToolkit?
The main workflow needs a Financial Modeling Prep API key; the README says the free plan is limited to 250 requests a day, 5 years of data and US-listed companies. Not a backtesting engine or broker connector: it calculates metrics and you build the rest. Needs Python knowledge. Data quality and coverage depend on the provider you use, so check results against the official source.
Tools in this guide
- OpenBB: Open-source data platform that connects many data sources and exposes them to Python, a command line, a local REST API and AI agents.
- yfinance: Python library to download prices and history from Yahoo Finance; widely used for research and learning.
- FinanceToolkit: Open-source Python toolkit that turns company data into financial statements, ratios, technical indicators and risk metrics, with every formula written in readable code.
- SEC EDGAR APIs: Free JSON APIs from the U.S. Securities and Exchange Commission with company filing histories and XBRL financial facts from 10-K, 10-Q, 8-K and other filings, plus nightly bulk downloads.
Compare your options
- TA-Lib vs ta vs FinanceToolkit: free Python libraries for technical indicators
- yfinance vs OpenBB vs Alpha Vantage: where to get market data for research
Want a bot like this when custom bots open? Get notified · more bot ideas
Coming soon: custom bots
We are preparing a service to code, backtest and automate trading and statistics bots to your own rules. It is not available yet: follow our Telegram channel to know when it opens.