Skip to content

Commit

Permalink
update peg ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
MuslemRahimi committed Feb 15, 2025
1 parent 82360fa commit 7cf63dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
8 changes: 5 additions & 3 deletions app/cron_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
23 changes: 11 additions & 12 deletions app/restart_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,21 +968,20 @@ 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)
except:
Expand Down

0 comments on commit 7cf63dd

Please sign in to comment.