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
parent
commit
c467c946d4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts
  2. 2
      test/import/invalid-symbol-btc-usd.csv
  3. 2
      test/import/ok-btcusd.csv

2
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

@ -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

@ -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

2
test/import/ok-btcusd.csv

@ -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
Loading…
Cancel
Save