|
@ -197,16 +197,17 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
// filter out undefined symbols
|
|
|
// filter out undefined symbols
|
|
|
return quote.symbol; |
|
|
return quote.symbol; |
|
|
}) |
|
|
}) |
|
|
.filter(({ quoteType }) => { |
|
|
.filter(({ quoteType, symbol }) => { |
|
|
return ( |
|
|
return ( |
|
|
quoteType === 'CRYPTOCURRENCY' || |
|
|
(quoteType === 'CRYPTOCURRENCY' && this.isCryptoCurrency(symbol)) || |
|
|
quoteType === 'EQUITY' || |
|
|
quoteType === 'EQUITY' || |
|
|
quoteType === 'ETF' |
|
|
quoteType === 'ETF' |
|
|
); |
|
|
); |
|
|
}) |
|
|
}) |
|
|
.filter(({ quoteType, symbol }) => { |
|
|
.filter(({ quoteType, symbol }) => { |
|
|
if (quoteType === 'CRYPTOCURRENCY') { |
|
|
if (quoteType === 'CRYPTOCURRENCY') { |
|
|
// Only allow cryptocurrencies in USD
|
|
|
// Only allow cryptocurrencies in USD to avoid having redundancy in the database.
|
|
|
|
|
|
// Trades need to be converted manually before to USD (or a UI converter needs to be developed)
|
|
|
return symbol.includes('USD'); |
|
|
return symbol.includes('USD'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -253,21 +254,26 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
) { |
|
|
) { |
|
|
if (isCurrency(aSymbol.substring(0, aSymbol.length - 3))) { |
|
|
if (isCurrency(aSymbol.substring(0, aSymbol.length - 3))) { |
|
|
return `${aSymbol}=X`; |
|
|
return `${aSymbol}=X`; |
|
|
} else if ( |
|
|
} else if (this.isCryptoCurrency(aSymbol)) { |
|
|
this.cryptocurrencyService.isCrypto(aSymbol) || |
|
|
|
|
|
this.cryptocurrencyService.isCrypto(aSymbol.replace('1', '')) |
|
|
|
|
|
) { |
|
|
|
|
|
// Add a dash before the last three characters
|
|
|
// Add a dash before the last three characters
|
|
|
// BTCUSD -> BTC-USD
|
|
|
// BTCUSD -> BTC-USD
|
|
|
// DOGEUSD -> DOGE-USD
|
|
|
// DOGEUSD -> DOGE-USD
|
|
|
// SOL1USD -> SOL1-USD
|
|
|
// SOL1USD -> SOL1-USD
|
|
|
return aSymbol.replace('USD', '-USD'); |
|
|
return aSymbol.replace(new RegExp('-?USD$'), '-USD'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return aSymbol; |
|
|
return aSymbol; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private isCryptoCurrency(aSymbol: string) { |
|
|
|
|
|
const symbol = aSymbol.replace(new RegExp('-USD$'), 'USD'); |
|
|
|
|
|
return ( |
|
|
|
|
|
this.cryptocurrencyService.isCrypto(symbol) || |
|
|
|
|
|
this.cryptocurrencyService.isCrypto(symbol.replace('1', '')) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private parseAssetClass(aPrice: IYahooFinancePrice): { |
|
|
private parseAssetClass(aPrice: IYahooFinancePrice): { |
|
|
assetClass: AssetClass; |
|
|
assetClass: AssetClass; |
|
|
assetSubClass: AssetSubClass; |
|
|
assetSubClass: AssetSubClass; |
|
|