Browse Source

Refactoring

pull/239/head
Thomas 4 years ago
parent
commit
5e9cecc6c1
  1. 20
      apps/api/src/app/core/current-rate.service.ts
  2. 0
      apps/api/src/app/core/get-value-object.interface.ts
  3. 0
      apps/api/src/app/core/get-value-params.interface.ts
  4. 0
      apps/api/src/app/core/get-values-params.interface.ts
  5. 8
      apps/api/src/app/core/portfolio-calculator.spec.ts
  6. 2
      apps/api/src/app/core/portfolio-calculator.ts

20
apps/api/src/app/core/current-rate.service.ts

@ -1,6 +1,6 @@
import { GetValueObject } from '@ghostfolio/api/app/core/get-value.object'; import { GetValueObject } from '@ghostfolio/api/app/core/get-value-object.interface';
import { GetValueParams } from '@ghostfolio/api/app/core/get-value.params'; import { GetValueParams } from '@ghostfolio/api/app/core/get-value-params.interface';
import { GetValuesParams } from '@ghostfolio/api/app/core/get-values.params'; import { GetValuesParams } from '@ghostfolio/api/app/core/get-values-params.interface';
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 { resetHours } from '@ghostfolio/common/helper'; import { resetHours } from '@ghostfolio/common/helper';
@ -41,12 +41,12 @@ export class CurrentRateService {
if (marketData) { if (marketData) {
return { return {
date: marketData.date, date: marketData.date,
symbol: marketData.symbol,
marketPrice: this.exchangeRateDataService.toCurrency( marketPrice: this.exchangeRateDataService.toCurrency(
marketData.marketPrice, marketData.marketPrice,
currency, currency,
userCurrency userCurrency
) ),
symbol: marketData.symbol
}; };
} }
@ -67,8 +67,8 @@ export class CurrentRateService {
const promises: Promise< const promises: Promise<
{ {
date: Date; date: Date;
symbol: string;
marketPrice: number; marketPrice: number;
symbol: string;
}[] }[]
>[] = []; >[] = [];
@ -80,8 +80,8 @@ export class CurrentRateService {
for (const symbol of symbols) { for (const symbol of symbols) {
result.push({ result.push({
date: today, date: today,
symbol: symbol, marketPrice: dataResultProvider?.[symbol]?.marketPrice ?? 0,
marketPrice: dataResultProvider?.[symbol]?.marketPrice ?? 0 symbol: symbol
}); });
} }
return result; return result;
@ -99,12 +99,12 @@ export class CurrentRateService {
return data.map((marketDataItem) => { return data.map((marketDataItem) => {
return { return {
date: marketDataItem.date, date: marketDataItem.date,
symbol: marketDataItem.symbol,
marketPrice: this.exchangeRateDataService.toCurrency( marketPrice: this.exchangeRateDataService.toCurrency(
marketDataItem.marketPrice, marketDataItem.marketPrice,
currencies[marketDataItem.symbol], currencies[marketDataItem.symbol],
userCurrency userCurrency
) ),
symbol: marketDataItem.symbol
}; };
}); });
}) })

0
apps/api/src/app/core/get-value.object.ts → apps/api/src/app/core/get-value-object.interface.ts

0
apps/api/src/app/core/get-value.params.ts → apps/api/src/app/core/get-value-params.interface.ts

0
apps/api/src/app/core/get-values.params.ts → apps/api/src/app/core/get-values-params.interface.ts

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

@ -1,8 +1,6 @@
import { import { CurrentRateService } from '@ghostfolio/api/app/core/current-rate.service';
CurrentRateService import { GetValueParams } from '@ghostfolio/api/app/core/get-value-params.interface';
} from '@ghostfolio/api/app/core/current-rate.service'; import { GetValuesParams } from '@ghostfolio/api/app/core/get-values-params.interface';
import { GetValueParams } from '@ghostfolio/api/app/core/get-value.params';
import { GetValuesParams } from '@ghostfolio/api/app/core/get-values.params';
import { PortfolioCalculator } from '@ghostfolio/api/app/core/portfolio-calculator'; import { PortfolioCalculator } from '@ghostfolio/api/app/core/portfolio-calculator';
import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order'; import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order';
import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period'; import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period';

2
apps/api/src/app/core/portfolio-calculator.ts

@ -1,5 +1,5 @@
import { CurrentRateService } from '@ghostfolio/api/app/core/current-rate.service'; import { CurrentRateService } from '@ghostfolio/api/app/core/current-rate.service';
import { GetValueObject } from '@ghostfolio/api/app/core/get-value.object'; import { GetValueObject } from '@ghostfolio/api/app/core/get-value-object.interface';
import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order'; import { PortfolioOrder } from '@ghostfolio/api/app/core/portfolio-order';
import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period'; import { TimelinePeriod } from '@ghostfolio/api/app/core/timeline-period';
import { import {

Loading…
Cancel
Save