From 0372b76ee22ea4421b70d6f7f8c2b29b2c7ac9dc Mon Sep 17 00:00:00 2001 From: loit Date: Tue, 29 Jul 2025 00:59:43 -0400 Subject: add basic features to indicte if parameters are bad --- api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'api.py') 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 -- cgit v1.2.3-70-g09d2