Browse Source

Remove performances from snapshot

pull/3393/head
Thomas Kaul 1 year ago
parent
commit
a5686c1754
  1. 8
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 22
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts
  3. 46
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 40
      libs/common/src/lib/models/portfolio-snapshot.ts

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

@ -159,16 +159,8 @@ export abstract class PortfolioCalculator {
if (!transactionPoints.length) { if (!transactionPoints.length) {
return { return {
currentValueInBaseCurrency: new Big(0), currentValueInBaseCurrency: new Big(0),
grossPerformance: new Big(0),
grossPerformancePercentage: new Big(0),
grossPerformancePercentageWithCurrencyEffect: new Big(0),
grossPerformanceWithCurrencyEffect: new Big(0),
hasErrors: false, hasErrors: false,
historicalData: [], historicalData: [],
netPerformance: new Big(0),
netPerformancePercentage: new Big(0),
netPerformancePercentageWithCurrencyEffect: new Big(0),
netPerformanceWithCurrencyEffect: new Big(0),
positions: [], positions: [],
totalFeesWithCurrencyEffect: new Big(0), totalFeesWithCurrencyEffect: new Big(0),
totalInterestWithCurrencyEffect: new Big(0), totalInterestWithCurrencyEffect: new Big(0),

22
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

@ -106,35 +106,13 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
return { return {
currentValueInBaseCurrency, currentValueInBaseCurrency,
grossPerformance,
grossPerformanceWithCurrencyEffect,
hasErrors, hasErrors,
netPerformance,
netPerformanceWithCurrencyEffect,
positions, positions,
totalFeesWithCurrencyEffect, totalFeesWithCurrencyEffect,
totalInterestWithCurrencyEffect, totalInterestWithCurrencyEffect,
totalInvestment, totalInvestment,
totalInvestmentWithCurrencyEffect, totalInvestmentWithCurrencyEffect,
historicalData: [], historicalData: [],
netPerformancePercentage: totalTimeWeightedInvestment.eq(0)
? new Big(0)
: netPerformance.div(totalTimeWeightedInvestment),
netPerformancePercentageWithCurrencyEffect:
totalTimeWeightedInvestmentWithCurrencyEffect.eq(0)
? new Big(0)
: netPerformanceWithCurrencyEffect.div(
totalTimeWeightedInvestmentWithCurrencyEffect
),
grossPerformancePercentage: totalTimeWeightedInvestment.eq(0)
? new Big(0)
: grossPerformance.div(totalTimeWeightedInvestment),
grossPerformancePercentageWithCurrencyEffect:
totalTimeWeightedInvestmentWithCurrencyEffect.eq(0)
? new Big(0)
: grossPerformanceWithCurrencyEffect.div(
totalTimeWeightedInvestmentWithCurrencyEffect
),
totalLiabilitiesWithCurrencyEffect: new Big(0), totalLiabilitiesWithCurrencyEffect: new Big(0),
totalValuablesWithCurrencyEffect: new Big(0) totalValuablesWithCurrencyEffect: new Big(0)
}; };

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

@ -1588,18 +1588,27 @@ export class PortfolioService {
} }
} }
const { currentValueInBaseCurrency, totalInvestment } =
await portfolioCalculator.getSnapshot();
const { performance } = await this.getPerformance({
impersonationId,
userId
});
console.log(performance);
const { const {
currentValueInBaseCurrency, // TODO
grossPerformance, // grossPerformance,
grossPerformancePercentage, // grossPerformancePercentage,
grossPerformancePercentageWithCurrencyEffect, // grossPerformancePercentageWithCurrencyEffect,
grossPerformanceWithCurrencyEffect, // grossPerformanceWithCurrencyEffect,
netPerformance, netPerformance,
netPerformancePercentage, netPerformancePercentage,
netPerformancePercentageWithCurrencyEffect, netPerformancePercentageWithCurrencyEffect,
netPerformanceWithCurrencyEffect, netPerformanceWithCurrencyEffect
totalInvestment } = performance;
} = await portfolioCalculator.getSnapshot();
const dividendInBaseCurrency = const dividendInBaseCurrency =
await portfolioCalculator.getDividendInBaseCurrency(); await portfolioCalculator.getDividendInBaseCurrency();
@ -1696,6 +1705,10 @@ export class PortfolioService {
cash, cash,
excludedAccountsAndActivities, excludedAccountsAndActivities,
firstOrderDate, firstOrderDate,
netPerformance,
netPerformancePercentage,
netPerformancePercentageWithCurrencyEffect,
netPerformanceWithCurrencyEffect,
totalBuy, totalBuy,
totalSell, totalSell,
committedFunds: committedFunds.toNumber(), committedFunds: committedFunds.toNumber(),
@ -1716,21 +1729,14 @@ export class PortfolioService {
fireWealth: new Big(currentValueInBaseCurrency) fireWealth: new Big(currentValueInBaseCurrency)
.minus(emergencyFundPositionsValueInBaseCurrency) .minus(emergencyFundPositionsValueInBaseCurrency)
.toNumber(), .toNumber(),
grossPerformance: grossPerformance.toNumber(), // TODO
grossPerformancePercentage: grossPerformancePercentage.toNumber(), grossPerformance: 0,
grossPerformancePercentageWithCurrencyEffect: grossPerformancePercentage: 0,
grossPerformancePercentageWithCurrencyEffect.toNumber(), grossPerformancePercentageWithCurrencyEffect: 0,
grossPerformanceWithCurrencyEffect: grossPerformanceWithCurrencyEffect: 0,
grossPerformanceWithCurrencyEffect.toNumber(),
interest: interest.toNumber(), interest: interest.toNumber(),
items: valuables.toNumber(), items: valuables.toNumber(),
liabilities: liabilities.toNumber(), liabilities: liabilities.toNumber(),
netPerformance: netPerformance.toNumber(),
netPerformancePercentage: netPerformancePercentage.toNumber(),
netPerformancePercentageWithCurrencyEffect:
netPerformancePercentageWithCurrencyEffect.toNumber(),
netPerformanceWithCurrencyEffect:
netPerformanceWithCurrencyEffect.toNumber(),
ordersCount: activities.filter(({ type }) => { ordersCount: activities.filter(({ type }) => {
return ['BUY', 'SELL'].includes(type); return ['BUY', 'SELL'].includes(type);
}).length, }).length,

40
libs/common/src/lib/models/portfolio-snapshot.ts

@ -15,50 +15,10 @@ export class PortfolioSnapshot {
errors?: AssetProfileIdentifier[]; errors?: AssetProfileIdentifier[];
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
grossPerformance: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
grossPerformanceWithCurrencyEffect: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
grossPerformancePercentage: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
grossPerformancePercentageWithCurrencyEffect: Big;
hasErrors: boolean; hasErrors: boolean;
historicalData: HistoricalDataItem[]; historicalData: HistoricalDataItem[];
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netAnnualizedPerformance?: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netAnnualizedPerformanceWithCurrencyEffect?: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netPerformance: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netPerformanceWithCurrencyEffect: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netPerformancePercentage: Big;
@Transform(transformToBig, { toClassOnly: true })
@Type(() => Big)
netPerformancePercentageWithCurrencyEffect: Big;
@Type(() => TimelinePosition) @Type(() => TimelinePosition)
positions: TimelinePosition[]; positions: TimelinePosition[];

Loading…
Cancel
Save