RN Genesis
Posted on March 25, 2023
Financial data is crucial for making informed investment decisions. Historically, access to this data was limited to those who could afford it, such as institutions that paid hefty fees for services like Bloomberg terminals. However, the emergence of stock market data APIs has democratized access to financial information, allowing individuals to obtain the same data at a fraction of the cost. It is worth mentioning that some stock market APIs also offer peripheral data services such as News API, ESG, or other alternative datasets. For the sake of simplicity, we will focus on the strength of core financial data offerings in this article.
While there are many financial data APIs available [1], it's essential to choose the one that best suits your needs, as not all APIs are created equal. In this article, we will survey 3 popular stock data APIs to get a wide range of data from the financial market, spanning asset classes such as stocks, cryptocurrencies, mutual funds, commodities, etc:
- Alpha Vantage
- Tradier
- Intrinio
I will also include Python-based sample codes for my fellow developers and algorithmic traders.
Let's get to it!
Alpha Vantage
Alpha Vantage is a popular financial data provider offering accessible and developer-friendly APIs for a diverse range of markets, including stocks, crypto, commodities, and currencies. With a large global user base, the API platform boasts over 500 open-source repositories for easy integration across various programming languages. Alpha Vantage provides over a billion data points, 50+ technical indicators, and 20+ years of historical data, making it an attractive choice for both hobbyist investors and serious professionals. Coverage extends to fundamentals, technicals, forex, financial news, economic data, corporate events, and more.
Below is a sample code snippet to get daily historical data for IBM:
import requests
# replace the "demo" apikey with your own API key, which can be acquired from https://www.alphavantage.co/support/#api-key
url = 'https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=IBM&apikey=demo'
r = requests.get(url)
data = r.json()
print(data)
Tradier
Tradier is a unique platform that combines market data with a trading API, enabling users to test strategies and execute trades all in one place. Opening a free brokerage account with Tradier grants access to real-time equity and option pricing (a rare gem among data providers).
Below is a sample code snippet that demonstrates Tradier API integration. It uses an open-source Python library called PyTradier [2].
import PyTradier
tradier = Tradier(token='abc123', account_id='123456', sandbox=False)
stocks = tradier.stock('AAPL', 'MSFT')
options = tradier.option('AAPL170630P00130000')
Intrinio
Intrinio offers a variety of financial data and analytics through a unique pay-per-service model, allowing users to select specific data packages tailored to their needs. Intrinio provides extensive coverage and decades of historical data. Additionally, they offer a wide array of alternative data feeds, making them an ideal choice for users seeking differentiated market insights in addition to "tradition" equity data feeds.
Below is a sample Python code snippet that retrieves company filing data with the official Intrinio Python SDK.
from __future__ import print_function
import time
import intrinio_sdk as intrinio
from intrinio_sdk.rest import ApiException
intrinio.ApiClient().set_api_key('YOUR_API_KEY')
intrinio.ApiClient().allow_retries(True)
identifier = 'GME'
report_type = ''
start_date = '2020-01-01'
end_date = ''
thea_enabled = ''
page_size = 50
next_page = ''
response = intrinio.CompanyApi().get_company_filings(identifier, report_type=report_type, start_date=start_date, end_date=end_date, thea_enabled=thea_enabled, page_size=page_size, next_page=next_page)
print(response)
That's it for now! Do you use Alpha Vantage, Tradier, or Intrinio in your quantitative investing activities, or some other data sources? Please let me know if the comment section.
References & Citations
[1] https://hackernoon.com/best-stock-market-apis-a-guide-for-data-scientists-and-algorithmic-traders
[2] https://pytradier.readthedocs.io/en/latest/getting_started/quick_start.html
Posted on March 25, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.