Skip to content

Instantly share code, notes, and snippets.

@joeng03
Last active May 4, 2021 09:58
Show Gist options
  • Save joeng03/6a93a52c177f1b3fdeaceecdd181a507 to your computer and use it in GitHub Desktop.
Save joeng03/6a93a52c177f1b3fdeaceecdd181a507 to your computer and use it in GitHub Desktop.
data=requests.get('https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&outputsize=full&symbol=FB&apikey=YOURAPIKEY')
data=data.json()
prices_low,prices_high,prices_close=[],[],[]
for i in range(200,1,-1):
d=date.today()-timedelta(i)
d=d.strftime("%Y-%m-%d")
try:
prices_high.append(float(data["Time Series (Daily)"][d]["2. high"]))
prices_low.append(float(data["Time Series (Daily)"][d]["3. low"]))
prices_close.append(float(data["Time Series (Daily)"][d]["4. close"]))
except:
continue
prices_low=np.array(prices_low)
prices_high=np.array(prices_high)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment