Browse Source

chore: Use protected instead of private methods for logging

pull/5027/head
Dan 1 year ago
parent
commit
17078aeafd
  1. 24
      apps/api/src/app/portfolio/calculator/constantPortfolioReturn/portfolio-calculator.ts
  2. 7
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  3. 14
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

24
apps/api/src/app/portfolio/calculator/constantPortfolioReturn/portfolio-calculator.ts

@ -197,7 +197,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private async getTimeWeightedChartData({ protected async getTimeWeightedChartData({
dates dates
}: { }: {
dates?: Date[]; dates?: Date[];
@ -301,7 +301,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private async handleSingleHolding( protected async handleSingleHolding(
previousDate: string, previousDate: string,
holding: string, holding: string,
date: string, date: string,
@ -387,12 +387,12 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private getCurrency(symbol: string) { protected getCurrency(symbol: string) {
return this.getCurrencyFromActivities(this.activities, symbol); return this.getCurrencyFromActivities(this.activities, symbol);
} }
@LogPerformance @LogPerformance
private getCurrencyFromActivities( protected getCurrencyFromActivities(
activities: PortfolioOrder[], activities: PortfolioOrder[],
symbol: string symbol: string
) { ) {
@ -406,7 +406,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private async getHoldings( protected async getHoldings(
activities: PortfolioOrder[], activities: PortfolioOrder[],
start: Date, start: Date,
end: Date end: Date
@ -428,7 +428,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private async computeHoldings( protected async computeHoldings(
activities: PortfolioOrder[], activities: PortfolioOrder[],
start: Date, start: Date,
end: Date end: Date
@ -473,7 +473,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private calculateInitialHoldings( protected calculateInitialHoldings(
investmentByDate: { [date: string]: PortfolioOrder[] }, investmentByDate: { [date: string]: PortfolioOrder[] },
start: Date, start: Date,
currentHoldings: { [date: string]: { [symbol: string]: Big } } currentHoldings: { [date: string]: { [symbol: string]: Big } }
@ -504,7 +504,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private getInvestmentByDate(activities: PortfolioOrder[]): { protected getInvestmentByDate(activities: PortfolioOrder[]): {
[date: string]: PortfolioOrder[]; [date: string]: PortfolioOrder[];
} { } {
return activities.reduce((groupedByDate, order) => { return activities.reduce((groupedByDate, order) => {
@ -519,7 +519,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private mapToDataGatheringItems( protected mapToDataGatheringItems(
orders: PortfolioOrder[] orders: PortfolioOrder[]
): IDataGatheringItem[] { ): IDataGatheringItem[] {
return orders return orders
@ -536,7 +536,7 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private async computeMarketMap(dateQuery: DateQuery): Promise<{ protected async computeMarketMap(dateQuery: DateQuery): Promise<{
[date: string]: { [symbol: string]: Big }; [date: string]: { [symbol: string]: Big };
}> { }> {
const dataGatheringItems: IDataGatheringItem[] = const dataGatheringItems: IDataGatheringItem[] =
@ -568,7 +568,9 @@ export class CPRPortfolioCalculator extends TWRPortfolioCalculator {
} }
@LogPerformance @LogPerformance
private activitiesToPortfolioOrder(activities: Activity[]): PortfolioOrder[] { protected activitiesToPortfolioOrder(
activities: Activity[]
): PortfolioOrder[] {
return activities return activities
.map( .map(
({ ({

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

@ -926,13 +926,15 @@ export abstract class PortfolioCalculator {
return this.transactionPoints; return this.transactionPoints;
} }
@LogPerformance
public async getValuablesInBaseCurrency() { public async getValuablesInBaseCurrency() {
await this.snapshotPromise; await this.snapshotPromise;
return this.snapshot.totalValuablesWithCurrencyEffect; return this.snapshot.totalValuablesWithCurrencyEffect;
} }
private computeTransactionPoints() { @LogPerformance
protected computeTransactionPoints() {
this.transactionPoints = []; this.transactionPoints = [];
const symbols: { [symbol: string]: TransactionPointSymbol } = {}; const symbols: { [symbol: string]: TransactionPointSymbol } = {};
@ -1070,7 +1072,8 @@ export abstract class PortfolioCalculator {
} }
} }
private async initialize() { @LogPerformance
protected async initialize() {
if (this.useCache) { if (this.useCache) {
const startTimeTotal = performance.now(); const startTimeTotal = performance.now();

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

@ -632,7 +632,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private handleOrders( protected handleOrders(
orders: PortfolioOrderItem[], orders: PortfolioOrderItem[],
exchangeRates: { [dateString: string]: number }, exchangeRates: { [dateString: string]: number },
totalDividend, totalDividend,
@ -986,7 +986,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private calculateTimeWeightedInvestments( protected calculateTimeWeightedInvestments(
valueOfInvestmentBeforeTransaction: any, valueOfInvestmentBeforeTransaction: any,
order: PortfolioOrderItem, order: PortfolioOrderItem,
orders: PortfolioOrderItem[], orders: PortfolioOrderItem[],
@ -1102,7 +1102,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private calculatePerformances( protected calculatePerformances(
order: PortfolioOrderItem, order: PortfolioOrderItem,
lastAveragePrice: any, lastAveragePrice: any,
lastAveragePriceWithCurrencyEffect: any, lastAveragePriceWithCurrencyEffect: any,
@ -1187,7 +1187,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private calculateInvestmentValues( protected calculateInvestmentValues(
totalInvestment: any, totalInvestment: any,
totalInvestmentWithCurrencyEffect: any, totalInvestmentWithCurrencyEffect: any,
transactionInvestment, transactionInvestment,
@ -1260,7 +1260,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private handleBuyAndSellOrders( protected handleBuyAndSellOrders(
order: PortfolioOrderItem, order: PortfolioOrderItem,
transactionInvestment, transactionInvestment,
transactionInvestmentWithCurrencyEffect, transactionInvestmentWithCurrencyEffect,
@ -1314,7 +1314,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private handleOrderType( protected handleOrderType(
order: PortfolioOrderItem, order: PortfolioOrderItem,
totalDividend: any, totalDividend: any,
totalDividendInBaseCurrency: any, totalDividendInBaseCurrency: any,
@ -1368,7 +1368,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
} }
@LogPerformance @LogPerformance
private handleIsChartMode( protected handleIsChartMode(
isChartMode: boolean, isChartMode: boolean,
orders: PortfolioOrderItem[], orders: PortfolioOrderItem[],
day: Date, day: Date,

Loading…
Cancel
Save