From 9517b0fdf93877b4c0c8e275a08a6acb8dd01a88 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 5 Aug 2024 09:39:28 +0200 Subject: [PATCH] bugfixing ratios page --- src/lib/utils.ts | 2 +- .../[tickerID]/stats/income/+page.svelte | 1 - .../[tickerID]/stats/ratios/+page.svelte | 33 +++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 1958478a..aac51722 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -143,7 +143,7 @@ export function sumQuarterlyResultsByYear(quarterlyResults, namingList) { // Define a Set of keys to exclude from summing //FMP sucks since these keys are up to date for every quarter hence no summation required - const excludeKeys = new Set(['weightedAverageShsOut', 'weightedAverageShsOutDil']); + const excludeKeys = new Set(['priceToEarnings','weightedAverageShsOut', 'weightedAverageShsOutDil']); // Function to get the quarter number from the period string function getQuarterNumber(period) { diff --git a/src/routes/stocks/[tickerID]/stats/income/+page.svelte b/src/routes/stocks/[tickerID]/stats/income/+page.svelte index c54b4fad..7b266c70 100644 --- a/src/routes/stocks/[tickerID]/stats/income/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/income/+page.svelte @@ -350,7 +350,6 @@ const exportData = (format = 'csv') => { } - diff --git a/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte b/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte index 7d9d6b0e..a6001ce4 100644 --- a/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte @@ -314,7 +314,7 @@ $: { if (timeFrame || displayStatement || filterRule) { if (filterRule === 'annual') { - fullStatement = sumQuarterlyResultsByYear(data?.getRatiosStatement) + fullStatement = sumQuarterlyResultsByYear(data?.getRatiosStatement, namingList) } else { fullStatement = data?.getRatiosStatement; @@ -333,8 +333,7 @@ $: { } -} - +} @@ -512,44 +511,58 @@ $: { PE Ratio {#each ratios as item} - {item?.priceEarningsRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.priceEarningsRatio/4)?.toFixed(2): item?.priceEarningsRatio?.toFixed(2)} + {/each} PS Ratio {#each ratios as item} - {item?.priceToSalesRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.priceToSalesRatio/4)?.toFixed(2): item?.priceToSalesRatio?.toFixed(2)} + {/each} PB Ratio {#each ratios as item} - {item?.priceToBookRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.priceToBookRatio/4)?.toFixed(2): item?.priceToBookRatio?.toFixed(2)} + {/each} P/FCF Ratio {#each ratios as item} - {item?.priceToFreeCashFlowsRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.priceToFreeCashFlowsRatio/4)?.toFixed(2): item?.priceToFreeCashFlowsRatio?.toFixed(2)} + {/each} P/OCF Ratio {#each ratios as item} - {item?.priceToOperatingCashFlowsRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.priceToOperatingCashFlowsRatio/4)?.toFixed(2): item?.priceToOperatingCashFlowsRatio?.toFixed(2)} + {/each} OCF/S Ratio {#each ratios as item} - {item?.operatingCashFlowSalesRatio !== null ? item?.operatingCashFlowSalesRatio?.toFixed(2) : '-'} + + {filterRule === 'annual' ? (item?.operatingCashFlowSalesRatio/4)?.toFixed(2): item?.operatingCashFlowSalesRatio?.toFixed(2)} + {/each} Debt / Equity Ratio {#each ratios as item} - {item?.debtEquityRatio?.toFixed(2)} + + {filterRule === 'annual' ? (item?.debtEquityRatio/4)?.toFixed(2): item?.debtEquityRatio?.toFixed(2)} + {/each}