add volume to eod data
This commit is contained in:
parent
7a2dd2379f
commit
422f794c28
@ -41,16 +41,18 @@ async def get_historical_data(ticker, query_con, session):
|
|||||||
for response in [response_1w, response_1m]:
|
for response in [response_1w, response_1m]:
|
||||||
json_data = await response.json()
|
json_data = await response.json()
|
||||||
df = pd.DataFrame(json_data).iloc[::-1].reset_index(drop=True)
|
df = pd.DataFrame(json_data).iloc[::-1].reset_index(drop=True)
|
||||||
|
'''
|
||||||
try:
|
try:
|
||||||
df = df.drop(['volume'], axis=1)
|
df = df.drop(['volume'], axis=1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
'''
|
||||||
df = df.round(2).rename(columns={"date": "time"})
|
df = df.round(2).rename(columns={"date": "time"})
|
||||||
data.append(df.to_json(orient="records"))
|
data.append(df.to_json(orient="records"))
|
||||||
|
|
||||||
# Database read for 6M, 1Y, MAX data
|
# Database read for 6M, 1Y, MAX data
|
||||||
query_template = """
|
query_template = """
|
||||||
SELECT date, open,high,low,close
|
SELECT date, open,high,low,close,volume
|
||||||
FROM "{ticker}"
|
FROM "{ticker}"
|
||||||
WHERE date BETWEEN ? AND ?
|
WHERE date BETWEEN ? AND ?
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -38,7 +38,7 @@ def filter_data_quarterly(data):
|
|||||||
def get_yahoo_data(ticker, outstanding_shares, float_shares):
|
def get_yahoo_data(ticker, outstanding_shares, float_shares):
|
||||||
try:
|
try:
|
||||||
data_dict = yf.Ticker(ticker).info
|
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_outstanding_percent = round((data_dict['sharesShort']/outstanding_shares)*100,2)
|
||||||
short_float_percent = round((data_dict['sharesShort']/float_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}
|
return {'forwardPE': forward_pe}, {'sharesShort': data_dict['sharesShort'], 'shortRatio': data_dict['shortRatio'], 'sharesShortPriorMonth': data_dict['sharesShortPriorMonth'], 'shortOutStandingPercent': short_outstanding_percent, 'shortFloatPercent': short_float_percent}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user