Merge pull request #5 from cotester/main_refactor
Refactor main.py #3 stock-income endpoint
This commit is contained in:
commit
da209c8d92
13
app/main.py
13
app/main.py
@ -749,10 +749,15 @@ async def stock_income(data: TickerData):
|
|||||||
symbol = ?
|
symbol = ?
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
df = pd.read_sql_query(query_template,con, params=(ticker,))
|
with db_connection(STOCK_DB) as cursor:
|
||||||
income_statement = ujson.loads(df['income'].iloc[0])
|
cursor.execute(query_template, (ticker,))
|
||||||
income_statement_growth = ujson.loads(df['income_growth'].iloc[0])
|
result = cursor.fetchone()
|
||||||
res = clean_financial_data(income_statement,income_statement_growth)
|
if result:
|
||||||
|
income_statement = ujson.loads(result[0])
|
||||||
|
income_statement_growth = ujson.loads(result[1])
|
||||||
|
res = clean_financial_data(income_statement, income_statement_growth)
|
||||||
|
else:
|
||||||
|
res = []
|
||||||
except:
|
except:
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user