Browse Source

Refactoring

pull/4650/head
Thomas Kaul 4 months ago
parent
commit
e142bdd21b
  1. 16
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts

16
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts

@ -223,12 +223,14 @@ describe('PortfolioCalculator', () => {
});
const portfolioSnapshot = await portfolioCalculator.computeSnapshot();
const snapshotOnTheDate = portfolioSnapshot.historicalData.find(
(snapshot) => snapshot.date === '2021-11-30'
const snapshotOnBuyDate = portfolioSnapshot.historicalData.find(
({ date }) => {
return date === '2021-11-30';
}
);
// Closing price on 2021-11-30: 136.6
expect(snapshotOnTheDate?.netPerformanceWithCurrencyEffect).toEqual(1.65); // 2 * (136.6 - 135.0) - 1.55 = 1.65
expect(snapshotOnBuyDate?.netPerformanceWithCurrencyEffect).toEqual(1.65); // 2 * (136.6 - 135.0) - 1.55 = 1.65
});
it.only('with BALN.SW buy (with unit price lower than closing price), calculated on buy date', async () => {
@ -260,12 +262,14 @@ describe('PortfolioCalculator', () => {
});
const portfolioSnapshot = await portfolioCalculator.computeSnapshot();
const snapshotOnTheDate = portfolioSnapshot.historicalData.find(
(snapshot) => snapshot.date === '2021-11-30'
const snapshotOnBuyDate = portfolioSnapshot.historicalData.find(
({ date }) => {
return date === '2021-11-30';
}
);
// Closing price on 2021-11-30: 136.6
expect(snapshotOnTheDate?.netPerformanceWithCurrencyEffect).toEqual(1.65); // 2 * (136.6 - 135.0) - 1.55 = 1.65
expect(snapshotOnBuyDate?.netPerformanceWithCurrencyEffect).toEqual(1.65); // 2 * (136.6 - 135.0) - 1.55 = 1.65
});
});
});

Loading…
Cancel
Save