update peg ratio
This commit is contained in:
parent
82360fa11c
commit
7cf63dd536
@ -20,7 +20,7 @@ async def save_json(symbol, data):
|
||||
async def get_data(symbol):
|
||||
"""Extract specified columns data for a given symbol."""
|
||||
columns = ['sharesOutStanding', 'sharesQoQ', 'sharesYoY','institutionalOwnership','floatShares',
|
||||
'peg','priceEarningsRatio','forwardPE','priceToSalesRatio','forwardPS','priceToBookRatio','priceToFreeCashFlowsRatio',
|
||||
'priceEarningsToGrowthRatio','priceEarningsRatio','forwardPE','priceToSalesRatio','forwardPS','priceToBookRatio','priceToFreeCashFlowsRatio',
|
||||
'sharesShort','shortOutStandingPercent','shortFloatPercent','shortRatio',
|
||||
'enterpriseValue','evEarnings','evSales','evEBITDA','evEBIT','evFCF',
|
||||
'currentRatio','quickRatio','debtRatio','debtEquityRatio','interestCoverage','cashFlowToDebtRatio','totalDebtToCapitalization',
|
||||
@ -37,12 +37,14 @@ async def get_data(symbol):
|
||||
if symbol in stock_screener_data_dict:
|
||||
result = {}
|
||||
for column in columns:
|
||||
result[column] = stock_screener_data_dict[symbol].get(column, None)
|
||||
try:
|
||||
result[column] = stock_screener_data_dict[symbol].get(column, None)
|
||||
except:
|
||||
pass
|
||||
return result
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
async def run():
|
||||
"""Main function to run the data extraction process."""
|
||||
# Connect to SQLite database
|
||||
|
||||
@ -968,20 +968,19 @@ async def get_stock_screener(con):
|
||||
|
||||
try:
|
||||
with open(f"json/analyst-estimate/{symbol}.json", 'r') as file:
|
||||
res = orjson.loads(file.read())
|
||||
res = orjson.loads(file.read())[-1]
|
||||
item['forwardPS'] = None
|
||||
item['peg'] = None
|
||||
for analyst_item in res:
|
||||
if analyst_item['date'] == next_year and item['marketCap'] > 0 and analyst_item['estimatedRevenueAvg'] > 0:
|
||||
# Calculate forwardPS: marketCap / estimatedRevenueAvg
|
||||
item['forwardPS'] = round(item['marketCap'] / analyst_item['estimatedRevenueAvg'], 1)
|
||||
if item['eps'] > 0:
|
||||
cagr = ((analyst_item['estimatedEpsHigh']/item['eps'] ) -1)*100
|
||||
item['peg'] = round(item['priceEarningsRatio'] / cagr,2) if cagr > 0 else None
|
||||
break # Exit the loop once the desired item is found
|
||||
#item['peg'] = None
|
||||
#for analyst_item in res:
|
||||
if item['marketCap'] > 0 and res['estimatedRevenueAvg'] > 0: #res['date'] == next_year and
|
||||
# Calculate forwardPS: marketCap / estimatedRevenueAvg
|
||||
item['forwardPS'] = round(item['marketCap'] / res['estimatedRevenueAvg'], 1)
|
||||
if item['eps'] > 0:
|
||||
cagr = ((res['estimatedEpsAvg']/item['eps'] ) -1)*100
|
||||
#item['peg'] = round(item['priceEarningsRatio'] / cagr,2) if cagr > 0 else None
|
||||
except:
|
||||
item['forwardPS'] = None
|
||||
item['peg'] = None
|
||||
#item['peg'] = None
|
||||
|
||||
try:
|
||||
item['halalStocks'] = get_halal_compliant(item)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user