Browse Source

Improve handling of excluded holdings

pull/7828/head
Thomas Kaul 2 days ago
parent
commit
0cd70fdc35
  1. 14
      apps/api/src/app/portfolio/calculator/portfolio-calculator.factory.ts
  2. 8
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  3. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts

14
apps/api/src/app/portfolio/calculator/portfolio-calculator.factory.ts

@ -34,16 +34,16 @@ export class PortfolioCalculatorFactory {
calculationType, calculationType,
currency, currency,
filters = [], filters = [],
userId, usePortfolioSnapshotCache = true,
usePortfolioSnapshotCache = true userId
}: { }: {
accountBalanceItems?: HistoricalDataItem[]; accountBalanceItems?: HistoricalDataItem[];
activities: Activity[]; activities: Activity[];
calculationType: PerformanceCalculationType; calculationType: PerformanceCalculationType;
currency: string; currency: string;
filters?: Filter[]; filters?: Filter[];
userId: string;
usePortfolioSnapshotCache?: boolean; usePortfolioSnapshotCache?: boolean;
userId: string;
}): PortfolioCalculator { }): PortfolioCalculator {
switch (calculationType) { switch (calculationType) {
case PerformanceCalculationType.MWR: case PerformanceCalculationType.MWR:
@ -52,8 +52,8 @@ export class PortfolioCalculatorFactory {
activities, activities,
currency, currency,
filters, filters,
userId,
usePortfolioSnapshotCache, usePortfolioSnapshotCache,
userId,
configurationService: this.configurationService, configurationService: this.configurationService,
currentRateService: this.currentRateService, currentRateService: this.currentRateService,
exchangeRateDataService: this.exchangeRateDataService, exchangeRateDataService: this.exchangeRateDataService,
@ -67,8 +67,8 @@ export class PortfolioCalculatorFactory {
activities, activities,
currency, currency,
filters, filters,
userId,
usePortfolioSnapshotCache, usePortfolioSnapshotCache,
userId,
configurationService: this.configurationService, configurationService: this.configurationService,
currentRateService: this.currentRateService, currentRateService: this.currentRateService,
exchangeRateDataService: this.exchangeRateDataService, exchangeRateDataService: this.exchangeRateDataService,
@ -82,8 +82,8 @@ export class PortfolioCalculatorFactory {
activities, activities,
currency, currency,
filters, filters,
userId,
usePortfolioSnapshotCache, usePortfolioSnapshotCache,
userId,
configurationService: this.configurationService, configurationService: this.configurationService,
currentRateService: this.currentRateService, currentRateService: this.currentRateService,
exchangeRateDataService: this.exchangeRateDataService, exchangeRateDataService: this.exchangeRateDataService,
@ -97,8 +97,8 @@ export class PortfolioCalculatorFactory {
activities, activities,
currency, currency,
filters, filters,
userId,
usePortfolioSnapshotCache, usePortfolioSnapshotCache,
userId,
configurationService: this.configurationService, configurationService: this.configurationService,
currentRateService: this.currentRateService, currentRateService: this.currentRateService,
exchangeRateDataService: this.exchangeRateDataService, exchangeRateDataService: this.exchangeRateDataService,

8
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -90,8 +90,8 @@ export abstract class PortfolioCalculator {
private snapshotPromise: Promise<void>; private snapshotPromise: Promise<void>;
private startDate: Date; private startDate: Date;
private transactionPoints: TransactionPoint[]; private transactionPoints: TransactionPoint[];
private userId: string;
private usePortfolioSnapshotCache: boolean; private usePortfolioSnapshotCache: boolean;
private userId: string;
public constructor({ public constructor({
accountBalanceItems, accountBalanceItems,
@ -103,8 +103,8 @@ export abstract class PortfolioCalculator {
filters, filters,
portfolioSnapshotService, portfolioSnapshotService,
redisCacheService, redisCacheService,
userId, usePortfolioSnapshotCache = true,
usePortfolioSnapshotCache = true userId
}: { }: {
accountBalanceItems: HistoricalDataItem[]; accountBalanceItems: HistoricalDataItem[];
activities: Activity[]; activities: Activity[];
@ -115,8 +115,8 @@ export abstract class PortfolioCalculator {
filters: Filter[]; filters: Filter[];
portfolioSnapshotService: PortfolioSnapshotService; portfolioSnapshotService: PortfolioSnapshotService;
redisCacheService: RedisCacheService; redisCacheService: RedisCacheService;
userId: string;
usePortfolioSnapshotCache?: boolean; usePortfolioSnapshotCache?: boolean;
userId: string;
}) { }) {
this.accountBalanceItems = accountBalanceItems; this.accountBalanceItems = accountBalanceItems;
this.configurationService = configurationService; this.configurationService = configurationService;

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts

@ -108,8 +108,8 @@ describe('PortfolioCalculator', () => {
activities, activities,
calculationType: PerformanceCalculationType.ROAI, calculationType: PerformanceCalculationType.ROAI,
currency: 'USD', currency: 'USD',
userId: userDummyData.id, usePortfolioSnapshotCache: false,
usePortfolioSnapshotCache: false userId: userDummyData.id
}); });
const portfolioSnapshot = await portfolioCalculator.getSnapshot(); const portfolioSnapshot = await portfolioCalculator.getSnapshot();

Loading…
Cancel
Save