diff --git a/src/lib/components/RuleControl.svelte b/src/lib/components/RuleControl.svelte index 6e0a1fce..e0304648 100644 --- a/src/lib/components/RuleControl.svelte +++ b/src/lib/components/RuleControl.svelte @@ -10,6 +10,7 @@ export let unit = ''; export let condition; + console.log(condition) const dispatch = createEventDispatcher(); function changeRuleCondition(newCondition) { @@ -21,21 +22,97 @@ } + + + + +
+
+ {title?.replace('[%]','')} +
+
+ +
+ +
+
+
+ \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 499f96d1..884a1f22 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -18,7 +18,7 @@ //import DiscountBanner from '$lib/components/DiscountBanner.svelte'; import { beforeNavigate, afterNavigate } from '$app/navigation'; - import { onMount } from 'svelte'; + import { onMount, onDestroy } from 'svelte'; import { clearCache, showCookieConsent, newAvatar, userRegion, screenWidth, stockTicker, etfTicker, loginData, numberOfUnreadNotification, cachedPosts, currentPagePosition, clientSideCache, twitchStatus } from '$lib/store'; import { Button } from "$lib/components/shadcn/button/index.ts"; @@ -197,7 +197,9 @@ onMount(async () => { }) - +onDestroy( () => { + clearCache() +}) beforeNavigate(async () => { NProgress.start(); diff --git a/src/routes/stock-screener/[strategyId]/+page.svelte b/src/routes/stock-screener/[strategyId]/+page.svelte index fa1d91e8..3c7f25d6 100644 --- a/src/routes/stock-screener/[strategyId]/+page.svelte +++ b/src/routes/stock-screener/[strategyId]/+page.svelte @@ -14,7 +14,7 @@ $strategyId = data?.getStrategyId; let ruleOfList = data?.getStrategy?.rules ?? []; - + const title = data?.getStrategy?.title; let stockScreenerData = data?.getStockScreenerData?.filter(item => @@ -57,68 +57,68 @@ const getStockScreenerData = async (rules) => { let displayResults = []; let isSaved = false; let ruleCondition = { - avgVolume: (ruleOfList?.find(item => item.name === "avgVolume") || { condition: 'above' }).condition, - priceToBookRatio: (ruleOfList?.find(item => item.name === "priceToBookRati") || { condition: 'above' }).condition, - priceToSalesRatio: (ruleOfList?.find(item => item.name === "priceToSalesRatio") || { condition: 'above' }).condition, - rsi: (ruleOfList?.find(item => item.name === "rsi") || { condition: 'above' }).condition, - stochRSI: (ruleOfList?.find(item => item.name === "stochRSI") || { condition: 'above' }).condition, - mfi: (ruleOfList?.find(item => item.name === "mfi") || { condition: 'above' }).condition, - cci: (ruleOfList?.find(item => item.name === "cci") || { condition: 'above' }).condition, - atr: (ruleOfList?.find(item => item.name === "atr") || { condition: 'above' }).condition, - sma50: (ruleOfList?.find(item => item.name === "sma50") || { condition: 'above' }).condition, - sma200: (ruleOfList?.find(item => item.name === "sma200") || { condition: 'above' }).condition, - ema50: (ruleOfList?.find(item => item.name === "ema50") || { condition: 'above' }).condition, - ema200: (ruleOfList?.find(item => item.name === "ema200") || { condition: 'above' }).condition, - change1W: (ruleOfList?.find(item => item.name === "change1W") || { condition: 'above' }).condition, - change1M: (ruleOfList?.find(item => item.name === "change1M") || { condition: 'above' }).condition, - change3M: (ruleOfList?.find(item => item.name === "change3M") || { condition: 'above' }).condition, - change6M: (ruleOfList?.find(item => item.name === "change6M") || { condition: 'above' }).condition, - change1Y: (ruleOfList?.find(item => item.name === "change1Y") || { condition: 'above' }).condition, - change3Y: (ruleOfList?.find(item => item.name === "change3Y") || { condition: 'above' }).condition, - payoutRatio: (ruleOfList?.find(item => item.name === "payoutRatio") || { condition: 'above' }).condition, - annualDividend: (ruleOfList?.find(item => item.name === "annualDividend") || { condition: 'above' }).condition, - dividendYield: (ruleOfList?.find(item => item.name === "dividendYield") || { condition: 'above' }).condition, - dividendGrowth: (ruleOfList?.find(item => item.name === "dividendGrowth") || { condition: 'above' }).condition, - eps: (ruleOfList?.find(item => item.name === "eps") || { condition: 'above' }).condition, - growthEPS: (ruleOfList?.find(item => item.name === "growthEPS") || { condition: 'above' }).condition, - pe: (ruleOfList?.find(item => item.name === "pe") || { condition: 'above' }).condition, - forwardPE: (ruleOfList?.find(item => item.name === "forwardPE") || { condition: 'above' }).condition, - beta: (ruleOfList?.find(item => item.name === "beta") || { condition: 'above' }).condition, - ebitda: (ruleOfList?.find(item => item.name === "ebitda") || { condition: 'above' }).condition, - growthEBITDA: (ruleOfList?.find(item => item.name === "growthEBITDA") || { condition: 'above' }).condition, - revenue: (ruleOfList?.find(item => item.name === "revenue") || { condition: 'above' }).condition, - growthRevenue: (ruleOfList?.find(item => item.name === "growthRevenue") || { condition: 'above' }).condition, - costOfRevenue: (ruleOfList?.find(item => item.name === "costOfRevenue") || { condition: 'above' }).condition, - growthCostOfRevenue: (ruleOfList?.find(item => item.name === "growthCostOfRevenue") || { condition: 'above' }).condition, - costAndExpenses: (ruleOfList?.find(item => item.name === "costAndExpenses") || { condition: 'above' }).condition, - growthCostAndExpenses: (ruleOfList?.find(item => item.name === "growthCostAndExpenses") || { condition: 'above' }).condition, - netIncome: (ruleOfList?.find(item => item.name === "netIncome") || { condition: 'above' }).condition, - growthNetIncome: (ruleOfList?.find(item => item.name === "growthNetIncome") || { condition: 'above' }).condition, - researchAndDevelopmentExpenses: (ruleOfList?.find(item => item.name === "researchAndDevelopmentExpenses") || { condition: 'above' }).condition, - growthResearchAndDevelopmentExpenses: (ruleOfList?.find(item => item.name === "growthResearchAndDevelopmentExpenses") || { condition: 'above' }).condition, - grossProfit: (ruleOfList?.find(item => item.name === "grossProfit") || { condition: 'above' }).condition, - growthGrossProfit: (ruleOfList?.find(item => item.name === "growthGrossProfit") || { condition: 'above' }).condition, - interestIncome: (ruleOfList?.find(item => item.name === "interestIncome") || { condition: 'above' }).condition, - interestExpense: (ruleOfList?.find(item => item.name === "interestExpense") || { condition: 'above' }).condition, - growthInterestExpense: (ruleOfList?.find(item => item.name === "growthInterestExpense") || { condition: 'above' }).condition, - operatingExpenses: (ruleOfList?.find(item => item.name === "operatingExpense") || { condition: 'above' }).condition, - growthOperatingExpenses: (ruleOfList?.find(item => item.name === "growthOperatingExpense") || { condition: 'above' }).condition, - operatingIncome: (ruleOfList?.find(item => item.name === "operatingIncome") || { condition: 'above' }).condition, - growthOperatingIncome: (ruleOfList?.find(item => item.name === "growthOperatingIncome") || { condition: 'above' }).condition, - marketCap: (ruleOfList?.find(item => item.name === "marketCap") || { condition: 'above' }).condition, - var: (ruleOfList?.find(item => item.name === "var") || { condition: 'above' }).condition, - trendAnalysis: (ruleOfList?.find(item => item.name === "trendAnalysis") || { condition: 'above' }).condition, - fundamentalAnalysis: (ruleOfList?.find(item => item.name === "fundamentalAnalysis") || { condition: 'above' }).condition, - currentRatio: (ruleOfList?.find(item => item.name === "currentRatio") || { condition: 'above' }).condition, - 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, - 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, + avgVolume: (ruleOfList?.find(item => item.name === "avgVolume") || { condition: 'over' }).condition, + priceToBookRatio: (ruleOfList?.find(item => item.name === "priceToBookRati") || { condition: 'over' }).condition, + priceToSalesRatio: (ruleOfList?.find(item => item.name === "priceToSalesRatio") || { condition: 'over' }).condition, + rsi: (ruleOfList?.find(item => item.name === "rsi") || { condition: 'over' }).condition, + stochRSI: (ruleOfList?.find(item => item.name === "stochRSI") || { condition: 'over' }).condition, + mfi: (ruleOfList?.find(item => item.name === "mfi") || { condition: 'over' }).condition, + cci: (ruleOfList?.find(item => item.name === "cci") || { condition: 'over' }).condition, + atr: (ruleOfList?.find(item => item.name === "atr") || { condition: 'over' }).condition, + sma50: (ruleOfList?.find(item => item.name === "sma50") || { condition: 'over' }).condition, + sma200: (ruleOfList?.find(item => item.name === "sma200") || { condition: 'over' }).condition, + ema50: (ruleOfList?.find(item => item.name === "ema50") || { condition: 'over' }).condition, + ema200: (ruleOfList?.find(item => item.name === "ema200") || { condition: 'over' }).condition, + change1W: (ruleOfList?.find(item => item.name === "change1W") || { condition: 'over' }).condition, + change1M: (ruleOfList?.find(item => item.name === "change1M") || { condition: 'over' }).condition, + change3M: (ruleOfList?.find(item => item.name === "change3M") || { condition: 'over' }).condition, + change6M: (ruleOfList?.find(item => item.name === "change6M") || { condition: 'over' }).condition, + change1Y: (ruleOfList?.find(item => item.name === "change1Y") || { condition: 'over' }).condition, + change3Y: (ruleOfList?.find(item => item.name === "change3Y") || { condition: 'over' }).condition, + payoutRatio: (ruleOfList?.find(item => item.name === "payoutRatio") || { condition: 'over' }).condition, + annualDividend: (ruleOfList?.find(item => item.name === "annualDividend") || { condition: 'over' }).condition, + dividendYield: (ruleOfList?.find(item => item.name === "dividendYield") || { condition: 'over' }).condition, + dividendGrowth: (ruleOfList?.find(item => item.name === "dividendGrowth") || { condition: 'over' }).condition, + eps: (ruleOfList?.find(item => item.name === "eps") || { condition: 'over' }).condition, + growthEPS: (ruleOfList?.find(item => item.name === "growthEPS") || { condition: 'over' }).condition, + pe: (ruleOfList?.find(item => item.name === "pe") || { condition: 'over' }).condition, + forwardPE: (ruleOfList?.find(item => item.name === "forwardPE") || { condition: 'over' }).condition, + beta: (ruleOfList?.find(item => item.name === "beta") || { condition: 'over' }).condition, + ebitda: (ruleOfList?.find(item => item.name === "ebitda") || { condition: 'over' }).condition, + growthEBITDA: (ruleOfList?.find(item => item.name === "growthEBITDA") || { condition: 'over' }).condition, + revenue: (ruleOfList?.find(item => item.name === "revenue") || { condition: 'over' }).condition, + growthRevenue: (ruleOfList?.find(item => item.name === "growthRevenue") || { condition: 'over' }).condition, + costOfRevenue: (ruleOfList?.find(item => item.name === "costOfRevenue") || { condition: 'over' }).condition, + growthCostOfRevenue: (ruleOfList?.find(item => item.name === "growthCostOfRevenue") || { condition: 'over' }).condition, + costAndExpenses: (ruleOfList?.find(item => item.name === "costAndExpenses") || { condition: 'over' }).condition, + growthCostAndExpenses: (ruleOfList?.find(item => item.name === "growthCostAndExpenses") || { condition: 'over' }).condition, + netIncome: (ruleOfList?.find(item => item.name === "netIncome") || { condition: 'over' }).condition, + growthNetIncome: (ruleOfList?.find(item => item.name === "growthNetIncome") || { condition: 'over' }).condition, + researchAndDevelopmentExpenses: (ruleOfList?.find(item => item.name === "researchAndDevelopmentExpenses") || { condition: 'over' }).condition, + growthResearchAndDevelopmentExpenses: (ruleOfList?.find(item => item.name === "growthResearchAndDevelopmentExpenses") || { condition: 'over' }).condition, + grossProfit: (ruleOfList?.find(item => item.name === "grossProfit") || { condition: 'over' }).condition, + growthGrossProfit: (ruleOfList?.find(item => item.name === "growthGrossProfit") || { condition: 'over' }).condition, + interestIncome: (ruleOfList?.find(item => item.name === "interestIncome") || { condition: 'over' }).condition, + interestExpense: (ruleOfList?.find(item => item.name === "interestExpense") || { condition: 'over' }).condition, + growthInterestExpense: (ruleOfList?.find(item => item.name === "growthInterestExpense") || { condition: 'over' }).condition, + operatingExpenses: (ruleOfList?.find(item => item.name === "operatingExpense") || { condition: 'over' }).condition, + growthOperatingExpenses: (ruleOfList?.find(item => item.name === "growthOperatingExpense") || { condition: 'over' }).condition, + operatingIncome: (ruleOfList?.find(item => item.name === "operatingIncome") || { condition: 'over' }).condition, + growthOperatingIncome: (ruleOfList?.find(item => item.name === "growthOperatingIncome") || { condition: 'over' }).condition, + marketCap: (ruleOfList?.find(item => item.name === "marketCap") || { condition: 'over' }).condition, + var: (ruleOfList?.find(item => item.name === "var") || { condition: 'over' }).condition, + trendAnalysis: (ruleOfList?.find(item => item.name === "trendAnalysis") || { condition: 'over' }).condition, + fundamentalAnalysis: (ruleOfList?.find(item => item.name === "fundamentalAnalysis") || { condition: 'over' }).condition, + currentRatio: (ruleOfList?.find(item => item.name === "currentRatio") || { condition: 'over' }).condition, + quickRatio: (ruleOfList?.find(item => item.name === "quickRatio") || { condition: 'over' }).condition, + debtEquityRatio: (ruleOfList?.find(item => item.name === "debtEquityRatio") || { condition: 'over' }).condition, + debtRatio: (ruleOfList?.find(item => item.name === "debtRatio") || { condition: 'over' }).condition, + returnOnAssets: (ruleOfList?.find(item => item.name === "returnOnAssets") || { condition: 'over' }).condition, + returnOnEquity: (ruleOfList?.find(item => item.name === "returnOnEquity") || { condition: 'over' }).condition, + enterpriseValue: (ruleOfList?.find(item => item.name === "enterpriseValue") || { condition: 'over' }).condition, + freeCashFlowPerShare: (ruleOfList?.find(item => item.name === "freeCashFlowPerShare") || { condition: 'over' }).condition, + cashPerShare: (ruleOfList?.find(item => item.name === "cashPerShare") || { condition: 'over' }).condition, + priceToFreeCashFlowsRatio: (ruleOfList?.find(item => item.name === "priceToFreeCashFlowsRatio") || { condition: 'over' }).condition, }; @@ -144,7 +144,7 @@ const getStockScreenerData = async (rules) => { { rule: 'change6M', label: 'Price Change 6M [%]', max: "200", min:"-100", step:"2", unit: '%',category: 'ta' }, { rule: 'change1Y', label: 'Price Change 1Y [%]', max: "200", min:"-100", step:"2", unit: '%',category: 'ta' }, { rule: 'change3Y', label: 'Price Change 3Y [%]', max: "200", min:"-100", step:"2", unit: '%',category: 'ta' }, - { rule: 'marketCap', label: 'Market Capitalization', max: "800", min:"10", step:"10", unit: 'Bn', category: 'fund'}, + { rule: 'marketCap', label: 'Market Cap', max: "800", min:"10", step:"10", unit: 'Bn', category: 'fund'}, { rule: 'revenue', label: 'Revenue', max: "800", min:"-100", step:"10", unit: 'Bn', category: 'fund' }, { rule: 'growthRevenue', label: 'Revenue Growth [%]', max: "200", min:"-100", step:"2", unit: '%', category: 'fund' }, { rule: 'costOfRevenue', label: 'Cost of Revenue', max: "800", min:"-100", step:"10", unit: 'Bn', category: 'fund' }, @@ -729,54 +729,54 @@ function filterStockScreenerData() { 'grossProfit' ]?.includes(rule.name)) { - if (rule.condition === "above" && item[rule.name] !== null && item[rule.name] <= rule.value * 10**(9)) { + if (rule.condition === "over" && item[rule.name] !== null && item[rule.name] <= rule.value * 10**(9)) { return false; } - else if (rule.condition === "below" && item[rule.name] !== null && item[rule.name] > rule.value * 10**(9)) { + else if (rule.condition === "under" && item[rule.name] !== null && item[rule.name] > rule.value * 10**(9)) { return false; } } else if (rule.name === 'interestIncome' || rule.name === 'interestExpense') { - if (rule.condition === "above" && item[rule.name] !== null && item[rule.name] <= rule.value * 10**(6)) { + if (rule.condition === "over" && item[rule.name] !== null && item[rule.name] <= rule.value * 10**(6)) { return false; } - else if (rule.condition === "below" && item[rule.name] !== null && item[rule.name] > rule.value * 10**(6)) { + else if (rule.condition === "under" && item[rule.name] !== null && item[rule.name] > rule.value * 10**(6)) { return false; } } else if (rule.name === 'avgVolume') { - if (rule.condition === "above" && item[rule.name] <= rule.value * 10**(6)) { + if (rule.condition === "over" && item[rule.name] <= rule.value * 10**(6)) { return false; } - else if (rule.condition === "below" && item[rule.name] > rule.value * 10**(6)) { + else if (rule.condition === "under" && item[rule.name] > rule.value * 10**(6)) { return false; } } else if (rule.name === 'trendAnalysis') { - if (rule.condition === "above" && item[rule.name]?.accuracy <= rule.value ) { + if (rule.condition === "over" && item[rule.name]?.accuracy <= rule.value ) { return false; } - else if (rule.condition === "below" && item[rule.name]?.accuracy > rule.value ) { + else if (rule.condition === "under" && item[rule.name]?.accuracy > rule.value ) { return false; } } else if (rule.name === 'fundamentalAnalysis') { - if (rule.condition === "above" && item[rule.name]?.accuracy <= rule.value ) { + if (rule.condition === "over" && item[rule.name]?.accuracy <= rule.value ) { return false; } - else if (rule.condition === "below" && item[rule.name]?.accuracy > rule.value ) { + else if (rule.condition === "under" && item[rule.name]?.accuracy > rule.value ) { return false; } } else { - if (rule.condition === "above" && item[rule.name] !== null && item[rule.name] <= rule.value) { + if (rule.condition === "over" && item[rule.name] !== null && item[rule.name] <= rule.value) { return false; } - else if (rule.condition === "below" && item[rule.name] !== null && item[rule.name] > rule.value) { + else if (rule.condition === "under" && item[rule.name] !== null && item[rule.name] > rule.value) { return false; } } @@ -856,7 +856,6 @@ $: isSaved = !ruleOfList; $: charNumber = $screenWidth < 640 ? 20 : 40; - function handleChangeCondition(event) { ruleCondition[event.detail.rule] = event.detail.condition; } @@ -1089,11 +1088,11 @@ function handleChangeValue(event) { -
+
-