The most popular and useful Python libraries and APIs for different free market-data services and sources.
yfinance
Yfinance offers a threaded and Pythonic way to download market data from Yahoo Finance.
Yfinance is an open-source tool that uses Yahoo's publicly available APIs (yfinance is not affiliated, endorsed, or vetted by Yahoo, Inc.), and is intended for research and educational purposes.
- Project on pypi → https://pypi.org/project/yfinance/
- Project on GitHub → https://github.com/ranaroussi/yfinance
- Description and examples on the yfinance developer blog → https://aroussi.com/post/python-yahoo-finance
Nasdaq Data Link (ex Quandl)
Most datasets on Nasdaq Data Link are available directly in Python, using the Nasdaq Data Link Python module. The Nasdaq Data Link Python package is free to use and grants access to all free datasets. Users only pay to access Nasdaq Data Link’s premium data products.
- Project on pypi → https://pypi.org/project/Nasdaq-Data-Link/
- Project on GitHub → https://github.com/Nasdaq/data-link-python
- Examples → https://data.nasdaq.com/tools/python
Alpha Vantage
Alpha Vantage APIs are grouped into six categories: (1) Core Time Series Stock Data APIs, (2) Alpha Intelligence, (3) Fundamental Data, (4) Physical and Digital/Crypto Currencies (e.g., Bitcoin), (5) Economic Indicators, and (6) Technical Indicators.
- Project on pypi → https://pypi.org/project/alpha-vantage/
- Project on GitHub → https://github.com/RomelTorres/alpha_vantage
- Examples → https://www.alphavantage.co/documentation/
pandas-datareader
Pandas Datareader is a Python package that allows us to create a pandas DataFrame object by using various data sources (AlphaVantage, Bank of Canada, Eurostat, Moscow Exchange (MOEX), NASDAQ, Quandl, Yahoo Finance, and many more).
- Project on pypi → https://pypi.org/project/pandas-datareader/
- Project on GitHub → https://github.com/pydata/pandas-datareader
- Examples → https://pandas-datareader.readthedocs.io/en/latest/remote_data.html
IBApi / TWS API
The TWS API is a simple yet powerful interface to automate your trading strategies, request market data, and monitor your account balance and portfolio in real time. Build your own trading application or connect your custom application to TWS so that you can take advantage of our advanced trading tools.
- Project on pypi → https://pypi.org/project/ibapi/
- Project on GitHub → https://interactivebrokers.github.io/tws-api/
- Examples → https://interactivebrokers.github.io/tws-api/
Twelve Data
Data is available in pandas, json and csv formats. About 100 available and ready-for-use technical indicators. Static and interactive charts from the same source as financial data. Many subsidiary methods to build from simple applications to ML & AI projects.
- Project on pypi → https://pypi.org/project/twelvedata/
- Project on GitHub → https://github.com/twelvedata
- Examples → https://twelvedata.com/blog/get-high-quality-financial-data-directly-into-python
Tiingo
Tiingo is a financial data platform that makes high quality financial tools available to all. They have a RESTful and Real-Time Data API. Presently, the API includes support for the following endpoints: Stock Market Ticker Closing Prices + Metadata. Data includes full distribution details and is validated using a proprietary EOD Price Engine; Curated news from top financial news sources + curated blogs. Stories are tagged by Tiingo’s algorithms.
- Project on pypi → https://pypi.org/project/tiingo/
- Project on GitHub → https://github.com/hydrosquall/tiingo-python
- Examples → https://tiingo-python.readthedocs.io/en/latest/
Polygon .io
Polygon.io has several Open Source projects that you can use to easily interact with our financial data APIs. Polygon.io also provides client libraries for Python.
- Project on pypi → https://pypi.org/project/polygon-io/
- Project on GitHub → https://github.com/polygon-io/client-python
- Examples → https://polygon.io/docs/stocks/getting-started
Finnhub
The API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
- Project on pypi → https://pypi.org/project/finnhub-python/
- Project on GitHub → https://github.com/Finnhub-Stock-API/finnhub-python
- Examples → https://finnhub.io/docs/api
Tradier
Rrealtime data for US-based stocks and options is available only to Tradier Brokerage account holder.
- Project on pypi → https://pypi.org/project/tradier-python/ ; https://github.com/cablehead/python-tradier
- Project on GitHub → https://github.com/rleonard21/PyTradier
- Examples → https://documentation.tradier.com/brokerage-api/overview/market-data