Feature/improve yahoo finance symbol conversion (#402)

* Improve symbol conversion

* Update changelog
This commit is contained in:
Thomas Kaul 2021-10-02 10:28:06 +02:00 committed by GitHub
parent 595ec1d7b4
commit 1050bfa098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### 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` - Upgraded `envalid` from version `7.1.0` to `7.2.1`
## 1.57.0 - 29.09.2021 ## 1.57.0 - 29.09.2021

View File

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