From 422f794c2827d26869477574867492e5f7efd0a8 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 4 Nov 2024 20:24:13 +0100 Subject: [PATCH] add volume to eod data --- app/cron_historical_price.py | 4 +++- app/cron_share_statistics.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/cron_historical_price.py b/app/cron_historical_price.py index a76034d..346f684 100755 --- a/app/cron_historical_price.py +++ b/app/cron_historical_price.py @@ -41,16 +41,18 @@ async def get_historical_data(ticker, query_con, session): for response in [response_1w, response_1m]: json_data = await response.json() df = pd.DataFrame(json_data).iloc[::-1].reset_index(drop=True) + ''' try: df = df.drop(['volume'], axis=1) except: pass + ''' df = df.round(2).rename(columns={"date": "time"}) data.append(df.to_json(orient="records")) # Database read for 6M, 1Y, MAX data query_template = """ - SELECT date, open,high,low,close + SELECT date, open,high,low,close,volume FROM "{ticker}" WHERE date BETWEEN ? AND ? """ diff --git a/app/cron_share_statistics.py b/app/cron_share_statistics.py index dcfb8b2..486aa09 100644 --- a/app/cron_share_statistics.py +++ b/app/cron_share_statistics.py @@ -38,7 +38,7 @@ def filter_data_quarterly(data): def get_yahoo_data(ticker, outstanding_shares, float_shares): try: data_dict = yf.Ticker(ticker).info - forward_pe = round(data_dict['forwardPE'],2) + forward_pe = round(data_dict.get('forwardPE'), 2) if data_dict.get('forwardPE') is not None else None short_outstanding_percent = round((data_dict['sharesShort']/outstanding_shares)*100,2) short_float_percent = round((data_dict['sharesShort']/float_shares)*100,2) return {'forwardPE': forward_pe}, {'sharesShort': data_dict['sharesShort'], 'shortRatio': data_dict['shortRatio'], 'sharesShortPriorMonth': data_dict['sharesShortPriorMonth'], 'shortOutStandingPercent': short_outstanding_percent, 'shortFloatPercent': short_float_percent}