From be62e9f6d6f5d50c77f1125a784c57dec5b75269 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 25 Oct 2024 00:00:14 +0200 Subject: [PATCH] refactor code --- src/routes/analysts/[slug]/+page.svelte | 835 ++++++++++-------- src/routes/etf/etf-providers/+layout.svelte | 341 +++---- src/routes/etf/etf-providers/+page.svelte | 207 ++--- .../etf/etf-providers/[slug]/+page.svelte | 304 ++++--- src/routes/etf/new-launches/+page.svelte | 473 +++++----- src/routes/market-mover/+page.svelte | 25 +- src/routes/market-news/+layout.svelte | 368 ++++---- src/routes/politicians/flow-data/+page.svelte | 617 +------------ src/routes/watchlist/+layout.svelte | 5 +- 9 files changed, 1395 insertions(+), 1780 deletions(-) diff --git a/src/routes/analysts/[slug]/+page.svelte b/src/routes/analysts/[slug]/+page.svelte index bd8afc45..95d12625 100644 --- a/src/routes/analysts/[slug]/+page.svelte +++ b/src/routes/analysts/[slug]/+page.svelte @@ -1,396 +1,509 @@ - -window.addEventListener('scroll', handleScroll); - return () => { - window.removeEventListener('scroll', handleScroll); - }; -}) - - -$: charNumber = $screenWidth < 640 ? 20 : 40; - - - - - - - - {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} Top Wall Street Stock Analysts · stocknear - - + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} Top + Wall Street Stock Analysts · stocknear + + - - - - - - - - - - - + + + + + + + + + + +
+ +
+
+
+
+
+
+ +
+
{analystName}
+
+ Analyst at {companyName} +
+
+ {#each Array.from({ length: 5 }) as _, i} + {#if i < Math.floor(analystScore)} + + {:else} + + {/if} + {/each} -
- - - -
- -
-
+ + ({analystScore}) + +
+
+
+
+
+
+
+
# {rank}
+
+ Out of {numOfAnalysts} analysts +
+
-
- - -
+
+
+ {totalRatings} +
+
Total Ratings
+
-
- -
-
{analystName}
-
Analyst at {companyName}
-
- {#each Array.from({ length: 5 }) as _, i} - {#if i < Math.floor(analystScore)} - - {:else} - - {/if} - {/each} - - - ({analystScore}) - +
+
+ {successRate >= 0 ? "+" : ""}{successRate?.toFixed(2)}% +
+
Success Rate
+
+ +
+
+ {avgReturn >= 0 ? "+" : ""}{avgReturn?.toFixed(2)}% +
+
Avg Return
+
+
+
+
+ +
+
+
+ + Main Sectors: + + +
+ {#each data?.getAnalystStats?.mainSectors as sector} + + {sector} + + {/each} +
+
+
+
+ + + {numOfStocks} Stocks + + +
+
+ + + + + + + + + + + + {#each stockList as item, index} + + - - - - - - - - {numOfStocks} Stocks - - -
- -
-
+ Stock + + Action + + Price Target + + Date +
+ {#if index >= 5 && data?.user?.tier !== "Pro"} + + + XXXX + + +
+ XXXXXXXXXXXXXXXX
- - -
-
- -
- - -
-
# {rank}
-
Out of {numOfAnalysts} analysts
-
- -
-
{totalRatings}
-
Total Ratings
-
- -
-
{successRate >= 0 ? '+' : ''}{successRate?.toFixed(2)}%
-
Success Rate
-
- -
-
{avgReturn >= 0 ? '+' : ''}{avgReturn?.toFixed(2)}%
-
Avg Return
-
- - -
- - -
-
+
+ + + + -
-
- + {:else} +
+ + {item?.ticker} + + + {item?.name?.length > charNumber + ? item?.name?.slice(0, charNumber) + "..." + : item?.name} + +
+ {/if} +
- - - - - - - - - - - {#each stockList as item, index} - - - - - - - - - - - - - - - {/each} - -
- Stock - - Action - - Price Target - - Date -
- {#if index >= 5 && data?.user?.tier !== 'Pro'} - - - XXXX - - -
- XXXXXXXXXXXXXXXX -
- -
- - - - - - - Upgrade - -
-
- {:else} -
- - {item?.ticker} - - - {item?.name?.length > charNumber - ? item?.name?.slice(0, charNumber) + "..." - : item?.name} - -
- {/if} -
-
- {item?.action_company}: - - {item?.rating_current} - -
-
-
- {#if Math?.ceil(item?.adjusted_pt_prior) !== 0} - ${Math?.ceil(item?.adjusted_pt_prior)} - - ${Math?.ceil(item?.adjusted_pt_current)} - {:else if Math?.ceil(item?.adjusted_pt_current) !== 0} - ${Math?.ceil(item?.adjusted_pt_current)} - {/if} -
-
- {new Date(item?.date).toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} -
-
- - -
- - - - -
- -
- - - + + + + {new Date(item?.date).toLocaleString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + daySuffix: "2-digit", + })} + + + {/each} + + +
+
-
- - +
+ +
- - - -
- - \ No newline at end of file + + + diff --git a/src/routes/etf/etf-providers/+layout.svelte b/src/routes/etf/etf-providers/+layout.svelte index a730dd8e..10def2d9 100644 --- a/src/routes/etf/etf-providers/+layout.svelte +++ b/src/routes/etf/etf-providers/+layout.svelte @@ -1,192 +1,209 @@ - - - - {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} Largest ETF Providers by Assets Under Management · stocknear + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} Largest + ETF Providers by Assets Under Management · stocknear - + - - - + + + - - - + + + - - - -
- - - - - -
- -
-
+
+ +
+
+
- -
+
+ +
+
+

+ ETF Providers +

+
- -
-
-

- ETF Providers -

-
+ +
+ - + + - - - - - -
- - -
- - - -
- - -
- - - -
- - - - -
- - -
- - -
-
- {/if} -
goto('/analysts')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> -
-
-

- Wallstreet Analyst -

- +
+
+ +
- - Get the latest top Wall Street analyst ratings. - -
-
+ -
goto('/politicians')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> -
- - - -
-
- - -
- - -
diff --git a/src/routes/etf/etf-providers/+page.svelte b/src/routes/etf/etf-providers/+page.svelte index 43576851..6a153adf 100644 --- a/src/routes/etf/etf-providers/+page.svelte +++ b/src/routes/etf/etf-providers/+page.svelte @@ -1,121 +1,130 @@ - - - - {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} Largest ETF Providers by Assets Under Management · stocknear + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} Largest + ETF Providers by Assets Under Management · stocknear - + - - - + + + - - - + + + - - +
+
+ -
- - -
- - - Every Exchange-Traded Fund (ETF) is managed by a specific company. Below is a list of companies offering actively traded ETFs on the U.S. stock market. - -
- - -
+ Every Exchange-Traded Fund (ETF) is managed by a specific company. Below is + a list of companies offering actively traded ETFs on the U.S. stock market. +
- - - -
- - - - - - - - - - - - - - - {#each etfProviderList as item,index} - - - + +
+ +
+
Provider NameTotal AssetsFundsAvg. CostAvg. Holdings
+ + + + + + + + + + + {#each etfProviderList as item, index} + + + - - - - - - - - + - - - - - - - - - {/each} - -
Provider NameTotal AssetsFundsAvg. CostAvg. Holdings
+ + {formatETFName(item?.etfProvider)} + + - - {formatETFName(item?.etfProvider)} - - - {abbreviateNumber(item?.totalAssets, true)} - - {item?.funds} - - {item?.avgExpenseRatio}% - + {abbreviateNumber(item?.totalAssets)} + - {item?.avgHoldings} -
- - + + {item?.funds} + -
+ + {item?.avgExpenseRatio}% + - -
- - - -
- - - - \ No newline at end of file + + {item?.avgHoldings} + + + {/each} + + + + + diff --git a/src/routes/etf/etf-providers/[slug]/+page.svelte b/src/routes/etf/etf-providers/[slug]/+page.svelte index 09e1deb1..af5b7820 100644 --- a/src/routes/etf/etf-providers/[slug]/+page.svelte +++ b/src/routes/etf/etf-providers/[slug]/+page.svelte @@ -1,173 +1,203 @@ - - - {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} {etfProviderData?.length} {etfProviderName} ETFs - A Complete List · stocknear + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} + {etfProviderData?.length} + {etfProviderName} ETFs - A Complete List · stocknear - + - + - + - - + + - -
- + {#if rawData?.length !== 0} +
+ - {#if rawData?.length !== 0} -
- - - {etfProviderName} has {rawData?.length} ETFs listed with a total of {abbreviateNumber(totalAssets,true)} - in assets under management. - The funds have an average expense ratio of {avgExpenseRatio?.toFixed(2)}%. - -
- {/if} + {etfProviderName} has {rawData?.length} ETFs listed with a total of {abbreviateNumber( + totalAssets, + true, + )} + in assets under management. The funds have an average expense ratio of {avgExpenseRatio?.toFixed( + 2, + )}%. +
+ {/if} -
- -
-
Listed Funds
-
{rawData?.length}
-
- -
-
Total Assets
-
{abbreviateNumber(totalAssets,true)}
-
- -
-
Average Cost
-
{avgExpenseRatio?.toFixed(2)}%
-
- -
- - {#if rawData?.length !== 0} - - -
- -
- - - - - - - - - - - - - {#each etfProviderData as item,index} - - - - - - - - - - - - - - - - - - - - - {/each} - -
SymbolFund NameTotal AssetsHoldingsExpense Ratio
- - {item?.symbol} - - - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} - - {abbreviateNumber(item?.totalAssets, true)} - - {item?.numberOfHoldings} - - {item?.expenseRatio}% -
- +
+
+
+ Listed Funds +
+
+ {rawData?.length} +
+
-
+
+
+ Total Assets +
+
+ {abbreviateNumber(totalAssets)} +
+
-
+
+
+ Average Cost +
+
+ {avgExpenseRatio?.toFixed(2)}% +
+
+
- {:else} -
- No data Available -
- {/if} - + {#if rawData?.length !== 0} + +
+ +
+ + + + + + + + + + + + {#each etfProviderData as item} + + + - + + + + + + + + + {/each} + +
SymbolFund NameTotal AssetsHoldingsExpense Ratio
+ + {item?.symbol} + + + {item?.name?.length > charNumber + ? item?.name?.slice(0, charNumber) + "..." + : item?.name} + + {abbreviateNumber(item?.totalAssets)} + + {item?.numberOfHoldings} + + {item?.expenseRatio}% +
+
+
+ {:else} +
+ No data Available +
+ {/if}
- - - - \ No newline at end of file diff --git a/src/routes/etf/new-launches/+page.svelte b/src/routes/etf/new-launches/+page.svelte index 23d6599b..53198955 100644 --- a/src/routes/etf/new-launches/+page.svelte +++ b/src/routes/etf/new-launches/+page.svelte @@ -1,71 +1,84 @@ - - - + - - - - {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} 100 Newest ETFs · stocknear - - + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ""} 100 + Newest ETFs · stocknear + + - - - - - + + + + + - - - - - + + + + + - -
- - -
+
+ -
-
- - -
- -
-
- - -
-
-

- New ETFs -

-
+
+
+
+
+
+
+ +
+
+

+ New ETFs +

+
- - +
+ + + + +
+
+ +
+ +
+
+ + {etfData?.length} ETFs + +
+ +
+ +
+ + + + + + + + + + + + {#each etfData as item, index} + + + + + + + + + + + + {/each} + +
InceptionSymbolFund NameHoldingsTotal Assets
+ {new Date(item?.inceptionDate)?.toLocaleString( + "en-US", + { + month: "short", + day: "numeric", + year: "numeric", + daySuffix: "2-digit", + }, + )} + + + {item?.symbol} + + + {item?.name?.length > charNumber + ? item?.name?.slice(0, charNumber) + "..." + : item?.name} + + {item?.numberOfHoldings} + + {item?.totalAssets !== 0 && item?.totalAssets !== null + ? abbreviateNumber(item?.totalAssets, true) + : "-"} +
+
+
+
+
+ +
- - - - - -
- - - - -
- - - -
- - - -
- -
- - {etfData?.length} ETFs - -
- -
- -
- - - - - - - - - - - - {#each etfData as item,index} - goto("/etf/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - - - - - - - - - - - - - {/each} - - - -
InceptionSymbolFund NameHoldingsTotal Assets
- {new Date(item?.inceptionDate)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} - - {item?.symbol} - - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + '...' : item?.name} - - {item?.numberOfHoldings} - - {(item?.totalAssets !== 0 && item?.totalAssets !== null) ? abbreviateNumber(item?.totalAssets,true) : '-'} -
- - -
- - - - -
-
- - -
- - -
- - \ No newline at end of file diff --git a/src/routes/market-mover/+page.svelte b/src/routes/market-mover/+page.svelte index d1a7db8d..842f187e 100644 --- a/src/routes/market-mover/+page.svelte +++ b/src/routes/market-mover/+page.svelte @@ -1,5 +1,4 @@ @@ -43,179 +34,188 @@ let activeIdx = 0; - - - -
- +
- +
- -
-
- - -
- -
-
- - -
-
-

- Market News -

-
- - - - - -
- - - - - +
+
+
+
+
+ +
+
+

+ Market News +

- - - - + +
- + + +
- -
-
goto('/dividends-calendar')} class="w-full bg-[#141417] duration-100 ease-out sm:hover:text-white text-gray-400 sm:hover:border-gray-700 border border-gray-800 rounded-lg h-fit pb-4 mt-4 cursor-pointer"> -
-
-

- Dividend Calendar 💸 -

- -
- - Stay updated on upcoming Dividends in the stock market. - -
+
+ {#each tabs as item, i} + + {#if activeIdx === i} +
+ {/if} + + {item.title} + +
+ {/each} +
+ +
+ + + + +
+ + - + +
- -
- - -
- - - - \ No newline at end of file diff --git a/src/routes/politicians/flow-data/+page.svelte b/src/routes/politicians/flow-data/+page.svelte index 10440440..9878ecb4 100644 --- a/src/routes/politicians/flow-data/+page.svelte +++ b/src/routes/politicians/flow-data/+page.svelte @@ -665,7 +665,7 @@ >

- Pro Subscription + Pro Subscription 🔥

@@ -685,12 +685,12 @@ >

- Wallstreet Analyst + Top Analyst 📊

- Get the latest top Wall Street analyst ratings. + Get the latest top Wall Street analyst ratings @@ -704,7 +704,7 @@ >

- Congress Trading + Congress Trading 🇺🇸

@@ -718,612 +718,3 @@
- - - - - - - - - - - - - - - - - - - - -{#if $screenWidth >= 640} - - - - - - - - - -{:else} -
- -
-
- - -
-
-
- -
-

- Filter List -

-
- - -
- -
-
-

- Political Party -

-
    -
  • - -
  • -
  • - -
  • -
-
- -
-
    -
  • - -
  • - -
-
-
- - - -
-
-

- Transaction Type -

-
    -
  • - -
  • -
-
- -
-
    -
  • - -
  • - -
-
-
- - - - - - -
-
-
-
-
-
-
-{/if} - - diff --git a/src/routes/watchlist/+layout.svelte b/src/routes/watchlist/+layout.svelte index 569ba3cc..a8140420 100644 --- a/src/routes/watchlist/+layout.svelte +++ b/src/routes/watchlist/+layout.svelte @@ -18,9 +18,11 @@ const tabs = [ { title: "Stocks", + path: "/watchlist/stocks", }, { title: "Options", + path: "/watchlist/options", }, ]; @@ -124,8 +126,7 @@ > {#each tabs as item, i} handleMode(i)} + href={item?.path} class="group relative z-[1] rounded-full px-6 py-1 {activeIdx === i ? 'z-0'