|
@ -288,7 +288,9 @@ export abstract class PortfolioCalculator { |
|
|
firstIndex--; |
|
|
firstIndex--; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const positions: TimelinePosition[] = []; |
|
|
const positions: (TimelinePosition & { |
|
|
|
|
|
isInvestmentAssetProfilePosition: boolean; |
|
|
|
|
|
})[] = []; |
|
|
let hasAnySymbolMetricsErrors = false; |
|
|
let hasAnySymbolMetricsErrors = false; |
|
|
|
|
|
|
|
|
const errors: ResponseError['errors'] = []; |
|
|
const errors: ResponseError['errors'] = []; |
|
@ -412,6 +414,7 @@ export abstract class PortfolioCalculator { |
|
|
: null, |
|
|
: null, |
|
|
investment: totalInvestment, |
|
|
investment: totalInvestment, |
|
|
investmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect, |
|
|
investmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect, |
|
|
|
|
|
isInvestmentAssetProfilePosition: item.isInvestmentAssetProfileItem, |
|
|
marketPrice: |
|
|
marketPrice: |
|
|
marketSymbolMap[endDateString]?.[item.symbol]?.toNumber() ?? null, |
|
|
marketSymbolMap[endDateString]?.[item.symbol]?.toNumber() ?? null, |
|
|
marketPriceInBaseCurrency: |
|
|
marketPriceInBaseCurrency: |
|
@ -606,14 +609,23 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
|
const overall = this.calculateOverallPerformance(positions); |
|
|
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 { |
|
|
return { |
|
|
...overall, |
|
|
...overall, |
|
|
errors, |
|
|
errors, |
|
|
historicalData, |
|
|
historicalData, |
|
|
positions, |
|
|
|
|
|
totalInterestWithCurrencyEffect, |
|
|
totalInterestWithCurrencyEffect, |
|
|
totalLiabilitiesWithCurrencyEffect, |
|
|
totalLiabilitiesWithCurrencyEffect, |
|
|
hasErrors: hasAnySymbolMetricsErrors || overall.hasErrors |
|
|
hasErrors: hasAnySymbolMetricsErrors || overall.hasErrors, |
|
|
|
|
|
positions: investmentPositions |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -899,7 +911,6 @@ export abstract class PortfolioCalculator { |
|
|
} of this.activities) { |
|
|
} of this.activities) { |
|
|
let currentTransactionPointItem: TransactionPointSymbol; |
|
|
let currentTransactionPointItem: TransactionPointSymbol; |
|
|
|
|
|
|
|
|
if (INVESTMENT_ACTIVITY_TYPES.includes(type)) { |
|
|
|
|
|
const currency = SymbolProfile.currency; |
|
|
const currency = SymbolProfile.currency; |
|
|
const dataSource = SymbolProfile.dataSource; |
|
|
const dataSource = SymbolProfile.dataSource; |
|
|
const factor = getFactor(type); |
|
|
const factor = getFactor(type); |
|
@ -937,6 +948,8 @@ export abstract class PortfolioCalculator { |
|
|
dividend: new Big(0), |
|
|
dividend: new Big(0), |
|
|
fee: oldAccumulatedSymbol.fee.plus(fee), |
|
|
fee: oldAccumulatedSymbol.fee.plus(fee), |
|
|
firstBuyDate: oldAccumulatedSymbol.firstBuyDate, |
|
|
firstBuyDate: oldAccumulatedSymbol.firstBuyDate, |
|
|
|
|
|
isInvestmentAssetProfileItem: |
|
|
|
|
|
oldAccumulatedSymbol.isInvestmentAssetProfileItem, |
|
|
quantity: newQuantity, |
|
|
quantity: newQuantity, |
|
|
tags: oldAccumulatedSymbol.tags.concat(tags), |
|
|
tags: oldAccumulatedSymbol.tags.concat(tags), |
|
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1 |
|
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1 |
|
@ -953,6 +966,8 @@ export abstract class PortfolioCalculator { |
|
|
dividend: new Big(0), |
|
|
dividend: new Big(0), |
|
|
firstBuyDate: date, |
|
|
firstBuyDate: date, |
|
|
investment: unitPrice.mul(quantity).mul(factor), |
|
|
investment: unitPrice.mul(quantity).mul(factor), |
|
|
|
|
|
isInvestmentAssetProfileItem: |
|
|
|
|
|
INVESTMENT_ACTIVITY_TYPES.includes(type), |
|
|
quantity: quantity.mul(factor), |
|
|
quantity: quantity.mul(factor), |
|
|
transactionCount: 1 |
|
|
transactionCount: 1 |
|
|
}; |
|
|
}; |
|
@ -964,7 +979,6 @@ export abstract class PortfolioCalculator { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
symbols[SymbolProfile.symbol] = currentTransactionPointItem; |
|
|
symbols[SymbolProfile.symbol] = currentTransactionPointItem; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const items = lastTransactionPoint?.items ?? []; |
|
|
const items = lastTransactionPoint?.items ?? []; |
|
|
|
|
|
|
|
@ -972,9 +986,7 @@ export abstract class PortfolioCalculator { |
|
|
return symbol !== SymbolProfile.symbol; |
|
|
return symbol !== SymbolProfile.symbol; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (currentTransactionPointItem) { |
|
|
|
|
|
newItems.push(currentTransactionPointItem); |
|
|
newItems.push(currentTransactionPointItem); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
newItems.sort((a, b) => { |
|
|
newItems.sort((a, b) => { |
|
|
return a.symbol?.localeCompare(b.symbol); |
|
|
return a.symbol?.localeCompare(b.symbol); |
|
|