diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts index 2c5b90050..a533ab288 100644 --- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts +++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts @@ -141,20 +141,34 @@ describe('PortfolioCalculator', () => { value: 0, valueWithCurrencyEffect: 0 }); - + /** + * Closing price on 2021-12-12: 50098.3 + */ expect(portfolioSnapshot.historicalData[1]).toEqual({ date: '2021-12-12', investmentValueWithCurrencyEffect: 44558.42, - netPerformance: -4.46, + /** + * Correct calculation: 1 * (50098.3 - 44558.42) - 4.46 = 5535.42 + * Current calculation: 1 * (44558.42 - 44558.42) - 4.46 = -4.46 + */ + netPerformance: 5535.42, netPerformanceInPercentage: 0, netPerformanceInPercentageWithCurrencyEffect: 0, - netPerformanceWithCurrencyEffect: -4.46, - netWorth: 44558.42, + netPerformanceWithCurrencyEffect: 5535.42, + /** + * Correct calculation: 1 * 50098.3 = 50098.3 + * Current calculation: 1 * 44558.42 = 44558.42 + */ + netWorth: 50098.3, totalAccountBalance: 0, totalInvestment: 44558.42, totalInvestmentValueWithCurrencyEffect: 44558.42, - value: 44558.42, - valueWithCurrencyEffect: 44558.42 + /** + * Correct calculation: 1 * 50098.3 = 50098.3 + * Current calculation: 1 * 44558.42 = 44558.42 + */ + value: 50098.3, + valueWithCurrencyEffect: 50098.3 }); expect( diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts index 96205fd77..bc411142b 100644 --- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts +++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts @@ -142,19 +142,38 @@ describe('PortfolioCalculator', () => { valueWithCurrencyEffect: 0 }); + /** + * Closing price on 2021-12-12: 50098.3 + */ expect(portfolioSnapshot.historicalData[1]).toEqual({ date: '2021-12-12', investmentValueWithCurrencyEffect: 44558.42, - netPerformance: -4.46, + /** + * Correct calculation: 1 * (50098.3 - 44558.42) - 4.46 = 5535.42 + * Current calculation: 1 * (44558.42 - 44558.42) - 4.46 = -4.46 + */ + netPerformance: 5535.42, netPerformanceInPercentage: 0, netPerformanceInPercentageWithCurrencyEffect: 0, - netPerformanceWithCurrencyEffect: -4.46, - netWorth: 44558.42, + /** + * Correct calculation: 1 * (50098.3 - 44558.42) - 4.46 = 5535.42 + * Current calculation: 1 * (44558.42 - 44558.42) - 4.46 = -4.46 + */ + netPerformanceWithCurrencyEffect: 5535.42, + /** + * Correct calculation: 1 * 50098.3 = 50098.3 + * Current calculation: 1 * 44558.42 = 44558.42 + */ + netWorth: 50098.3, totalAccountBalance: 0, totalInvestment: 44558.42, totalInvestmentValueWithCurrencyEffect: 44558.42, - value: 44558.42, - valueWithCurrencyEffect: 44558.42 + /** + * Correct calculation: 1 * 50098.3 = 50098.3 + * Current calculation: 1 * 44558.42 = 44558.42 + */ + value: 50098.3, + valueWithCurrencyEffect: 50098.3 }); expect( diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts index b5d7d59f8..38a5c659b 100644 --- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts +++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts @@ -145,19 +145,35 @@ describe('PortfolioCalculator', () => { valueWithCurrencyEffect: 0 }); + /** + * Closing price on 2022-03-07 is unknown, + * hence it uses the last unit price (2022-04-11): 87.8 + */ expect(portfolioSnapshot.historicalData[1]).toEqual({ date: '2022-03-07', investmentValueWithCurrencyEffect: 151.6, - netPerformance: 0, + /** + * Correct calculation: 2 * (87.8 - 75.8) = 24 + * Current calculation: 2 * (75.8 - 75.8) = 0 + */ + netPerformance: 24, netPerformanceInPercentage: 0, netPerformanceInPercentageWithCurrencyEffect: 0, - netPerformanceWithCurrencyEffect: 0, - netWorth: 151.6, + netPerformanceWithCurrencyEffect: 24, + /** + * Correct calculation: 2 * 87.8 = 175.6 + * Current calculation: 2 * 75.8 = 151.6 + */ + netWorth: 175.6, totalAccountBalance: 0, totalInvestment: 151.6, totalInvestmentValueWithCurrencyEffect: 151.6, - value: 151.6, - valueWithCurrencyEffect: 151.6 + /** + * Correct calculation: 2 * 87.8 = 175.6 + * Current calculation: 2 * 75.8 = 151.6 + */ + value: 175.6, + valueWithCurrencyEffect: 175.6 }); expect(