aboutsummaryrefslogtreecommitdiff
path: root/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'api.py')
-rw-r--r--api.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/api.py b/api.py
index 00c2733..41e361a 100644
--- a/api.py
+++ b/api.py
@@ -28,6 +28,10 @@ def fetch_chart_data(ticker, period='1y', interval='1d'):
data_obj = r.json()
# get the specific data we want
+ if 'timestamp' not in data_obj['chart']['result'][0]:
+ last_data = pull_last_from_file()
+ last_data['error'] = True
+ return last_data
timestamps = data_obj['chart']['result'][0]['timestamp']
close_prices = data_obj['chart']['result'][0]['indicators']['quote'][0]['close']
@@ -43,7 +47,6 @@ def fetch_chart_data(ticker, period='1y', interval='1d'):
name = data_obj['chart']['result'][0]['meta']['longName']
data = {'timestamps': timestamps, 'prices': close_prices, 'name': name, 'error': False}
-
update_last_file(data)
# save data to file in case necessary
return data