diff --git a/src/routes/stocks/[tickerID]/stats/+layout.svelte b/src/routes/stocks/[tickerID]/stats/+layout.svelte index 3d03d230..6c49bc91 100644 --- a/src/routes/stocks/[tickerID]/stats/+layout.svelte +++ b/src/routes/stocks/[tickerID]/stats/+layout.svelte @@ -10,6 +10,7 @@ let displaySubSection = 'fundamental'; if (displaySubSection) { const parts = $page?.url?.pathname.split('/'); const sectionMap = { + 'market-cap': 'market-cap', 'employees': 'employees', 'income': 'income', 'balance-sheet': 'balance-sheet', @@ -27,6 +28,7 @@ if (displaySubSection) { function changeSubSection(state) { const subSectionMap = { + 'market-cap': '/stats/market-cap', 'employees': '/stats/employees', 'income': '/stats/income', 'balance-sheet': '/stats/balance-sheet', @@ -61,6 +63,12 @@ function changeSubSection(state) {
+
  • + (changeSubSection('market-cap'))} class="whitespace-nowrap px-2 text-xs sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySubSection === 'market-cap' ? 'text-white ' : 'bg-[#09090B]'}" > + Market Cap + +
    +
  • (changeSubSection('employees'))} class="px-2 text-xs sm:text-[1rem] font-medium text-gray-400 sm:hover:text-white {displaySubSection === 'employees' ? 'text-white ' : 'bg-[#09090B]'}" > Employees diff --git a/src/routes/stocks/[tickerID]/stats/employees/+page.svelte b/src/routes/stocks/[tickerID]/stats/employees/+page.svelte index f81081f8..b6804c98 100644 --- a/src/routes/stocks/[tickerID]/stats/employees/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/employees/+page.svelte @@ -313,16 +313,17 @@ optionsGrowth = plotGrowth(); -
    -
    -
    +
    +
    +

    Employees

    - -
    + + +
    {#if employeeHistory?.length !== 0 && !dateDistance} @@ -352,46 +353,34 @@ optionsGrowth = plotGrowth();
    -
    - -
    -
    - - Total Employees - -
    - - - {abbreviateNumber(employees)} - +
    +
    + +
    + {abbreviateNumber(employees)} +
    - - - -
    -
    - - Change (1Y) - -
    - - {#if dateDistance} - n/a - {:else} - {abbreviateNumber(changeRate)} - {/if} - +
    + + +
    + {#if dateDistance} + n/a + {:else} + {abbreviateNumber(changeRate)} + {/if} +
    - - - -
    -
    - - Growth (1Y) - -
    - +
    + + +
    {#if growthRate >= 0} @@ -407,12 +396,14 @@ optionsGrowth = plotGrowth(); n/a {/if} - -
    - +
    +
    +
    - + + + diff --git a/src/routes/stocks/[tickerID]/stats/market-cap/+page.svelte b/src/routes/stocks/[tickerID]/stats/market-cap/+page.svelte new file mode 100644 index 00000000..b6317f9e --- /dev/null +++ b/src/routes/stocks/[tickerID]/stats/market-cap/+page.svelte @@ -0,0 +1,449 @@ + + + + + + + + + {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} {$displayCompanyName} ({$stockTicker}) Market Cap & Net Worth · stocknear + + + + + + + + + + + +
    +
    +
    + + {#if isLoaded} +
    +
    +
    +

    + Market Cap +

    +
    + + +
    +
    + + {$displayCompanyName} has a market cap or net worth of {abbreviateNumber(rawData?.at(-1)?.marketCap,true)} as of {new Date(rawData?.at(-1)?.date ?? null)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })}. Its market cap has {changePercentageYearAgo > 0 ? 'increased' : changePercentageYearAgo < 0 ? 'decreased' : 'unchanged'} by {abbreviateNumber(changePercentageYearAgo?.toFixed(2))}% in one year. +
    + + +
    +
    + +
    +
    + +
    + +
    + + +

    + Market Cap History +

    + + +
      +
    • + +
    • +
    • + {#if data?.user?.tier === 'Pro'} + + {:else} + + Quarterly + + + {/if} + +
    • +
    + +
    + + + + + + + + + + {#each tableList as item, index} + + + + + + + + + + + {/each} + + +
    DateMarket Cap% Change
    + {item?.date} + + {abbreviateNumber(item?.marketCap)} + + {#if index+1-tableList?.length === 0} + - + {:else} + {#if (item?.marketCap- tableList[index+1]?.marketCap) > 0} + + +{(((item?.marketCap-tableList[index+1]?.marketCap) / item?.marketCap) * 100 )?.toFixed(2)}% + + {:else if (item?.marketCap - tableList[index+1]?.marketCap ) < 0} + + -{(Math?.abs((tableList[index+1]?.marketCap - item?.marketCap) / item?.marketCap) * 100 )?.toFixed(2)}% + + {:else} + - + {/if} + {/if} +
    + + +
    + + + + +
    + +
    +
    + {:else} +
    +
    + +
    +
    + {/if} +
    +
    +
    + + + + + + + + + + + \ No newline at end of file diff --git a/src/routes/stocks/[tickerID]/stats/market-cap/+page.ts b/src/routes/stocks/[tickerID]/stats/market-cap/+page.ts new file mode 100644 index 00000000..c08d7061 --- /dev/null +++ b/src/routes/stocks/[tickerID]/stats/market-cap/+page.ts @@ -0,0 +1,41 @@ +import { getCache, setCache } from '$lib/store'; + + +export const load = async ({ parent, params }) => { + const getHistoricalMarketCap = async () => { + let output; + + // Get cached data for the specific tickerID + const cachedData = getCache(params.tickerID, 'getHistoricalMarketCap'); + if (cachedData) { + output = cachedData; + } else { + + const {apiKey, apiURL} = await parent(); + const postData = { + ticker: params.tickerID + }; + + // make the POST request to the endpoint + const response = await fetch(apiURL + '/historical-market-cap', { + method: 'POST', + headers: { + "Content-Type": "application/json", "X-API-KEY": apiKey + }, + body: JSON.stringify(postData) + }); + + output = await response.json(); + + // Cache the data for this specific tickerID with a specific name 'getHistoricalMarketCap' + setCache(params.tickerID, output, 'getHistoricalMarketCap'); + } + + return output; + }; + + // Make sure to return a promise + return { + getHistoricalMarketCap: await getHistoricalMarketCap() + }; +};