|
@ -2,6 +2,7 @@ import { DATE_FORMAT, getYesterday } from '@ghostfolio/common/helper'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Currency } from '@prisma/client'; |
|
|
import { Currency } from '@prisma/client'; |
|
|
import { format } from 'date-fns'; |
|
|
import { format } from 'date-fns'; |
|
|
|
|
|
import { isNumber } from 'lodash'; |
|
|
|
|
|
|
|
|
import { DataProviderService } from './data-provider.service'; |
|
|
import { DataProviderService } from './data-provider.service'; |
|
|
|
|
|
|
|
@ -83,9 +84,17 @@ export class ExchangeRateDataService { |
|
|
factor = this.currencies[`${aFromCurrency}${aToCurrency}`]; |
|
|
factor = this.currencies[`${aFromCurrency}${aToCurrency}`]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isNumber(factor)) { |
|
|
return factor * aValue; |
|
|
return factor * aValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Fallback with error, if currencies are not available
|
|
|
|
|
|
console.error( |
|
|
|
|
|
`No exchange rate has been found for ${aFromCurrency}${aToCurrency}` |
|
|
|
|
|
); |
|
|
|
|
|
return aValue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private addPairs(aCurrency1: Currency, aCurrency2: Currency) { |
|
|
private addPairs(aCurrency1: Currency, aCurrency2: Currency) { |
|
|
this.pairs.push(`${aCurrency1}${aCurrency2}`); |
|
|
this.pairs.push(`${aCurrency1}${aCurrency2}`); |
|
|
this.pairs.push(`${aCurrency2}${aCurrency1}`); |
|
|
this.pairs.push(`${aCurrency2}${aCurrency1}`); |
|
|