Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Refactoring

Thomas8571709014d9
diff --git a/apps/api/src/app/core/portfolio-calculator.ts b/apps/api/src/app/core/portfolio-calculator.ts
index f0cd0b5d2c..e0cd2633dd 100644
--- a/apps/api/src/app/core/portfolio-calculator.ts
+++ b/apps/api/src/app/core/portfolio-calculator.ts
@@ -103,14 +103,14 @@ export class PortfolioCalculator {
}
}
- public setTransactionPoints(transactionPoints: TransactionPoint[]) {
- this.transactionPoints = transactionPoints;
- }
-
public getTransactionPoints(): TransactionPoint[] {
return this.transactionPoints;
}
+ public setTransactionPoints(transactionPoints: TransactionPoint[]) {
+ this.transactionPoints = transactionPoints;
+ }
+
public async getCurrentPositions(start: Date): Promise<{
hasErrors: boolean;
positions: TimelinePosition[];
@@ -331,35 +331,6 @@ export class PortfolioCalculator {
return flatten(timelinePeriods);
}
- private async getMarketValues(
- transactionPoint: TransactionPoint,
- dateRangeStart: Date,
- dateRangeEnd: Date
- ) {
- const symbols: string[] = [];
- const currencies: { [symbol: string]: Currency } = {};
-
- for (const item of transactionPoint.items) {
- symbols.push(item.symbol);
- currencies[item.symbol] = item.currency;
- }
- const values = await this.currentRateService.getValues({
- dateQuery: {
- gte: dateRangeStart,
- lt: endOfDay(dateRangeEnd)
- },
- symbols,
- currencies,
- userCurrency: this.currency
- });
-
- const marketValues: { [symbol: string]: GetValueObject } = {};
- for (const value of values) {
- marketValues[value.symbol] = value;
- }
- return marketValues;
- }
-
private async getTimePeriodForDate(
j: number,
startDate: Date,
@@ -450,6 +421,7 @@ export class PortfolioCalculator {
private getFactor(type: OrderType) {
let factor: number;
+
switch (type) {
case OrderType.Buy:
factor = 1;
@@ -461,6 +433,7 @@ export class PortfolioCalculator {
factor = 0;
break;
}
+
return factor;
}