From d678254da0f4c5b0cc2d8bb949f7e29cad64ee2f Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sat, 26 Oct 2024 13:20:36 +0200 Subject: [PATCH] add more rules --- app/cron_info_text.py | 24 ++++++++++++++++++++++++ app/restart_json.py | 26 +++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/app/cron_info_text.py b/app/cron_info_text.py index f7c7004..fe3d2aa 100644 --- a/app/cron_info_text.py +++ b/app/cron_info_text.py @@ -495,6 +495,30 @@ data = { }, "grossProfitGrowthYears": { "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" } } diff --git a/app/restart_json.py b/app/restart_json.py index 92e878e..9545896 100755 --- a/app/restart_json.py +++ b/app/restart_json.py @@ -334,6 +334,11 @@ def get_financial_statements(item, symbol): item['interestIncomeToCapitalization'] = round((item['interestIncome'] / item['marketCap']) * 100,1) except: item['interestIncomeToCapitalization'] = None + + try: + item['ebit'] = item['operatingIncome'] + except: + item['ebit'] = None return item @@ -511,9 +516,18 @@ async def get_stock_screener(con): try: 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: item['enterpriseValue'] = None + item['evSales'] = None + item['evEarnings'] = None + item['evEBITDA'] = None + item['evEBIT'] = None try: 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: res = orjson.loads(file.read()) 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 except: item['forwardPS'] = None - + item['peg'] = None + try: item['halalStocks'] = get_halal_compliant(item) except: @@ -1910,6 +1929,7 @@ async def save_json_files(): with open(f"json/stock-screener/data.json", 'w') as file: ujson.dump(stock_screener_data, file) + ''' earnings_list = await get_earnings_calendar(con,symbols) with open(f"json/earnings-calendar/calendar.json", 'w') as file: ujson.dump(earnings_list, file) @@ -1984,7 +2004,7 @@ async def save_json_files(): data = await get_magnificent_seven(con) with open(f"json/magnificent-seven/data.json", 'w') as file: ujson.dump(data, file) - + ''' con.close() etf_con.close()