add more rules

This commit is contained in:
MuslemRahimi 2024-10-26 13:20:36 +02:00
parent 46e6c1c9f8
commit d678254da0
2 changed files with 47 additions and 3 deletions

View File

@ -495,6 +495,30 @@ data = {
}, },
"grossProfitGrowthYears": { "grossProfitGrowthYears": {
"text": "For how many consecutive fiscal years the company's gross profit has been growing.", "text": "For how many consecutive fiscal years the company's gross profit has been growing.",
},
"ebit": {
"text": "EBIT stands for Earnings Before Interest and Taxes and is a commonly used measure of earnings or profits. It is similar to operating income.",
'equation': 'EBIT = Net Income + Interest + Taxes',
},
"peg": {
"text": "The price/earnings to growth (PEG) ratio is calculated by dividing a company's PE ratio by its expected earnings growth next year.",
"equation": "PEG Ratio = PE Ratio / Expected Earnings Growth"
},
"evSales": {
"text": "The enterprise value to sales (EV/Sales) ratio is similar to the price-to-sales ratio, but the price is adjusted for the company's debt and cash levels.",
"equation": "EV/Sales Ratio = Enterprise Value / Revenue"
},
"evEarnings": {
"text": "The enterprise value to earnings (EV/Earnings) ratio measures valuation, but the price is adjusted for the company's levels of cash and debt.",
"equation": "EV/Earnings Ratio = Enterprise Value / Net Income"
},
"evEBITDA": {
"text": "The EV/EBITDA ratio measures a company's valuation relative to its EBITDA, or Earnings Before Interest, Taxes, Depreciation, and Amortization.",
"equation": "EV/EBITDA Ratio = Enterprise Value / EBITDA"
},
"evEBIT": {
"text": "The EV/EBIT is a valuation metric that measures a company's price relative to EBIT, or Earnings Before Interest and Taxes.",
"equation": "EV/EBIT Ratio = Enterprise Value / EBIT"
} }
} }

View File

@ -334,6 +334,11 @@ def get_financial_statements(item, symbol):
item['interestIncomeToCapitalization'] = round((item['interestIncome'] / item['marketCap']) * 100,1) item['interestIncomeToCapitalization'] = round((item['interestIncome'] / item['marketCap']) * 100,1)
except: except:
item['interestIncomeToCapitalization'] = None item['interestIncomeToCapitalization'] = None
try:
item['ebit'] = item['operatingIncome']
except:
item['ebit'] = None
return item return item
@ -511,9 +516,18 @@ async def get_stock_screener(con):
try: try:
with open(f"json/enterprise-values/{symbol}.json", 'r') as file: with open(f"json/enterprise-values/{symbol}.json", 'r') as file:
item['enterpriseValue'] = orjson.loads(file.read())[-1]['enterpriseValue'] ev = orjson.loads(file.read())[-1]['enterpriseValue']
item['enterpriseValue'] = ev
item['evSales'] = round(ev / item['revenue'],2)
item['evEarnings'] = round(ev / item['netIncome'],2)
item['evEBITDA'] = round(ev / item['ebitda'],2)
item['evEBIT'] = round(ev / item['ebit'],2)
except: except:
item['enterpriseValue'] = None item['enterpriseValue'] = None
item['evSales'] = None
item['evEarnings'] = None
item['evEBITDA'] = None
item['evEBIT'] = None
try: try:
with open(f"json/analyst/summary/{symbol}.json", 'r') as file: with open(f"json/analyst/summary/{symbol}.json", 'r') as file:
@ -644,14 +658,19 @@ async def get_stock_screener(con):
with open(f"json/analyst-estimate/{symbol}.json", 'r') as file: with open(f"json/analyst-estimate/{symbol}.json", 'r') as file:
res = orjson.loads(file.read()) res = orjson.loads(file.read())
item['forwardPS'] = None item['forwardPS'] = None
item['peg'] = None
for analyst_item in res: for analyst_item in res:
if analyst_item['date'] == next_year and item['marketCap'] > 0 and analyst_item['estimatedRevenueAvg'] > 0: if analyst_item['date'] == next_year and item['marketCap'] > 0 and analyst_item['estimatedRevenueAvg'] > 0:
# Calculate forwardPS: marketCap / estimatedRevenueAvg # Calculate forwardPS: marketCap / estimatedRevenueAvg
item['forwardPS'] = round(item['marketCap'] / analyst_item['estimatedRevenueAvg'], 1) 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 break # Exit the loop once the desired item is found
except: except:
item['forwardPS'] = None item['forwardPS'] = None
item['peg'] = None
try: try:
item['halalStocks'] = get_halal_compliant(item) item['halalStocks'] = get_halal_compliant(item)
except: except:
@ -1910,6 +1929,7 @@ async def save_json_files():
with open(f"json/stock-screener/data.json", 'w') as file: with open(f"json/stock-screener/data.json", 'w') as file:
ujson.dump(stock_screener_data, file) ujson.dump(stock_screener_data, file)
'''
earnings_list = await get_earnings_calendar(con,symbols) earnings_list = await get_earnings_calendar(con,symbols)
with open(f"json/earnings-calendar/calendar.json", 'w') as file: with open(f"json/earnings-calendar/calendar.json", 'w') as file:
ujson.dump(earnings_list, file) ujson.dump(earnings_list, file)
@ -1984,7 +2004,7 @@ async def save_json_files():
data = await get_magnificent_seven(con) data = await get_magnificent_seven(con)
with open(f"json/magnificent-seven/data.json", 'w') as file: with open(f"json/magnificent-seven/data.json", 'w') as file:
ujson.dump(data, file) ujson.dump(data, file)
'''
con.close() con.close()
etf_con.close() etf_con.close()