Browse Source

Merge 1c56d9a644 into d1351b4665

pull/4793/merge
bptrgx 1 week ago
committed by GitHub
parent
commit
4046c18c3d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 34
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator.ts
  2. 5
      apps/api/src/app/portfolio/portfolio.service.ts
  3. 21
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

34
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator.ts

@ -554,6 +554,16 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
initialValueWithCurrencyEffect =
transactionInvestmentWithCurrencyEffect;
} else if (
order.quantity.gt(0) &&
['BUY', 'SELL'].includes(order.type) &&
!order.itemType
) {
initialValue = order.quantity.mul(marketPriceInBaseCurrency);
initialValueWithCurrencyEffect = order.quantity.mul(
marketPriceInBaseCurrencyWithCurrencyEffect
);
}
}
@ -783,7 +793,9 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
? totalGrossPerformance.div(
timeWeightedAverageInvestmentBetweenStartAndEndDate
)
: new Big(0);
: totalGrossPerformance
? new Big(1)
: new Big(0);
const grossPerformancePercentageWithCurrencyEffect =
timeWeightedAverageInvestmentBetweenStartAndEndDateWithCurrencyEffect.gt(
@ -792,7 +804,9 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
? totalGrossPerformanceWithCurrencyEffect.div(
timeWeightedAverageInvestmentBetweenStartAndEndDateWithCurrencyEffect
)
: new Big(0);
: totalGrossPerformanceWithCurrencyEffect
? new Big(1)
: new Big(0);
const feesPerUnit = totalUnits.gt(0)
? fees.minus(feesAtStartDate).div(totalUnits)
@ -809,7 +823,9 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
? totalNetPerformance.div(
timeWeightedAverageInvestmentBetweenStartAndEndDate
)
: new Big(0);
: totalNetPerformance
? new Big(1)
: new Big(0);
const netPerformancePercentageWithCurrencyEffectMap: {
[key: DateRange]: Big;
@ -902,7 +918,9 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0)
? netPerformanceWithCurrencyEffectMap[dateRange].div(average)
: new Big(0);
: netPerformanceWithCurrencyEffectMap[dateRange]
? new Big(1)
: new Big(0);
}
if (PortfolioCalculator.ENABLE_LOGGING) {
@ -938,9 +956,11 @@ export class RoaiPortfolioCalculator extends PortfolioCalculator {
Net performance: ${totalNetPerformance.toFixed(
2
)} / ${netPerformancePercentage.mul(100).toFixed(2)}%
Net performance with currency effect: ${netPerformancePercentageWithCurrencyEffectMap[
'max'
].toFixed(2)}%`
Net performance with currency effect: ${netPerformanceValuesWithCurrencyEffect[
endDateString
].toFixed(2)} / ${netPerformancePercentageWithCurrencyEffectMap['max']
.mul(100)
.toFixed(2)}%`
);
}

5
apps/api/src/app/portfolio/portfolio.service.ts

@ -798,10 +798,7 @@ export class PortfolioService {
historicalDataArray.push({
date,
averagePrice: currentAveragePrice,
marketPrice:
historicalDataArray.length > 0
? marketPrice
: currentAveragePrice,
marketPrice,
quantity: currentQuantity
});

21
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -275,11 +275,13 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
SymbolProfile?.userId === this.user?.id;
this.historicalDataItems = historicalData.map(
({ averagePrice, date, marketPrice }) => {
this.benchmarkDataItems.push({
date,
value: averagePrice
});
({ averagePrice, date, marketPrice, quantity }) => {
if (quantity) {
this.benchmarkDataItems.push({
date,
value: averagePrice
});
}
return {
date,
@ -429,15 +431,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
this.benchmarkDataItems[0].value = this.averagePrice;
}
this.benchmarkDataItems = this.benchmarkDataItems.map(
({ date, value }) => {
return {
date,
value: value === 0 ? null : value
};
}
);
if (this.hasPermissionToReadMarketDataOfOwnAssetProfile) {
this.fetchMarketData();
}

Loading…
Cancel
Save