diff --git a/README.md b/README.md index 84c9b43..47e94c4 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,7 @@ Why this Project? - Portfolio Performance & Value - All assets (except the TTWOR and Portfolio-Value) are scaled by percentage of their price. Thus their referenced, scale is on the right. The referenced scale on the left is only for the portfolio-value -https://github.com/user-attachments/assets/78b027fa-9883-4813-8086-8b6aa19767de - +https://github.com/user-attachments/assets/4507e102-8dfb-4614-b2ba-938e20e3d97b ## Features diff --git a/src/utils/calculations/performance.ts b/src/utils/calculations/performance.ts index cd2e04b..483b73a 100644 --- a/src/utils/calculations/performance.ts +++ b/src/utils/calculations/performance.ts @@ -1,4 +1,4 @@ -import { differenceInDays, isAfter, isBefore } from "date-fns"; +import { isAfter, isBefore } from "date-fns"; import type { Asset, InvestmentPerformance, PortfolioPerformance } from "../../types"; @@ -166,20 +166,23 @@ export const calculateInvestmentPerformance = (assets: Asset[]): PortfolioPerfor : 0; // Berechne die jährliche Performance - const performancePerAnnoPerformance = (() => { - if (!earliestDate || totalInvested === 0) return 0; + // const performancePerAnnoPerformance = (() => { + // if (!earliestDate || totalInvested === 0) return 0; - const years = differenceInDays(new Date(), earliestDate) / 365; - if (years < 0.01) return 0; // Verhindere Division durch sehr kleine Zahlen + // const years = differenceInDays(new Date(), earliestDate) / 365; + // if (years < 0.01) return 0; // Verhindere Division durch sehr kleine Zahlen - // Formel: (1 + r)^n = FV/PV - // r = (FV/PV)^(1/n) - 1 - const totalReturn = totalCurrentValue / totalInvested; - const annualizedReturn = Math.pow(totalReturn, 1 / years) - 1; + // // Formel: (1 + r)^n = FV/PV + // // r = (FV/PV)^(1/n) - 1 + // const totalReturn = totalCurrentValue / totalInvested; + // const annualizedReturn = Math.pow(totalReturn, 1 / years) - 1; - return annualizedReturn * 100; - })(); + // return annualizedReturn * 100; + // })(); + const performancePerAnnoPerformance = annualPerformances.reduce((acc, curr) => acc + curr.percentage, 0) / annualPerformances.length; + + console.log(performancePerAnnoPerformance, annualPerformances); return { investments, summary: {