Browse Source

Updated various models, interfaces, and functions to include a 'createdAt' field, providing timestamp information for portfolio data.

pull/4350/head
Verbindolai 6 months ago
committed by Thomas Kaul
parent
commit
99938d1857
  1. 1
      apps/api/src/app/endpoints/public/public.controller.ts
  2. 1
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  3. 1
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts
  4. 7
      apps/api/src/app/portfolio/portfolio.service.ts
  5. 1
      libs/common/src/lib/interfaces/portfolio-performance.interface.ts
  6. 1
      libs/common/src/lib/interfaces/responses/public-portfolio-response.interface.ts
  7. 2
      libs/common/src/lib/models/portfolio-snapshot.ts

1
apps/api/src/app/endpoints/public/public.controller.ts

@ -84,6 +84,7 @@ export class PublicController {
hasDetails, hasDetails,
markets, markets,
alias: access.alias, alias: access.alias,
createdAt: performance1d.createdAt,
holdings: {}, holdings: {},
performance: { performance: {
'1d': { '1d': {

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

@ -177,6 +177,7 @@ export abstract class PortfolioCalculator {
return { return {
activitiesCount: 0, activitiesCount: 0,
currentValueInBaseCurrency: new Big(0), currentValueInBaseCurrency: new Big(0),
createdAt: new Date(),
errors: [], errors: [],
hasErrors: false, hasErrors: false,
historicalData: [], historicalData: [],

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

@ -94,6 +94,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
return { return {
createdAt: new Date(),
currentValueInBaseCurrency, currentValueInBaseCurrency,
hasErrors, hasErrors,
positions, positions,

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

@ -1100,6 +1100,7 @@ export class PortfolioService {
firstOrderDate: undefined, firstOrderDate: undefined,
hasErrors: false, hasErrors: false,
performance: { performance: {
createdAt: undefined,
currentNetWorth: 0, currentNetWorth: 0,
currentValueInBaseCurrency: 0, currentValueInBaseCurrency: 0,
netPerformance: 0, netPerformance: 0,
@ -1120,7 +1121,7 @@ export class PortfolioService {
currency: userCurrency currency: userCurrency
}); });
const { errors, hasErrors, historicalData } = const { createdAt, errors, hasErrors, historicalData } =
await portfolioCalculator.getSnapshot(); await portfolioCalculator.getSnapshot();
const { endDate, startDate } = getIntervalFromDateRange(dateRange); const { endDate, startDate } = getIntervalFromDateRange(dateRange);
@ -1157,6 +1158,7 @@ export class PortfolioService {
netPerformance, netPerformance,
netPerformanceWithCurrencyEffect, netPerformanceWithCurrencyEffect,
totalInvestment, totalInvestment,
createdAt: createdAt,
currentNetWorth: netWorth, currentNetWorth: netWorth,
currentValueInBaseCurrency: valueWithCurrencyEffect, currentValueInBaseCurrency: valueWithCurrencyEffect,
netPerformancePercentage: netPerformanceInPercentage, netPerformancePercentage: netPerformanceInPercentage,
@ -1809,7 +1811,7 @@ export class PortfolioService {
} }
} }
const { currentValueInBaseCurrency, totalInvestment } = const { createdAt, currentValueInBaseCurrency, totalInvestment } =
await portfolioCalculator.getSnapshot(); await portfolioCalculator.getSnapshot();
const { performance } = await this.getPerformance({ const { performance } = await this.getPerformance({
@ -1927,6 +1929,7 @@ export class PortfolioService {
totalSell, totalSell,
committedFunds: committedFunds.toNumber(), committedFunds: committedFunds.toNumber(),
currentValueInBaseCurrency: currentValueInBaseCurrency.toNumber(), currentValueInBaseCurrency: currentValueInBaseCurrency.toNumber(),
createdAt: createdAt,
dividendInBaseCurrency: dividendInBaseCurrency.toNumber(), dividendInBaseCurrency: dividendInBaseCurrency.toNumber(),
emergencyFund: { emergencyFund: {
assets: emergencyFundPositionsValueInBaseCurrency, assets: emergencyFundPositionsValueInBaseCurrency,

1
libs/common/src/lib/interfaces/portfolio-performance.interface.ts

@ -1,5 +1,6 @@
export interface PortfolioPerformance { export interface PortfolioPerformance {
annualizedPerformancePercent?: number; annualizedPerformancePercent?: number;
createdAt: Date;
currentNetWorth?: number; currentNetWorth?: number;
currentValueInBaseCurrency: number; currentValueInBaseCurrency: number;
netPerformance: number; netPerformance: number;

1
libs/common/src/lib/interfaces/responses/public-portfolio-response.interface.ts

@ -3,6 +3,7 @@ import { Market } from '../../types';
export interface PublicPortfolioResponse extends PublicPortfolioResponseV1 { export interface PublicPortfolioResponse extends PublicPortfolioResponseV1 {
alias?: string; alias?: string;
createdAt: Date;
hasDetails: boolean; hasDetails: boolean;
holdings: { holdings: {
[symbol: string]: Pick< [symbol: string]: Pick<

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

@ -11,6 +11,8 @@ import { Transform, Type } from 'class-transformer';
export class PortfolioSnapshot { export class PortfolioSnapshot {
activitiesCount: number; activitiesCount: number;
createdAt: Date;
@Transform(transformToBig, { toClassOnly: true }) @Transform(transformToBig, { toClassOnly: true })
@Type(() => Big) @Type(() => Big)
currentValueInBaseCurrency: Big; currentValueInBaseCurrency: Big;

Loading…
Cancel
Save