diff --git a/src/routes/stocks/[tickerID]/insider/+page.svelte b/src/routes/stocks/[tickerID]/insider/+page.svelte
index 788ba92c..a0566d97 100644
--- a/src/routes/stocks/[tickerID]/insider/+page.svelte
+++ b/src/routes/stocks/[tickerID]/insider/+page.svelte
@@ -13,7 +13,7 @@
let isLoaded = false;
let statistics = data?.getInsiderTradingStatistics ?? {};
- let buySellRatio = statistics?.purchases/statistics?.sales
+ let buySellRatio = statistics?.totalBought/statistics?.totalSold
let buyShares = statistics?.totalBought
let soldShares = statistics?.totalSold
let buySharesPercentage = Math.floor(buyShares/(buyShares+soldShares)*100);
@@ -25,7 +25,6 @@
let insiderTradingList = [];
let dataPoints = [];
let dates = [];
- let barChartData = [];
let soldList = [];
let boughtList = [];
let grantList = [];
@@ -386,9 +385,9 @@ onMount(async() => {
{/if}
- {#if JSON.stringify(statistics) !== JSON.stringify({ totalBought: 0, totalSold: 0, purchases: 0, sales: 0 }) }
+ {#if Object?.keys(statistics)?.length !== 0 }
- Insider Statistics
+ Q{statistics?.quarter} {statistics?.year} Insider Statistics
diff --git a/src/routes/stocks/[tickerID]/insider/+page.ts b/src/routes/stocks/[tickerID]/insider/+page.ts
index fb75c3cf..658c6549 100644
--- a/src/routes/stocks/[tickerID]/insider/+page.ts
+++ b/src/routes/stocks/[tickerID]/insider/+page.ts
@@ -81,16 +81,11 @@ export const load = async ({ params }) => {
const getInsiderTradingStatistics = async () => {
- let sums = {
- totalBought: 0,
- totalSold: 0,
- purchases: 0,
- sales: 0
- };
+ let output;
const cachedData = getCache(params.tickerID, 'getInsiderTradingStatistics');
if (cachedData) {
- sums = cachedData;
+ output = cachedData;
} else {
const postData = {
ticker: params.tickerID
@@ -105,21 +100,13 @@ export const load = async ({ params }) => {
body: JSON.stringify(postData)
});
- const output = await response?.json();
+ output = await response?.json();
- // Iterate through the list and accumulate the values
- output?.forEach(item => {
- sums.totalBought += item.totalBought;
- sums.totalSold += item.totalSold;
- sums.purchases += item.purchases;
- sums.sales += item.sales;
- });
-
- setCache(params.tickerID, sums, 'getInsiderTradingStatistics');
+ setCache(params.tickerID, output, 'getInsiderTradingStatistics');
}
- return sums;
+ return output;
};