Browse Source
Bugfix/fix symbol validation in Yahoo Finance service (#4472)
* Fix symbol validation
* Add test cases
pull/4474/head
Thomas Kaul
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
5 additions and
1 deletions
-
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts
-
test/import/invalid-symbol-btc-usd.csv
-
test/import/ok-btcusd.csv
|
|
@ -170,7 +170,7 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface { |
|
|
|
symbol = quotes[0].symbol; |
|
|
|
} |
|
|
|
} catch {} |
|
|
|
} else if (symbol?.includes('-')) { |
|
|
|
} else if (symbol?.endsWith(`-${DEFAULT_CURRENCY}`)) { |
|
|
|
throw new Error(`${symbol} is not valid`); |
|
|
|
} else { |
|
|
|
symbol = this.convertToYahooFinanceSymbol(symbol); |
|
|
|
|
|
@ -0,0 +1,2 @@ |
|
|
|
Date,Code,Currency,Price,Quantity,Action,Fee |
|
|
|
12/12/2021,BTC-USD,USD,44558.42,1,buy,0 |
1 |
Date |
Code |
Currency |
Price |
Quantity |
Action |
Fee |
2 |
12/12/2021 |
BTC-USD |
USD |
44558.42 |
1 |
buy |
0 |
|
|
|
@ -0,0 +1,2 @@ |
|
|
|
Date,Code,Currency,Price,Quantity,Action,Fee |
|
|
|
12/12/2021,BTCUSD,USD,44558.42,1,buy,0 |
1 |
Date |
Code |
Currency |
Price |
Quantity |
Action |
Fee |
2 |
12/12/2021 |
BTCUSD |
USD |
44558.42 |
1 |
buy |
0 |
|