Bugfix/fix symbol validation in Yahoo Finance service (#4472)
* Fix symbol validation * Add test cases
This commit is contained in:
parent
a6952a0e37
commit
c467c946d4
@ -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);
|
||||
|
2
test/import/invalid-symbol-btc-usd.csv
Normal file
2
test/import/invalid-symbol-btc-usd.csv
Normal file
@ -0,0 +1,2 @@
|
||||
Date,Code,Currency,Price,Quantity,Action,Fee
|
||||
12/12/2021,BTC-USD,USD,44558.42,1,buy,0
|
|
2
test/import/ok-btcusd.csv
Normal file
2
test/import/ok-btcusd.csv
Normal file
@ -0,0 +1,2 @@
|
||||
Date,Code,Currency,Price,Quantity,Action,Fee
|
||||
12/12/2021,BTCUSD,USD,44558.42,1,buy,0
|
|
Loading…
x
Reference in New Issue
Block a user