Browse Source

Fix tests

pull/3393/head
Reto Kaul 1 year ago
parent
commit
026af10f36
  1. 2
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts
  2. 2
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts
  3. 2
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts
  4. 13
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

2
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts

@ -178,7 +178,7 @@ describe('PortfolioCalculator', () => {
'-0.05528341497550734703'
),
netPerformancePercentageWithCurrencyEffectMap: {
max: new Big('-0.18658152554233729881') // TODO: Different
max: new Big('-0.0552834149755073478')
},
netPerformanceWithCurrencyEffect: new Big('-15.8'),
netPerformanceWithCurrencyEffectMap: {

2
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts

@ -163,7 +163,7 @@ describe('PortfolioCalculator', () => {
'-0.0552834149755073478'
),
netPerformancePercentageWithCurrencyEffectMap: {
max: new Big('-0.18658152554233729881') // TODO: Different
max: new Big('-0.0552834149755073478')
},
netPerformanceWithCurrencyEffect: new Big('-15.8'),
netPerformanceWithCurrencyEffectMap: {

2
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts

@ -193,7 +193,7 @@ describe('PortfolioCalculator', () => {
'0.13100263852242744063'
),
netPerformancePercentageWithCurrencyEffectMap: {
max: new Big('0.14737796833773087071')
max: new Big('0.13100263852242744063')
},
netPerformanceWithCurrencyEffect: new Big('19.86'),
netPerformanceWithCurrencyEffectMap: {

13
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

@ -924,9 +924,16 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
netPerformanceWithCurrencyEffectMap[dateRange] =
netPerformanceValuesWithCurrencyEffect[
format(endDate, DATE_FORMAT)
].minus(
netPerformanceValuesWithCurrencyEffect[format(startDate, DATE_FORMAT)]
);
]?.minus(
// If the date range is 'max', take 0 as a start value. Otherwise,
// the value of the end of the day of the start date is taken which
// can differ.
dateRange === 'max'
? new Big(0)
: (netPerformanceValuesWithCurrencyEffect[
format(startDate, DATE_FORMAT)
] ?? new Big(0))
) ?? new Big(0);
netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0)
? netPerformanceWithCurrencyEffectMap[dateRange].div(average)

Loading…
Cancel
Save