add volume to eod data

This commit is contained in:
MuslemRahimi 2024-11-04 20:24:13 +01:00
parent 7a2dd2379f
commit 422f794c28
2 changed files with 4 additions and 2 deletions

View File

@ -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 ?
"""

View File

@ -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}