|
@ -58,6 +58,7 @@ export class PortfolioCalculator { |
|
|
.plus(oldAccumulatedSymbol.quantity); |
|
|
.plus(oldAccumulatedSymbol.quantity); |
|
|
currentTransactionPointItem = { |
|
|
currentTransactionPointItem = { |
|
|
currency: order.currency, |
|
|
currency: order.currency, |
|
|
|
|
|
fee: order.fee, |
|
|
firstBuyDate: oldAccumulatedSymbol.firstBuyDate, |
|
|
firstBuyDate: oldAccumulatedSymbol.firstBuyDate, |
|
|
investment: newQuantity.eq(0) |
|
|
investment: newQuantity.eq(0) |
|
|
? new Big(0) |
|
|
? new Big(0) |
|
@ -67,17 +68,16 @@ export class PortfolioCalculator { |
|
|
.add(oldAccumulatedSymbol.investment), |
|
|
.add(oldAccumulatedSymbol.investment), |
|
|
quantity: newQuantity, |
|
|
quantity: newQuantity, |
|
|
symbol: order.symbol, |
|
|
symbol: order.symbol, |
|
|
fee: order.fee, |
|
|
|
|
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1 |
|
|
transactionCount: oldAccumulatedSymbol.transactionCount + 1 |
|
|
}; |
|
|
}; |
|
|
} else { |
|
|
} else { |
|
|
currentTransactionPointItem = { |
|
|
currentTransactionPointItem = { |
|
|
currency: order.currency, |
|
|
currency: order.currency, |
|
|
|
|
|
fee: order.fee, |
|
|
firstBuyDate: order.date, |
|
|
firstBuyDate: order.date, |
|
|
investment: unitPrice.mul(order.quantity).mul(factor), |
|
|
investment: unitPrice.mul(order.quantity).mul(factor), |
|
|
quantity: order.quantity.mul(factor), |
|
|
quantity: order.quantity.mul(factor), |
|
|
symbol: order.symbol, |
|
|
symbol: order.symbol, |
|
|
fee: order.fee, |
|
|
|
|
|
transactionCount: 1 |
|
|
transactionCount: 1 |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
@ -119,13 +119,13 @@ export class PortfolioCalculator { |
|
|
public async getCurrentPositions(start: Date): Promise<CurrentPositions> { |
|
|
public async getCurrentPositions(start: Date): Promise<CurrentPositions> { |
|
|
if (!this.transactionPoints?.length) { |
|
|
if (!this.transactionPoints?.length) { |
|
|
return { |
|
|
return { |
|
|
|
|
|
currentValue: new Big(0), |
|
|
hasErrors: false, |
|
|
hasErrors: false, |
|
|
positions: [], |
|
|
|
|
|
grossPerformance: new Big(0), |
|
|
grossPerformance: new Big(0), |
|
|
grossPerformancePercentage: new Big(0), |
|
|
grossPerformancePercentage: new Big(0), |
|
|
netPerformance: new Big(0), |
|
|
netPerformance: new Big(0), |
|
|
netPerformancePercentage: new Big(0), |
|
|
netPerformancePercentage: new Big(0), |
|
|
currentValue: new Big(0), |
|
|
positions: [], |
|
|
totalInvestment: new Big(0) |
|
|
totalInvestment: new Big(0) |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
@ -300,13 +300,13 @@ export class PortfolioCalculator { |
|
|
isValid && holdingPeriodReturns[item.symbol] |
|
|
isValid && holdingPeriodReturns[item.symbol] |
|
|
? holdingPeriodReturns[item.symbol].minus(1) |
|
|
? holdingPeriodReturns[item.symbol].minus(1) |
|
|
: null, |
|
|
: null, |
|
|
|
|
|
investment: item.investment, |
|
|
|
|
|
marketPrice: marketValue?.toNumber() ?? null, |
|
|
netPerformance: isValid ? netPerformance[item.symbol] ?? null : null, |
|
|
netPerformance: isValid ? netPerformance[item.symbol] ?? null : null, |
|
|
netPerformancePercentage: |
|
|
netPerformancePercentage: |
|
|
isValid && netHoldingPeriodReturns[item.symbol] |
|
|
isValid && netHoldingPeriodReturns[item.symbol] |
|
|
? netHoldingPeriodReturns[item.symbol].minus(1) |
|
|
? netHoldingPeriodReturns[item.symbol].minus(1) |
|
|
: null, |
|
|
: null, |
|
|
investment: item.investment, |
|
|
|
|
|
marketPrice: marketValue?.toNumber() ?? null, |
|
|
|
|
|
quantity: item.quantity, |
|
|
quantity: item.quantity, |
|
|
symbol: item.symbol, |
|
|
symbol: item.symbol, |
|
|
transactionCount: item.transactionCount |
|
|
transactionCount: item.transactionCount |
|
@ -461,9 +461,9 @@ export class PortfolioCalculator { |
|
|
currentValue, |
|
|
currentValue, |
|
|
grossPerformance, |
|
|
grossPerformance, |
|
|
grossPerformancePercentage, |
|
|
grossPerformancePercentage, |
|
|
|
|
|
hasErrors, |
|
|
netPerformance, |
|
|
netPerformance, |
|
|
netPerformancePercentage, |
|
|
netPerformancePercentage, |
|
|
hasErrors, |
|
|
|
|
|
totalInvestment |
|
|
totalInvestment |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|