Bugfix/convert g bp to gbp in yahoo finance service (#301)

* Fix currency inconsistency in the yahoo finance service (GBp to GBP)

* Update changelog
pull/303/head
Thomas Kaul 3 years ago committed by GitHub
parent e17b217032
commit c71a4c078e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed the node engine version mismatch in `package.json`
- Fixed an issue on the buy date in the position detail dialog
- Fixed an issue with the currency inconsistency in the _Yahoo Finance_ service (convert from `GBp` to `GBP`)
## 1.39.0 - 16.08.2021

@ -10,6 +10,7 @@ import { Granularity } from '@ghostfolio/common/types';
import { Injectable } from '@nestjs/common';
import { AssetClass, Currency, DataSource } from '@prisma/client';
import * as bent from 'bent';
import Big from 'big.js';
import { format } from 'date-fns';
import * as yahooFinance from 'yahoo-finance';
@ -72,6 +73,16 @@ export class YahooFinanceService implements DataProviderInterface {
name: value.price?.longName || value.price?.shortName || symbol
};
if (value.price?.currency === 'GBp') {
// Convert GBp (pence) to GBP
response[symbol].currency = Currency.GBP;
response[symbol].marketPrice = new Big(
value.price?.regularMarketPrice ?? 0
)
.div(100)
.toNumber();
}
const url = value.summaryProfile?.website;
if (url) {
response[symbol].url = url;

@ -102,18 +102,8 @@ export function isRakutenRapidApiSymbol(aSymbol = '') {
return aSymbol === 'GF.FEAR_AND_GREED_INDEX';
}
export function parseCurrency(aString: string): Currency {
if (aString?.toLowerCase() === 'chf') {
return Currency.CHF;
} else if (aString?.toLowerCase() === 'eur') {
return Currency.EUR;
} else if (aString?.toLowerCase() === 'gbp') {
return Currency.GBP;
} else if (aString?.toLowerCase() === 'usd') {
return Currency.USD;
}
return undefined;
export function parseCurrency(aCurrency: string): Currency {
return Currency[aCurrency];
}
export function resetHours(aDate: Date) {

Loading…
Cancel
Save