From a0ac1fb7ed502a880c272d390a61b1237c5b4c43 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Fri, 5 Jul 2024 21:09:18 +0200 Subject: [PATCH] Add GovernmentContract component --- src/lib/components/GovernmentContract.svelte | 353 +++++++++++++------ src/lib/store.ts | 4 + src/routes/stocks/[tickerID]/+page.svelte | 13 +- 3 files changed, 267 insertions(+), 103 deletions(-) diff --git a/src/lib/components/GovernmentContract.svelte b/src/lib/components/GovernmentContract.svelte index 55c2cd4f..f212fba3 100644 --- a/src/lib/components/GovernmentContract.svelte +++ b/src/lib/components/GovernmentContract.svelte @@ -1,54 +1,95 @@ - + $: { + if($stockTicker && typeof window !== 'undefined') { + isLoaded=false; + const ticker = $stockTicker + const asyncFunctions = [ + getGovernmentContract(ticker) + ]; + Promise.all(asyncFunctions) + .then((results) => { + if(rawData?.length !== 0) { + optionsData = getPlotOptions(); + } + }) + .catch((error) => { + console.error('An error occurred:', error); + }); + isLoaded = true; + + } + } + + let charNumber = 20; + + $: { + if($screenWidth < 640) + { + charNumber = 20; + } + else { + charNumber =40; + } + } + + + + -
-
- -
- - +
+
+ +
+ + +
+ + {#if data?.user?.tier === 'Pro'} + {#if isLoaded} + + {#if rawData?.length !== 0} + +
+
+ Since 2015, {$displayCompanyName} has secured a total of {totalContract} government contracts, amassing {abbreviateNumber(totalAmount,true)} in revenue. The company has averaged {avgNumberOfContracts} contracts per year, with a peak of {displayMaxContracts} contracts in {displayYear}.
- - {#if contractList?.length !== 0} -
-
- Gain insights into government spending on {$displayCompanyName} and determine the annual value of significant government contracts awarded to the company. -
-
- - - +
+ +
+ + -
+
- -
- The company averaged {avgNumberOfContracts} contracts annually, peaking at {displayMaxContracts} in {displayYear}. -
- - {:else} -

- No data available - -

+ +
+ +
- {/if} - -
-
- - - +
+ + + + # of Contracts + +
- \ No newline at end of file + + {/if} + + {:else} +
+
+ +
+
+ {/if} + + {:else} +
+ + Unlock content with Pro Subscription +
+ {/if} + +
+
+ + + + + \ No newline at end of file diff --git a/src/lib/store.ts b/src/lib/store.ts index f4f4a0fa..03c0c128 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -77,6 +77,10 @@ export const failToDeliverComponent= writable((false)); export const borrowedShareComponent= writable((false)); export const impliedVolatilityComponent= writable((false)); export const optionsNetFlowComponent= writable((false)); +export const governmentContractComponent= writable((false)); + + + export const strategyId = writable( ("")); export const articleId = writable( ("")); diff --git a/src/routes/stocks/[tickerID]/+page.svelte b/src/routes/stocks/[tickerID]/+page.svelte index 10530065..4b23fc4a 100644 --- a/src/routes/stocks/[tickerID]/+page.svelte +++ b/src/routes/stocks/[tickerID]/+page.svelte @@ -3,7 +3,7 @@ import {AreaSeries, Chart, PriceLine, CandlestickSeries} from 'svelte-lightweight-charts'; import { TrackingModeExitMode } from 'lightweight-charts'; - import {getCache, setCache, optionsNetFlowComponent, impliedVolatilityComponent, borrowedShareComponent, clinicalTrialComponent, optionComponent, failToDeliverComponent, marketMakerComponent, analystEstimateComponent, sentimentComponent, screenWidth, displayCompanyName, numberOfUnreadNotification, globalForm, varComponent, shareStatisticsComponent, enterpriseComponent, darkPoolComponent, retailVolumeComponent, shareholderComponent, trendAnalysisComponent, revenueSegmentationComponent, priceAnalysisComponent, fundamentalAnalysisComponent, userRegion, isCrosshairMoveActive, realtimePrice, priceIncrease, currentPortfolioPrice, currentPrice, stockTicker, isOpen, isBeforeMarketOpen, isWeekend} from '$lib/store'; + import {getCache, setCache, governmentContractComponent, optionsNetFlowComponent, impliedVolatilityComponent, borrowedShareComponent, clinicalTrialComponent, optionComponent, failToDeliverComponent, marketMakerComponent, analystEstimateComponent, sentimentComponent, screenWidth, displayCompanyName, numberOfUnreadNotification, globalForm, varComponent, shareStatisticsComponent, enterpriseComponent, darkPoolComponent, retailVolumeComponent, shareholderComponent, trendAnalysisComponent, revenueSegmentationComponent, priceAnalysisComponent, fundamentalAnalysisComponent, userRegion, isCrosshairMoveActive, realtimePrice, priceIncrease, currentPortfolioPrice, currentPrice, stockTicker, isOpen, isBeforeMarketOpen, isWeekend} from '$lib/store'; import { onDestroy, onMount } from 'svelte'; import BullBearSay from '$lib/components/BullBearSay.svelte'; import CommunitySentiment from '$lib/components/CommunitySentiment.svelte'; @@ -1304,7 +1304,16 @@ function changeChartType() { - + + +
+ {#await import('$lib/components/GovernmentContract.svelte') then {default: Comp}} + + {/await} +
+
+ +
{#await import('$lib/components/Enterprise.svelte') then {default: Comp}}