Feature/improve yahoo finance symbol conversion (#402)

* Improve symbol conversion

* Update changelog
pull/404/head
Thomas Kaul 3 years ago committed by GitHub
parent 595ec1d7b4
commit 1050bfa098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Improved the symbol conversion for _Yahoo Finance_: Support for _Solana USD_ (`SOL1-USD`)
- Upgraded `envalid` from version `7.1.0` to `7.2.1`
## 1.57.0 - 29.09.2021

@ -256,18 +256,19 @@ export const convertFromYahooFinanceSymbol = (aYahooFinanceSymbol: string) => {
/**
* Converts a symbol to a Yahoo Finance symbol
*
* Currency: USDCHF=X
* Cryptocurrency: BTC-USD
* Currency: USDCHF -> USDCHF=X
* Cryptocurrency: BTCUSD -> BTC-USD
* DOGEUSD -> DOGE-USD
* SOL1USD -> SOL1-USD
*/
export const convertToYahooFinanceSymbol = (aSymbol: string) => {
if (isCurrency(aSymbol)) {
if (isCrypto(aSymbol)) {
if (isCrypto(aSymbol) || isCrypto(aSymbol.replace('1', ''))) {
// Add a dash before the last three characters
// BTCUSD -> BTC-USD
// DOGEUSD -> DOGE-USD
return `${aSymbol.substring(0, aSymbol.length - 3)}-${aSymbol.substring(
aSymbol.length - 3
)}`;
// SOL1USD -> SOL1-USD
return aSymbol.replace('USD', '-USD');
}
return `${aSymbol}=X`;

Loading…
Cancel
Save