Browse Source

Fix invested capital of ROI portfolio calculator and guard performance calculation type

pull/7993/head
Thomas Kaul 8 hours ago
parent
commit
0411820662
  1. 17
      apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts
  2. 6
      apps/api/src/app/user/user.controller.ts

17
apps/api/src/app/portfolio/calculator/roi/portfolio-calculator.ts

@ -35,7 +35,9 @@ import {
* time weighting. * time weighting.
* *
* The invested capital of a holding is the sum of its buy amounts. It fills the * The invested capital of a holding is the sum of its buy amounts. It fills the
* average investment fields of the holding performance. * average investment of the holding performance. The average investment values
* per date stay empty, because the invested capital of the portfolio is not the
* sum of the holdings.
* *
* The invested capital of the portfolio is the sum of the positive net * The invested capital of the portfolio is the sum of the positive net
* investment changes from date to date. Thus money which moves from one holding * investment changes from date to date. Thus money which moves from one holding
@ -333,9 +335,6 @@ export class RoiPortfolioCalculator extends PortfolioCalculator {
}; };
start: Date; start: Date;
} & AssetProfileIdentifier): HoldingPerformance { } & AssetProfileIdentifier): HoldingPerformance {
const investedCapitalValues: { [date: string]: Big } = {};
const investedCapitalValuesWithCurrencyEffect: { [date: string]: Big } = {};
const assetProfileIdentifier = getAssetProfileIdentifier({ const assetProfileIdentifier = getAssetProfileIdentifier({
dataSource, dataSource,
symbol symbol
@ -454,11 +453,6 @@ export class RoiPortfolioCalculator extends PortfolioCalculator {
item.transactionInvestmentWithCurrencyEffect item.transactionInvestmentWithCurrencyEffect
); );
} }
investedCapitalValues[item.date] = investedCapital;
investedCapitalValuesWithCurrencyEffect[item.date] =
investedCapitalWithCurrencyEffect;
} }
const { const {
@ -617,9 +611,8 @@ export class RoiPortfolioCalculator extends PortfolioCalculator {
totalInvestmentWithCurrencyEffect, totalInvestmentWithCurrencyEffect,
totalLiabilitiesInBaseCurrency, totalLiabilitiesInBaseCurrency,
averageInvestment: investedCapital, averageInvestment: investedCapital,
averageInvestmentValues: investedCapitalValues, averageInvestmentValues: {},
averageInvestmentValuesWithCurrencyEffect: averageInvestmentValuesWithCurrencyEffect: {},
investedCapitalValuesWithCurrencyEffect,
averageInvestmentWithCurrencyEffect: investedCapitalWithCurrencyEffect, averageInvestmentWithCurrencyEffect: investedCapitalWithCurrencyEffect,
grossPerformance: totalGrossPerformance, grossPerformance: totalGrossPerformance,
grossPerformanceWithCurrencyEffect: grossPerformanceWithCurrencyEffect:

6
apps/api/src/app/user/user.controller.ts

@ -242,6 +242,12 @@ export class UserController {
if (!userSettings.isExperimentalFeatures) { if (!userSettings.isExperimentalFeatures) {
delete userSettings.isGhostfolioAiEnabled; delete userSettings.isGhostfolioAiEnabled;
}
if (
!userSettings.isExperimentalFeatures ||
this.request.user.subscription
) {
delete userSettings.performanceCalculationType; delete userSettings.performanceCalculationType;
} }

Loading…
Cancel
Save