From f0b60d145e91d925c565a2199c4a22d2b42ee92f Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 1 Sep 2024 00:27:03 +0200 Subject: [PATCH] add more rules --- .../stock-screener/[strategyId]/+page.svelte | 144 ++++++++++++++++-- 1 file changed, 135 insertions(+), 9 deletions(-) diff --git a/src/routes/stock-screener/[strategyId]/+page.svelte b/src/routes/stock-screener/[strategyId]/+page.svelte index 8207d15e..92df1637 100644 --- a/src/routes/stock-screener/[strategyId]/+page.svelte +++ b/src/routes/stock-screener/[strategyId]/+page.svelte @@ -113,8 +113,12 @@ const getStockScreenerData = async (rules) => { quickRatio: (ruleOfList?.find(item => item.name === "quickRatio") || { condition: 'above' }).condition, debtEquityRatio: (ruleOfList?.find(item => item.name === "debtEquityRatio") || { condition: 'above' }).condition, debtRatio: (ruleOfList?.find(item => item.name === "debtRatio") || { condition: 'above' }).condition, - returnOnAssets: (ruleOfList?.find(item => item.name === "returnOnAssets") || { condition: 'above' }).condition, - returnOnEquity: (ruleOfList?.find(item => item.name === "returnOnEquity") || { condition: 'above' }).condition, + returnOnAssets: (ruleOfList?.find(item => item.name === "returnOnAssets") || { condition: 'above' }).condition, + returnOnEquity: (ruleOfList?.find(item => item.name === "returnOnEquity") || { condition: 'above' }).condition, + enterpriseValue: (ruleOfList?.find(item => item.name === "enterpriseValue") || { condition: 'above' }).condition, + freeCashFlowPerShare: (ruleOfList?.find(item => item.name === "freeCashFlowPerShare") || { condition: 'above' }).condition, + cashPerShare: (ruleOfList?.find(item => item.name === "cashPerShare") || { condition: 'above' }).condition, + priceToFreeCashFlowsRatio: (ruleOfList?.find(item => item.name === "priceToFreeCashFlowsRatio") || { condition: 'above' }).condition, }; @@ -183,6 +187,10 @@ const getStockScreenerData = async (rules) => { { rule: 'debtRatio', label: 'Debt Ratio',category: 'fund' }, { rule: 'returnOnAssets', label: 'Return on Assets',category: 'fund' }, { rule: 'returnOnEquity', label: 'Return on Equity',category: 'fund' }, + { rule: 'enterpriseValue', label: 'Enterprise Value',category: 'fund' }, + { rule: 'freeCashFlowPerShare', label: 'FCF / Share', category: 'fund' }, + { rule: 'cashPerShare', label: 'Cash / Share', category: 'fund' }, + { rule: 'priceToFreeCashFlowsRatio', label: 'Price / FCF', category: 'fund' }, ]; @@ -277,6 +285,10 @@ const getStockScreenerData = async (rules) => { let valueVaR = (ruleOfList?.find(item => item.name === "var") || { value: -10 }).value; let valueTrendAnalysis = (ruleOfList?.find(item => item.name === "trendAnalysis") || { value: 50 }).value; let valueFundamentalAnalysis = (ruleOfList?.find(item => item.name === "fundamentalAnalysis") || { value: 50 }).value; + let valueEnterpriseValue = (ruleOfList?.find(item => item.name === "enterpriseValue") || { value: 50 }).value; + let valueFCFShare = (ruleOfList?.find(item => item.name === "freeCashFlowPerShare") || { value: 1 }).value; + let valueCashShare = (ruleOfList?.find(item => item.name === "cashPerShare") || { value: 1 }).value; + let valuePriceFCF = (ruleOfList?.find(item => item.name === "priceToFreeCashFlowsRatio") || { value: 1 }).value; const ratingRecommendations = [ @@ -362,6 +374,10 @@ const valueMappings = { debtRatio: valueDebtRatio, returnOnAssets: valueReturnOnAssets, returnOnEquity: valueReturnOnEquity, + enterpriseValue: valueEnterpriseValue, + freeCashFlowPerShare: valueFCFShare, + cashPerShare: valueCashShare, + priceToFreeCashFlowsRatio: valuePriceFCF, }; const conditions = { @@ -417,7 +433,10 @@ const conditions = { quickRatio: ruleCondition.quickRatio, debtEquityRatio: ruleCondition.debtEquityRatio, debtRatio: ruleCondition.debtRatio, - + enterpriseValue: ruleCondition.enterpriseValue, + freeCashFlowPerShare: ruleCondition.freeCashFlowPerShare, + cashPerShare: ruleCondition.cashPerShare, + priceToFreeCashFlowsRatio: ruleCondition.priceToFreeCashFlowsRatio, }; @@ -667,6 +686,11 @@ $: { debtRatio: valueDebtRatio, returnOnAssets: valueReturnOnAssets, returnOnEquity: valueReturnOnEquity, + enterpriseValue: valueEnterpriseValue, + freeCashFlowPerShare: valueFCFShare, + cashPerShare: valueCashShare, + priceToFreeCashFlowsRatio: valuePriceFCF, + }; ruleToUpdate.value = valueMap[ruleToUpdate.name] ?? ruleToUpdate.value; @@ -686,7 +710,19 @@ $: { function filterStockScreenerData() { return stockScreenerData?.filter(item => { for (const rule of ruleOfList) { - if (rule.name === 'researchAndDevelopmentExpenses' || rule.name === 'operatingIncome' || rule.name === 'operatingExpenses' || rule.name === 'netIncome' || rule.name === 'revenue' || rule.name === 'marketCap' || rule.name === 'costAndExpenses' || rule.name === 'costOfRevenue' || rule.name === 'ebitda' || rule.name === 'grossProfit') + if ([ + 'researchAndDevelopmentExpenses', + 'operatingIncome', + 'operatingExpenses', + 'netIncome', + 'revenue', + 'marketCap', + 'enterpriseValue', + 'costAndExpenses', + 'costOfRevenue', + 'ebitda', + 'grossProfit' + ]?.includes(rule.name)) { if (rule.condition === "above" && item[rule.name] !== null && item[rule.name] <= rule.value * 10**(9)) { return false; @@ -947,7 +983,76 @@ $: charNumber = $screenWidth < 640 ? 20 : 40; {/if} - + {#if ruleName === 'freeCashFlowPerShare'} + +
+ FCF / Share {ruleCondition[ruleName]} {valueFCFShare} + + + + +
+ + +
+ +
+ + {/if} + + {#if ruleName === 'cashPerShare'} + +
+ Cash / Share {ruleCondition[ruleName]} {valueCashShare} + + + + +
+ + +
+ +
+ + {/if} + + {#if ruleName === 'priceToFreeCashFlowsRatio'} + +
+ Price / FCF {ruleCondition[ruleName]} {valuePriceFCF} + + + + +
+ + +
+ +
+ + {/if} + + {#if ruleName === 'revenue'}
@@ -971,7 +1076,6 @@ $: charNumber = $screenWidth < 640 ? 20 : 40;
{/if} - {#if ruleName === 'growthRevenue'} @@ -1471,9 +1575,32 @@ $: charNumber = $screenWidth < 640 ? 20 : 40; {/if} + + {#if ruleName === 'enterpriseValue'} + +
+ Enterprise Val {ruleCondition[ruleName]} ${valueEnterpriseValue} Bn + + + + +
+ + +
+ + +
+ + {/if} + - - {#if ruleName === 'marketCap'}
@@ -1497,7 +1624,6 @@ $: charNumber = $screenWidth < 640 ? 20 : 40;
{/if} - {#if ruleName === 'currentRatio'}