Feature/improve yahoo finance symbol conversion (#402)
* Improve symbol conversion * Update changelog
This commit is contained in:
parent
595ec1d7b4
commit
1050bfa098
@ -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
|
||||||
|
@ -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`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user