Browse Source

Add conversion from GPB to GBp

pull/722/head
Thomas 3 years ago
parent
commit
8bb24770df
  1. 20
      apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

20
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

@ -163,8 +163,15 @@ export class YahooFinanceService implements DataProviderInterface {
response[symbol] = {};
for (const historicalItem of historicalResult) {
let marketPrice = historicalItem.close;
if (symbol === 'USDGBp') {
// Convert GPB to GBp (pence)
marketPrice = new Big(marketPrice).mul(100).toNumber();
}
response[symbol][format(historicalItem.date, DATE_FORMAT)] = {
marketPrice: historicalItem.close,
marketPrice,
performance: historicalItem.open - historicalItem.close
};
}
@ -212,6 +219,17 @@ export class YahooFinanceService implements DataProviderInterface {
: MarketState.closed,
marketPrice: quote.regularMarketPrice || 0
};
if (symbol === 'USDGBP' && yahooFinanceSymbols.includes('USDGBp=X')) {
// Convert GPB to GBp (pence)
response['USDGBp'] = {
...response[symbol],
currency: 'GBp',
marketPrice: new Big(response[symbol].marketPrice)
.mul(100)
.toNumber()
};
}
}
return response;

Loading…
Cancel
Save