Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/API' into team-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandy Kopelke authored and Mandy Kopelke committed Sep 7, 2019
2 parents 12b58dd + 5e0f9a3 commit e6169e4
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions data_source.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@

#!/usr/bin/env python3
import requests

def import_stock_prices(company, start_date, end_date):
"""Imports a range of stock prices from an API.
* company - string company name (must be uppercase)
* start_date - datetime.date object
* end_date - datetime.date object
Returns stock data formatted as described in README.md.
"""
* company - string company name (must be uppercase)
* start_date - e.g year-date-month
* end_date - e.g year-date-month
Returns stock data formatted as described in README.md.
"""

URL = 'https://financialmodelingprep.com/api/v3/historical-price-full/'
stock_data = requests.get(URL + company + "?from=" + start_date + '-01' + "&to=" + end_date + '-31')
return stock_data.json()

dump = import_stock_prices('AAPL', '2018-03', '2018-04')
count = 0
lowsum = []

#testing averaging lows
for data in dump:
for key in data:
try:
lowsum.append(dump['historical'][count]['low'])
count += 1
print(sum(lowsum) / count)
except:
break

0 comments on commit e6169e4

Please sign in to comment.