update ftd shares

This commit is contained in:
MuslemRahimi 2024-12-31 12:44:50 +01:00
parent b88df70110
commit 3a82ea490a
2 changed files with 18 additions and 19 deletions

View File

@ -26,7 +26,7 @@ query_template = """
async def get_data(symbol):
"""Extract specified columns data for a given symbol."""
columns = ['dividendYield', 'employees', 'marketCap']
columns = ['dividendYield', 'employees', 'marketCap','relativeFTD']
if symbol in stock_screener_data_dict:
result = {}

View File

@ -2631,23 +2631,7 @@ async def get_pre_post_quote(data:TickerData, api_key: str = Security(get_api_ke
return res
@app.post("/options-net-flow-ticker")
async def get_options_net_flow(data:TickerData, api_key: str = Security(get_api_key)):
ticker = data.ticker.upper()
cache_key = f"options-net-flow-ticker-{ticker}"
cached_result = redis_client.get(cache_key)
if cached_result:
return orjson.loads(cached_result)
try:
with open(f"json/options-net-flow/companies/{ticker}.json", 'rb') as file:
res = orjson.loads(file.read())
except:
res = []
redis_client.set(cache_key, orjson.dumps(res))
redis_client.expire(cache_key, caching_time)
return res
@app.post("/options-stats-ticker")
async def get_options_stats_ticker(data:TickerData, api_key: str = Security(get_api_key)):
@ -3499,7 +3483,12 @@ async def get_fail_to_deliver(data:TickerData, api_key: str = Security(get_api_k
cache_key = f"fail-to-deliver-{ticker}"
cached_result = redis_client.get(cache_key)
if cached_result:
return orjson.loads(cached_result)
return StreamingResponse(
io.BytesIO(cached_result),
media_type="application/json",
headers={"Content-Encoding": "gzip"}
)
try:
with open(f"json/fail-to-deliver/companies/{ticker}.json", 'rb') as file:
res = orjson.loads(file.read())
@ -3508,7 +3497,17 @@ async def get_fail_to_deliver(data:TickerData, api_key: str = Security(get_api_k
redis_client.set(cache_key, orjson.dumps(res))
redis_client.expire(cache_key, 3600*3600) # Set cache expiration time to 1 day
return res
data = orjson.dumps(res)
compressed_data = gzip.compress(data)
redis_client.set(cache_key, compressed_data)
redis_client.expire(cache_key, 3600*3600) # Set cache expiration time to 1 day
return StreamingResponse(
io.BytesIO(compressed_data),
media_type="application/json",
headers={"Content-Encoding": "gzip"}
)
@app.post("/borrowed-share")
async def get_borrowed_share(data:TickerData, api_key: str = Security(get_api_key)):