Browse Source

Clean up code

pull/244/head
Thomas 4 years ago
parent
commit
a323593857
  1. 15
      apps/api/src/app/portfolio/portfolio.service.ts
  2. 13
      apps/api/src/models/rule.ts

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

@ -17,7 +17,6 @@ import { FeeRatioInitialInvestment } from '@ghostfolio/api/models/rules/fees/fee
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service'; import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service'; import { ImpersonationService } from '@ghostfolio/api/services/impersonation.service';
import { Type } from '@ghostfolio/api/services/interfaces/interfaces';
import { EnhancedSymbolProfile } from '@ghostfolio/api/services/interfaces/symbol-profile.interface'; import { EnhancedSymbolProfile } from '@ghostfolio/api/services/interfaces/symbol-profile.interface';
import { RulesService } from '@ghostfolio/api/services/rules.service'; import { RulesService } from '@ghostfolio/api/services/rules.service';
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service'; import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service';
@ -264,9 +263,7 @@ export class PortfolioService {
this.request.user.Settings.currency this.request.user.Settings.currency
); );
const { transactionPoints, orders } = await this.getTransactionPoints( const { transactionPoints } = await this.getTransactionPoints(userId);
userId
);
if (transactionPoints?.length <= 0) { if (transactionPoints?.length <= 0) {
return { return {
@ -352,18 +349,18 @@ export class PortfolioService {
} }
return { return {
averagePrice: averagePrice.toNumber(),
currency, currency,
firstBuyDate, firstBuyDate,
investment: investment.toNumber(),
marketPrice, marketPrice,
maxPrice, maxPrice,
minPrice, minPrice,
quantity: quantity.toNumber(),
transactionCount, transactionCount,
averagePrice: averagePrice.toNumber(),
grossPerformance: position.grossPerformance.toNumber(), grossPerformance: position.grossPerformance.toNumber(),
grossPerformancePercent: position.grossPerformancePercentage.toNumber(), grossPerformancePercent: position.grossPerformancePercentage.toNumber(),
historicalData: historicalDataArray, historicalData: historicalDataArray,
investment: investment.toNumber(),
quantity: quantity.toNumber(),
symbol: aSymbol symbol: aSymbol
}; };
} else { } else {
@ -452,9 +449,7 @@ export class PortfolioService {
position.grossPerformancePercentage?.toNumber() ?? null, position.grossPerformancePercentage?.toNumber() ?? null,
investment: new Big(position.investment).toNumber(), investment: new Big(position.investment).toNumber(),
name: position.name, name: position.name,
quantity: new Big(position.quantity).toNumber(), quantity: new Big(position.quantity).toNumber()
type: Type.Unknown, // TODO
url: '' // TODO
}; };
}) })
}; };

13
apps/api/src/models/rule.ts

@ -1,10 +1,7 @@
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface';
import { UserSettings } from '@ghostfolio/api/models/interfaces/user-settings.interface'; import { UserSettings } from '@ghostfolio/api/models/interfaces/user-settings.interface';
import { groupBy } from '@ghostfolio/common/helper'; import { groupBy } from '@ghostfolio/common/helper';
import { import { TimelinePosition } from '@ghostfolio/common/interfaces';
PortfolioPosition,
TimelinePosition
} from '@ghostfolio/common/interfaces';
import { Currency } from '@prisma/client'; import { Currency } from '@prisma/client';
import { ExchangeRateDataService } from '../services/exchange-rate-data.service'; import { ExchangeRateDataService } from '../services/exchange-rate-data.service';
@ -25,10 +22,6 @@ export abstract class Rule<T extends RuleSettings> implements RuleInterface<T> {
this.name = name; this.name = name;
} }
public abstract evaluate(aRuleSettings: T): EvaluationResult;
public abstract getSettings(aUserSettings: UserSettings): T;
public getName() { public getName() {
return this.name; return this.name;
} }
@ -59,4 +52,8 @@ export abstract class Rule<T extends RuleSettings> implements RuleInterface<T> {
}) })
); );
} }
public abstract evaluate(aRuleSettings: T): EvaluationResult;
public abstract getSettings(aUserSettings: UserSettings): T;
} }

Loading…
Cancel
Save