|
|
@ -176,7 +176,7 @@ export abstract class PortfolioCalculator { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected abstract calculateOverallPerformance( |
|
|
protected abstract calculateOverallPerformance( |
|
|
positions: TimelinePosition[] |
|
|
positions: (TimelinePosition & { includeInPerformance: boolean })[] |
|
|
): PortfolioSnapshot; |
|
|
): PortfolioSnapshot; |
|
|
|
|
|
|
|
|
@LogPerformance |
|
|
@LogPerformance |
|
|
@ -314,6 +314,7 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
|
const positions: (TimelinePosition & { |
|
|
const positions: (TimelinePosition & { |
|
|
includeInHoldings: boolean; |
|
|
includeInHoldings: boolean; |
|
|
|
|
|
includeInPerformance: boolean; |
|
|
})[] = []; |
|
|
})[] = []; |
|
|
|
|
|
|
|
|
const accumulatedValuesByDate: { |
|
|
const accumulatedValuesByDate: { |
|
|
@ -356,6 +357,10 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
|
const valueInBaseCurrency = marketPriceInBaseCurrency.mul(item.quantity); |
|
|
const valueInBaseCurrency = marketPriceInBaseCurrency.mul(item.quantity); |
|
|
|
|
|
|
|
|
|
|
|
const isCashInBaseCurrency = |
|
|
|
|
|
item.assetSubClass === AssetSubClass.CASH && |
|
|
|
|
|
item.currency === this.currency; |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
currentValues, |
|
|
currentValues, |
|
|
currentValuesWithCurrencyEffect, |
|
|
currentValuesWithCurrencyEffect, |
|
|
@ -396,17 +401,31 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
|
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors; |
|
|
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors; |
|
|
|
|
|
|
|
|
valuesBySymbol[item.symbol] = { |
|
|
// Cash in the base currency cannot generate a currency effect and thus
|
|
|
currentValues, |
|
|
// contributes nothing but its balance to the performance calculation
|
|
|
currentValuesWithCurrencyEffect, |
|
|
valuesBySymbol[item.symbol] = isCashInBaseCurrency |
|
|
investmentValuesAccumulated, |
|
|
? { |
|
|
investmentValuesAccumulatedWithCurrencyEffect, |
|
|
currentValues, |
|
|
investmentValuesWithCurrencyEffect, |
|
|
currentValuesWithCurrencyEffect, |
|
|
netPerformanceValues, |
|
|
investmentValuesAccumulated: {}, |
|
|
netPerformanceValuesWithCurrencyEffect, |
|
|
investmentValuesAccumulatedWithCurrencyEffect: {}, |
|
|
timeWeightedInvestmentValues, |
|
|
investmentValuesWithCurrencyEffect: {}, |
|
|
timeWeightedInvestmentValuesWithCurrencyEffect |
|
|
netPerformanceValues: {}, |
|
|
}; |
|
|
netPerformanceValuesWithCurrencyEffect: {}, |
|
|
|
|
|
timeWeightedInvestmentValues: {}, |
|
|
|
|
|
timeWeightedInvestmentValuesWithCurrencyEffect: {} |
|
|
|
|
|
} |
|
|
|
|
|
: { |
|
|
|
|
|
currentValues, |
|
|
|
|
|
currentValuesWithCurrencyEffect, |
|
|
|
|
|
investmentValuesAccumulated, |
|
|
|
|
|
investmentValuesAccumulatedWithCurrencyEffect, |
|
|
|
|
|
investmentValuesWithCurrencyEffect, |
|
|
|
|
|
netPerformanceValues, |
|
|
|
|
|
netPerformanceValuesWithCurrencyEffect, |
|
|
|
|
|
timeWeightedInvestmentValues, |
|
|
|
|
|
timeWeightedInvestmentValuesWithCurrencyEffect |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
positions.push({ |
|
|
positions.push({ |
|
|
timeWeightedInvestment, |
|
|
timeWeightedInvestment, |
|
|
@ -431,6 +450,7 @@ export abstract class PortfolioCalculator { |
|
|
? (grossPerformanceWithCurrencyEffect ?? null) |
|
|
? (grossPerformanceWithCurrencyEffect ?? null) |
|
|
: null, |
|
|
: null, |
|
|
includeInHoldings: item.includeInHoldings, |
|
|
includeInHoldings: item.includeInHoldings, |
|
|
|
|
|
includeInPerformance: !isCashInBaseCurrency, |
|
|
investment: totalInvestment, |
|
|
investment: totalInvestment, |
|
|
investmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect, |
|
|
investmentWithCurrencyEffect: totalInvestmentWithCurrencyEffect, |
|
|
marketPrice: |
|
|
marketPrice: |
|
|
@ -619,7 +639,7 @@ export abstract class PortfolioCalculator { |
|
|
return includeInHoldings; |
|
|
return includeInHoldings; |
|
|
}) |
|
|
}) |
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
.map(({ includeInHoldings, ...rest }) => { |
|
|
.map(({ includeInHoldings, includeInPerformance, ...rest }) => { |
|
|
return rest; |
|
|
return rest; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|