|
@ -13,7 +13,6 @@ import { |
|
|
import { GroupBy } from '@ghostfolio/common/types'; |
|
|
import { GroupBy } from '@ghostfolio/common/types'; |
|
|
|
|
|
|
|
|
import { Logger } from '@nestjs/common'; |
|
|
import { Logger } from '@nestjs/common'; |
|
|
import { Type as ActivityType } from '@prisma/client'; |
|
|
|
|
|
import Big from 'big.js'; |
|
|
import Big from 'big.js'; |
|
|
import { |
|
|
import { |
|
|
addDays, |
|
|
addDays, |
|
@ -971,7 +970,7 @@ export class PortfolioCalculator { |
|
|
itemType: 'start', |
|
|
itemType: 'start', |
|
|
name: '', |
|
|
name: '', |
|
|
quantity: new Big(0), |
|
|
quantity: new Big(0), |
|
|
type: ActivityType.BUY, |
|
|
type: 'BUY', |
|
|
unitPrice: unitPriceAtStartDate |
|
|
unitPrice: unitPriceAtStartDate |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -985,7 +984,7 @@ export class PortfolioCalculator { |
|
|
itemType: 'end', |
|
|
itemType: 'end', |
|
|
name: '', |
|
|
name: '', |
|
|
quantity: new Big(0), |
|
|
quantity: new Big(0), |
|
|
type: ActivityType.BUY, |
|
|
type: 'BUY', |
|
|
unitPrice: unitPriceAtEndDate |
|
|
unitPrice: unitPriceAtEndDate |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -1012,7 +1011,7 @@ export class PortfolioCalculator { |
|
|
feeInBaseCurrency: new Big(0), |
|
|
feeInBaseCurrency: new Big(0), |
|
|
name: '', |
|
|
name: '', |
|
|
quantity: new Big(0), |
|
|
quantity: new Big(0), |
|
|
type: ActivityType.BUY, |
|
|
type: 'BUY', |
|
|
unitPrice: |
|
|
unitPrice: |
|
|
marketSymbolMap[format(day, DATE_FORMAT)]?.[symbol] ?? |
|
|
marketSymbolMap[format(day, DATE_FORMAT)]?.[symbol] ?? |
|
|
lastUnitPrice |
|
|
lastUnitPrice |
|
@ -1194,14 +1193,14 @@ export class PortfolioCalculator { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const grossPerformanceFromSell = |
|
|
const grossPerformanceFromSell = |
|
|
order.type === ActivityType.SELL |
|
|
order.type === 'SELL' |
|
|
? order.unitPriceInBaseCurrency |
|
|
? order.unitPriceInBaseCurrency |
|
|
.minus(lastAveragePrice) |
|
|
.minus(lastAveragePrice) |
|
|
.mul(order.quantity) |
|
|
.mul(order.quantity) |
|
|
: new Big(0); |
|
|
: new Big(0); |
|
|
|
|
|
|
|
|
const grossPerformanceFromSellWithCurrencyEffect = |
|
|
const grossPerformanceFromSellWithCurrencyEffect = |
|
|
order.type === ActivityType.SELL |
|
|
order.type === 'SELL' |
|
|
? order.unitPriceInBaseCurrencyWithCurrencyEffect |
|
|
? order.unitPriceInBaseCurrencyWithCurrencyEffect |
|
|
.minus(lastAveragePriceWithCurrencyEffect) |
|
|
.minus(lastAveragePriceWithCurrencyEffect) |
|
|
.mul(order.quantity) |
|
|
.mul(order.quantity) |
|
|