Browse Source

Fix liabilities without market data

pull/7345/head
Thomas Kaul 2 months ago
parent
commit
c1338b448d
  1. 12
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator.ts

12
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator.ts

@ -2,7 +2,7 @@ import { PortfolioCalculator } from '@ghostfolio/api/app/portfolio/calculator/po
import { PortfolioOrderItem } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-order-item.interface'; import { PortfolioOrderItem } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-order-item.interface';
import { getFactor } from '@ghostfolio/api/helper/portfolio.helper'; import { getFactor } from '@ghostfolio/api/helper/portfolio.helper';
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'; import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper';
import { DATE_FORMAT, getSum } from '@ghostfolio/common/helper'; import { DATE_FORMAT } from '@ghostfolio/common/helper';
import { import {
AssetProfileIdentifier, AssetProfileIdentifier,
SymbolMetrics SymbolMetrics
@ -296,11 +296,9 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
// A missing market price can only affect the units which are held. The // A missing market price can only affect the units which are held. The
// dividends, the interest and the liabilities do not hold any units and // dividends, the interest and the liabilities do not hold any units and
// are therefore not in error. // are therefore not in error.
const totalUnitsOfActivities = getSum( const hasActivitiesWithUnits = orders.some(({ type }) => {
orders.map(({ quantity, type }) => { return ['BUY', 'SELL'].includes(type);
return quantity.mul(getFactor(type)); });
})
);
return { return {
totalDividend, totalDividend,
@ -316,7 +314,7 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
grossPerformancePercentage: new Big(0), grossPerformancePercentage: new Big(0),
grossPerformancePercentageWithCurrencyEffect: new Big(0), grossPerformancePercentageWithCurrencyEffect: new Big(0),
grossPerformanceWithCurrencyEffect: new Big(0), grossPerformanceWithCurrencyEffect: new Big(0),
hasErrors: totalUnitsOfActivities.gt(0), hasErrors: hasActivitiesWithUnits,
initialValue: new Big(0), initialValue: new Big(0),
initialValueWithCurrencyEffect: new Big(0), initialValueWithCurrencyEffect: new Big(0),
investmentValuesAccumulated: {}, investmentValuesAccumulated: {},

Loading…
Cancel
Save