|
|
@ -13,6 +13,7 @@ import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfac |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'; |
|
|
|
import { |
|
|
|
INVESTMENT_ACTIVITY_TYPES, |
|
|
|
PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, |
|
|
|
PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS, |
|
|
|
PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE_PRIORITY_HIGH, |
|
|
@ -287,7 +288,9 @@ export abstract class PortfolioCalculator { |
|
|
|
firstIndex--; |
|
|
|
} |
|
|
|
|
|
|
|
const positions: TimelinePosition[] = []; |
|
|
|
const positions: (TimelinePosition & { |
|
|
|
isInvestmentAssetProfilePosition: boolean; |
|
|
|
})[] = []; |
|
|
|
let hasAnySymbolMetricsErrors = false; |
|
|
|
|
|
|
|
const errors: ResponseError['errors'] = []; |
|
|
@ -411,6 +414,7 @@ export abstract class PortfolioCalculator { |
|
|
|
: null, |
|
|
|
investment: totalInvestment, |
|
|
|
investmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect, |
|
|
|
isInvestmentAssetProfilePosition: item.isInvestmentAssetProfileItem, |
|
|
|
marketPrice: |
|
|
|
marketSymbolMap[endDateString]?.[item.symbol]?.toNumber() ?? null, |
|
|
|
marketPriceInBaseCurrency: |
|
|
@ -605,14 +609,23 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
const overall = this.calculateOverallPerformance(positions); |
|
|
|
|
|
|
|
const investmentPositions = positions |
|
|
|
.filter(({ isInvestmentAssetProfilePosition }) => { |
|
|
|
return isInvestmentAssetProfilePosition; |
|
|
|
}) |
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
.map(({ isInvestmentAssetProfilePosition, ...rest }) => { |
|
|
|
return rest; |
|
|
|
}); |
|
|
|
|
|
|
|
return { |
|
|
|
...overall, |
|
|
|
errors, |
|
|
|
historicalData, |
|
|
|
positions, |
|
|
|
totalInterestWithCurrencyEffect, |
|
|
|
totalLiabilitiesWithCurrencyEffect, |
|
|
|
hasErrors: hasAnySymbolMetricsErrors || overall.hasErrors |
|
|
|
hasErrors: hasAnySymbolMetricsErrors || overall.hasErrors, |
|
|
|
positions: investmentPositions |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
@ -935,6 +948,8 @@ export abstract class PortfolioCalculator { |
|
|
|
dividend: new Big(0), |
|
|
|
fee: oldAccumulatedSymbol.fee.plus(fee), |
|
|
|
firstBuyDate: oldAccumulatedSymbol.firstBuyDate, |
|
|
|
isInvestmentAssetProfileItem: |
|
|
|
oldAccumulatedSymbol.isInvestmentAssetProfileItem, |
|
|
|
quantity: newQuantity, |
|
|
|
tags: oldAccumulatedSymbol.tags.concat(tags), |
|
|
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1 |
|
|
@ -951,6 +966,8 @@ export abstract class PortfolioCalculator { |
|
|
|
dividend: new Big(0), |
|
|
|
firstBuyDate: date, |
|
|
|
investment: unitPrice.mul(quantity).mul(factor), |
|
|
|
isInvestmentAssetProfileItem: |
|
|
|
INVESTMENT_ACTIVITY_TYPES.includes(type), |
|
|
|
quantity: quantity.mul(factor), |
|
|
|
transactionCount: 1 |
|
|
|
}; |
|
|
|