update
This commit is contained in:
parent
9de702534f
commit
286f88ab78
@ -20,10 +20,16 @@ async def save_json(symbol, data):
|
|||||||
async def get_data(symbol):
|
async def get_data(symbol):
|
||||||
"""Extract specified columns data for a given symbol."""
|
"""Extract specified columns data for a given symbol."""
|
||||||
columns = ['sharesOutStanding', 'sharesQoQ', 'sharesYoY','institutionalOwnership','floatShares',
|
columns = ['sharesOutStanding', 'sharesQoQ', 'sharesYoY','institutionalOwnership','floatShares',
|
||||||
'priceEarningsRatio','forwardPE','priceToSalesRatio','forwardPS','priceToBookRatio','priceToFreeCashFlowsRatio',
|
'peg','priceEarningsRatio','forwardPE','priceToSalesRatio','forwardPS','priceToBookRatio','priceToFreeCashFlowsRatio',
|
||||||
'sharesShort','shortOutStandingPercent','shortFloatPercent','shortRatio',
|
'sharesShort','shortOutStandingPercent','shortFloatPercent','shortRatio',
|
||||||
'enterpriseValue','evEarnings','evSales','evEBITDA','evEBIT','evFCF',
|
'enterpriseValue','evEarnings','evSales','evEBITDA','evEBIT','evFCF',
|
||||||
'currentRatio','quickRatio','debtRatio','debtEquityRatio',]
|
'currentRatio','quickRatio','debtRatio','debtEquityRatio','interestCoverage','cashFlowToDebtRatio','totalDebtToCapitalization',
|
||||||
|
'returnOnEquity','returnOnAssets','returnOnCapital','revenuePerEmployee','profitPerEmployee',
|
||||||
|
'employees','assetTurnover','inventoryTurnover','incomeTaxExpense','effectiveTaxRate','beta','returnOnInvestedCapital',
|
||||||
|
'change1Y','sma50','sma200','rsi','avgVolume','revenue','netIncome','grossProfit','operatingIncome','ebitda','ebit','eps',
|
||||||
|
'cashAndCashEquivalents','totalDebt','retainedEarnings','totalAssets','workingCapital','operatingCashFlow',
|
||||||
|
'capitalExpenditure','freeCashFlow','freeCashFlowPerShare','grossProfitMargin','operatingProfitMargin','pretaxProfitMargin',
|
||||||
|
'netProfitMargin','ebitdaMargin','ebitMargin','freeCashFlowMargin']
|
||||||
|
|
||||||
if symbol in stock_screener_data_dict:
|
if symbol in stock_screener_data_dict:
|
||||||
result = {}
|
result = {}
|
||||||
@ -45,7 +51,7 @@ async def run():
|
|||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
# Process symbols with progress bar
|
# Process symbols with progress bar
|
||||||
for symbol in tqdm(total_symbols, desc="Extracting dividend data"):
|
for symbol in tqdm(total_symbols, desc="Extracting data"):
|
||||||
data = await get_data(symbol)
|
data = await get_data(symbol)
|
||||||
if data: # Only save if we have data
|
if data: # Only save if we have data
|
||||||
await save_json(symbol, data)
|
await save_json(symbol, data)
|
||||||
|
|||||||
29
app/main.py
29
app/main.py
@ -4112,6 +4112,35 @@ async def get_insider_tracker(api_key: str = Security(get_api_key)):
|
|||||||
headers={"Content-Encoding": "gzip"}
|
headers={"Content-Encoding": "gzip"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.post("/statistics")
|
||||||
|
async def get_statistics(data: TickerData, api_key: str = Security(get_api_key)):
|
||||||
|
ticker = data.ticker
|
||||||
|
cache_key = f"statistics-{ticker}"
|
||||||
|
cached_result = redis_client.get(cache_key)
|
||||||
|
if cached_result:
|
||||||
|
return StreamingResponse(
|
||||||
|
io.BytesIO(cached_result),
|
||||||
|
media_type="application/json",
|
||||||
|
headers={"Content-Encoding": "gzip"}
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
with open(f"json/statistics/{ticker}.json", 'rb') as file:
|
||||||
|
res = orjson.loads(file.read())
|
||||||
|
except:
|
||||||
|
res = {}
|
||||||
|
|
||||||
|
data = orjson.dumps(res)
|
||||||
|
compressed_data = gzip.compress(data)
|
||||||
|
|
||||||
|
redis_client.set(cache_key, compressed_data)
|
||||||
|
redis_client.expire(cache_key,60*60)
|
||||||
|
|
||||||
|
return StreamingResponse(
|
||||||
|
io.BytesIO(compressed_data),
|
||||||
|
media_type="application/json",
|
||||||
|
headers={"Content-Encoding": "gzip"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/newsletter")
|
@app.get("/newsletter")
|
||||||
async def get_newsletter():
|
async def get_newsletter():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user