update insider page
This commit is contained in:
parent
57d5845b46
commit
d948458ed9
@ -13,7 +13,7 @@
|
|||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
let statistics = data?.getInsiderTradingStatistics ?? {};
|
let statistics = data?.getInsiderTradingStatistics ?? {};
|
||||||
|
|
||||||
let buySellRatio = statistics?.purchases/statistics?.sales
|
let buySellRatio = statistics?.totalBought/statistics?.totalSold
|
||||||
let buyShares = statistics?.totalBought
|
let buyShares = statistics?.totalBought
|
||||||
let soldShares = statistics?.totalSold
|
let soldShares = statistics?.totalSold
|
||||||
let buySharesPercentage = Math.floor(buyShares/(buyShares+soldShares)*100);
|
let buySharesPercentage = Math.floor(buyShares/(buyShares+soldShares)*100);
|
||||||
@ -25,7 +25,6 @@
|
|||||||
let insiderTradingList = [];
|
let insiderTradingList = [];
|
||||||
let dataPoints = [];
|
let dataPoints = [];
|
||||||
let dates = [];
|
let dates = [];
|
||||||
let barChartData = [];
|
|
||||||
let soldList = [];
|
let soldList = [];
|
||||||
let boughtList = [];
|
let boughtList = [];
|
||||||
let grantList = [];
|
let grantList = [];
|
||||||
@ -386,9 +385,9 @@ onMount(async() => {
|
|||||||
|
|
||||||
{/if}
|
{/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">
|
<h3 class="text-white text-xl font-semibold pt-5">
|
||||||
Insider Statistics
|
Q{statistics?.quarter} {statistics?.year} Insider Statistics
|
||||||
</h3>
|
</h3>
|
||||||
<!--Start Widget-->
|
<!--Start Widget-->
|
||||||
<div class="w-full mt-5 mb-10 m-auto flex justify-center items-center p-1">
|
<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 () => {
|
const getInsiderTradingStatistics = async () => {
|
||||||
|
|
||||||
let sums = {
|
let output;
|
||||||
totalBought: 0,
|
|
||||||
totalSold: 0,
|
|
||||||
purchases: 0,
|
|
||||||
sales: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
const cachedData = getCache(params.tickerID, 'getInsiderTradingStatistics');
|
const cachedData = getCache(params.tickerID, 'getInsiderTradingStatistics');
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
sums = cachedData;
|
output = cachedData;
|
||||||
} else {
|
} else {
|
||||||
const postData = {
|
const postData = {
|
||||||
ticker: params.tickerID
|
ticker: params.tickerID
|
||||||
@ -105,21 +100,13 @@ export const load = async ({ params }) => {
|
|||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
});
|
});
|
||||||
|
|
||||||
const output = await response?.json();
|
output = await response?.json();
|
||||||
|
|
||||||
// Iterate through the list and accumulate the values
|
setCache(params.tickerID, output, 'getInsiderTradingStatistics');
|
||||||
output?.forEach(item => {
|
|
||||||
sums.totalBought += item.totalBought;
|
|
||||||
sums.totalSold += item.totalSold;
|
|
||||||
sums.purchases += item.purchases;
|
|
||||||
sums.sales += item.sales;
|
|
||||||
});
|
|
||||||
|
|
||||||
setCache(params.tickerID, sums, 'getInsiderTradingStatistics');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sums;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user