update insider page
This commit is contained in:
parent
57d5845b46
commit
d948458ed9
@ -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 }
|
||||
<h3 class="text-white text-xl font-semibold pt-5">
|
||||
Insider Statistics
|
||||
Q{statistics?.quarter} {statistics?.year} Insider Statistics
|
||||
</h3>
|
||||
<!--Start Widget-->
|
||||
<div class="w-full mt-5 mb-10 m-auto flex justify-center items-center p-1">
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user