Financial data nowadays, is surprisingly hard to get. Thanks to the new kid in the block Finnhub, we now have access to a free stock api with super high quality data. You can build trading strategy using their free data and backtest it in live market for free. In this example, we will try to pull the price of Apple and calculate a simple moving average.You can get your Free API key first to access 60 calls/minute. In this tutorial I will use the API without a API key, which will limit me to 2 calls per mintue. Here is an example:
Get 2000 Daily candles for AAPLhttps://finnhub.io/api/v1/stock/candle?symbol=AAPL&resolution=D&count=500
import pandas as pd
r = requests.get('https://finnhub.io/api/v1/stock/candle?symbol=AAPL&resolution=D&count=500')
j = json.loads(r.text)
closes = j['c'].
N = 20