Browse Source

Fix tests

pull/5027/head
Daniel Devaud 3 months ago
parent
commit
6573126116
  1. 18
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 18
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts

18
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -199,10 +199,7 @@ export abstract class PortfolioCalculator {
for (const { currency, dataSource, symbol } of transactionPoints[ for (const { currency, dataSource, symbol } of transactionPoints[
firstIndex - 1 firstIndex - 1
].items) { ].items) {
dataGatheringItems.push({ dataGatheringItems.push({ dataSource, symbol });
dataSource,
symbol
});
currencies[symbol] = currency; currencies[symbol] = currency;
} }
@ -231,17 +228,12 @@ export abstract class PortfolioCalculator {
values: marketSymbols values: marketSymbols
} = await this.currentRateService.getValues({ } = await this.currentRateService.getValues({
dataGatheringItems, dataGatheringItems,
dateQuery: { dateQuery: { gte: this.startDate, lt: this.endDate }
gte: this.startDate,
lt: this.endDate
}
}); });
this.dataProviderInfos = dataProviderInfos; this.dataProviderInfos = dataProviderInfos;
const marketSymbolMap: { const marketSymbolMap: { [date: string]: { [symbol: string]: Big } } = {};
[date: string]: { [symbol: string]: Big };
} = {};
for (const marketSymbol of marketSymbols) { for (const marketSymbol of marketSymbols) {
const date = format(marketSymbol.date, DATE_FORMAT); const date = format(marketSymbol.date, DATE_FORMAT);
@ -1111,9 +1103,7 @@ export abstract class PortfolioCalculator {
chartDateMap: { [date: string]: boolean }; chartDateMap: { [date: string]: boolean };
end: Date; end: Date;
exchangeRates: { [dateString: string]: number }; exchangeRates: { [dateString: string]: number };
marketSymbolMap: { marketSymbolMap: { [date: string]: { [symbol: string]: Big } };
[date: string]: { [symbol: string]: Big };
};
start: Date; start: Date;
} & AssetProfileIdentifier): SymbolMetrics; } & AssetProfileIdentifier): SymbolMetrics;

18
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts

@ -154,25 +154,25 @@ describe('PortfolioCalculator', () => {
dividendInBaseCurrency: new Big('0.62'), dividendInBaseCurrency: new Big('0.62'),
fee: new Big('19'), fee: new Big('19'),
firstBuyDate: '2021-09-16', firstBuyDate: '2021-09-16',
grossPerformance: new Big('33.87'), grossPerformance: new Big('33.25'),
grossPerformancePercentage: new Big('0.11343693482483756447'), grossPerformancePercentage: new Big('0.11136043941322258691'),
grossPerformancePercentageWithCurrencyEffect: new Big( grossPerformancePercentageWithCurrencyEffect: new Big(
'0.11343693482483756447' '0.11136043941322258691'
), ),
grossPerformanceWithCurrencyEffect: new Big('33.87'), grossPerformanceWithCurrencyEffect: new Big('33.25'),
investment: new Big('298.58'), investment: new Big('298.58'),
investmentWithCurrencyEffect: new Big('298.58'), investmentWithCurrencyEffect: new Big('298.58'),
marketPrice: 331.83, marketPrice: 331.83,
marketPriceInBaseCurrency: 331.83, marketPriceInBaseCurrency: 331.83,
netPerformance: new Big('14.87'), netPerformance: new Big('14.25'),
netPerformancePercentage: new Big('0.04980239801728180052'), netPerformancePercentage: new Big('0.04772590260566682296'),
netPerformancePercentageWithCurrencyEffectMap: { netPerformancePercentageWithCurrencyEffectMap: {
max: new Big('0.04980239801728180052') max: new Big('0.04772590260566682296')
}, },
netPerformanceWithCurrencyEffectMap: { netPerformanceWithCurrencyEffectMap: {
'1d': new Big('-5.39'), '1d': new Big('-5.39'),
'5y': new Big('14.87'), '5y': new Big('14.25'),
max: new Big('14.87'), max: new Big('14.25'),
wtd: new Big('-5.39') wtd: new Big('-5.39')
}, },
quantity: new Big('1'), quantity: new Big('1'),

Loading…
Cancel
Save