bugfixing pe was string in screener workflow
This commit is contained in:
parent
109386ed8d
commit
7b90534cfe
@ -1174,7 +1174,7 @@ async def get_watchlist(data: GetWatchList, api_key: str = Security(get_api_key)
|
|||||||
res = {'data': combined_results, 'news': combined_news}
|
res = {'data': combined_results, 'news': combined_news}
|
||||||
res = orjson.dumps(res)
|
res = orjson.dumps(res)
|
||||||
compressed_data = gzip.compress(res)
|
compressed_data = gzip.compress(res)
|
||||||
|
print(combined_results)
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
io.BytesIO(compressed_data),
|
io.BytesIO(compressed_data),
|
||||||
media_type="application/json",
|
media_type="application/json",
|
||||||
|
|||||||
@ -401,7 +401,7 @@ async def get_stock_screener(con):
|
|||||||
|
|
||||||
#Stock Screener Data
|
#Stock Screener Data
|
||||||
|
|
||||||
cursor.execute("SELECT symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_20, sma_50, sma_100, sma_200, ema_20, ema_50, ema_100, ema_200, rsi, atr, stoch_rsi, mfi, cci, pe, marketCap, beta FROM stocks WHERE symbol NOT LIKE '%.%' AND eps IS NOT NULL AND marketCap IS NOT NULL AND beta IS NOT NULL")
|
cursor.execute("SELECT symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_20, sma_50, sma_100, sma_200, ema_20, ema_50, ema_100, ema_200, rsi, atr, stoch_rsi, mfi, cci, beta FROM stocks WHERE symbol NOT LIKE '%.%' AND eps IS NOT NULL AND marketCap IS NOT NULL AND beta IS NOT NULL")
|
||||||
raw_data = cursor.fetchall()
|
raw_data = cursor.fetchall()
|
||||||
stock_screener_data = [{
|
stock_screener_data = [{
|
||||||
'symbol': symbol,
|
'symbol': symbol,
|
||||||
@ -425,15 +425,13 @@ async def get_stock_screener(con):
|
|||||||
'stochRSI': stoch_rsi,
|
'stochRSI': stoch_rsi,
|
||||||
'mfi': mfi,
|
'mfi': mfi,
|
||||||
'cci': cci,
|
'cci': cci,
|
||||||
'pe': pe,
|
|
||||||
'marketCap': marketCap,
|
|
||||||
'beta': beta,
|
'beta': beta,
|
||||||
} for (symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_20, sma_50, sma_100, sma_200, ema_20, ema_50, ema_100, ema_200, rsi, atr, stoch_rsi, mfi, cci, pe, marketCap, beta) in raw_data]
|
} for (symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_20, sma_50, sma_100, sma_200, ema_20, ema_50, ema_100, ema_200, rsi, atr, stoch_rsi, mfi, cci, beta) in raw_data]
|
||||||
|
|
||||||
stock_screener_data = [{k: round(v, 2) if isinstance(v, (int, float)) else v for k, v in entry.items()} for entry in stock_screener_data]
|
stock_screener_data = [{k: round(v, 2) if isinstance(v, (int, float)) else v for k, v in entry.items()} for entry in stock_screener_data]
|
||||||
|
|
||||||
|
|
||||||
cursor.execute("SELECT symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_50, sma_200, ema_50, ema_200, rsi, atr, stoch_rsi, mfi, cci, pe, marketCap, beta FROM stocks WHERE symbol NOT LIKE '%.%' AND eps IS NOT NULL AND marketCap IS NOT NULL AND beta IS NOT NULL")
|
cursor.execute("SELECT symbol, name, change_1W, change_1M, change_3M, change_6M, change_1Y, change_3Y, sma_50, sma_200, ema_50, ema_200, rsi, atr, stoch_rsi, mfi, cci, beta FROM stocks WHERE symbol NOT LIKE '%.%' AND eps IS NOT NULL AND marketCap IS NOT NULL AND beta IS NOT NULL")
|
||||||
raw_data = cursor.fetchall()
|
raw_data = cursor.fetchall()
|
||||||
|
|
||||||
# Iterate through stock_screener_data and update 'price' and 'changesPercentage' if symbols match
|
# Iterate through stock_screener_data and update 'price' and 'changesPercentage' if symbols match
|
||||||
@ -449,12 +447,16 @@ async def get_stock_screener(con):
|
|||||||
item['avgVolume'] = int(res['avgVolume'])
|
item['avgVolume'] = int(res['avgVolume'])
|
||||||
item['volume'] = int(res['volume'])
|
item['volume'] = int(res['volume'])
|
||||||
item['relativeVolume'] = round(( item['volume'] / item['avgVolume'] )*100,2)
|
item['relativeVolume'] = round(( item['volume'] / item['avgVolume'] )*100,2)
|
||||||
|
item['pe'] = round(float(res['pe']),2)
|
||||||
|
item['marketCap'] = int(res['marketCap'])
|
||||||
except:
|
except:
|
||||||
item['price'] = None
|
item['price'] = None
|
||||||
item['changesPercentage'] = None
|
item['changesPercentage'] = None
|
||||||
item['avgVolume'] = None
|
item['avgVolume'] = None
|
||||||
item['volume'] = None
|
item['volume'] = None
|
||||||
item['relativeVolume'] = None
|
item['relativeVolume'] = None
|
||||||
|
item['pe'] = None
|
||||||
|
item['marketCap'] = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(f"json/stockdeck/{symbol}.json", 'r') as file:
|
with open(f"json/stockdeck/{symbol}.json", 'r') as file:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user