Browse Source

Refactoring

pull/5650/head
Thomas Kaul 3 weeks ago
parent
commit
fd5d4bb445
  1. 13
      apps/api/src/app/portfolio/portfolio.service.ts

13
apps/api/src/app/portfolio/portfolio.service.ts

@ -671,11 +671,15 @@ export class PortfolioService {
// Gather historical exchange rate data for all currencies in cash positions // Gather historical exchange rate data for all currencies in cash positions
const exchangeRatesByCurrency = const exchangeRatesByCurrency =
await this.exchangeRateDataService.getExchangeRatesByCurrency({ await this.exchangeRateDataService.getExchangeRatesByCurrency({
currencies: [
...new Set(cashDetails.accounts.map(({ currency }) => currency))
],
endDate, endDate,
startDate, startDate,
currencies: [
...new Set(
cashDetails.accounts.map(({ currency }) => {
return currency;
})
)
],
targetCurrency: userCurrency targetCurrency: userCurrency
}); });
@ -1694,8 +1698,10 @@ export class PortfolioService {
if (cashPositions[account.currency]) { if (cashPositions[account.currency]) {
cashPositions[account.currency].investment += convertedBalance; cashPositions[account.currency].investment += convertedBalance;
cashPositions[account.currency].netPerformanceWithCurrencyEffect += cashPositions[account.currency].netPerformanceWithCurrencyEffect +=
netPerformanceWithCurrencyEffect; netPerformanceWithCurrencyEffect;
cashPositions[account.currency].valueInBaseCurrency += convertedBalance; cashPositions[account.currency].valueInBaseCurrency += convertedBalance;
} else { } else {
cashPositions[account.currency] = this.getInitialCashPosition({ cashPositions[account.currency] = this.getInitialCashPosition({
@ -1715,6 +1721,7 @@ export class PortfolioService {
.div(value) .div(value)
.toNumber() .toNumber()
: 0; : 0;
cashPositions[symbol].netPerformancePercentWithCurrencyEffect = cashPositions[symbol].netPerformancePercentWithCurrencyEffect =
cashPositions[symbol].investment > 0 cashPositions[symbol].investment > 0
? new Big(cashPositions[symbol].netPerformanceWithCurrencyEffect) ? new Big(cashPositions[symbol].netPerformanceWithCurrencyEffect)

Loading…
Cancel
Save