What is the best way to handle potentially invalid tickers?
I have tried:
try:
df = tickers.get_historical('PX_LAST', start = '31/1/2019', end =
'31/1/2019', currency='EUR')
except Exception:
print("Could not validate ticker:")
But this stops the request entirely and does not provide any valid returns, indeed it says 'df' not defined.
The output if "a" was not in tickers would be:
GLEN LN EQUITY AAPL US EQUITY
date
2019-01-31 3.54638 145.36245
Ideally I would like the invalid tickers skipped entirely and the output be the same as it would have been had it not been there originally, i.e., the same as above.
I have the following:
Since "a" is obviously not a valid ticker I get the following error:
What is the best way to handle potentially invalid tickers?
I have tried:
But this stops the request entirely and does not provide any valid returns, indeed it says 'df' not defined.
The output if "a" was not in tickers would be:
Ideally I would like the invalid tickers skipped entirely and the output be the same as it would have been had it not been there originally, i.e., the same as above.