You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a ton of "Error 200 No security definition" errors and "Unknown contract" warnings when trying to retrieve an option chain.
I am trying to use logging.getLogger().addFilter() to block these, but it's not working. Or, rather, it worked in a Jupyter notebook, but not in the script based off of that code.
classIgnoreUnknownContractFilter(logging.Filter):
deffilter(self, record):
the_error=record.msgif ("Unknown contract"inthe_erroror"No security definition has been found"inthe_erroror"Error 200"inthe_error):
returnFalseelse:
returnTrue# Add the filter to the root logger or a specific loggerlogging.getLogger().addFilter(IgnoreUnknownContractFilter())
I tried adding this additional code, but it didn't help:
# move logger into my mail logging functionibasync_logger=logging.getLogger('ib_async')
ibasync_logger.addFilter(IgnoreUnknownContractFilter())
ibasync_logger.propagate=True
The errors and warnings are coming from qualifyContractsAsync:
strikes= [strikeforstrikeinchain.strikesif0.5*spx_value<=strike<=1.5*spx_value]
rights= ["P", "C"]
valid_contracts= []
forrightinrights:
forstrikeinstrikes:
contract=Option(
"SPX",
earliest_date,
strike,
right,
"CBOE",
tradingClass="SPXW",
multiplier="100",
)
# Qualify the contract to ensure it is validifcontractandawaitib.qualifyContractsAsync(contract):
valid_contracts.append(contract)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I get a ton of "Error 200 No security definition" errors and "Unknown contract" warnings when trying to retrieve an option chain.
I am trying to use logging.getLogger().addFilter() to block these, but it's not working. Or, rather, it worked in a Jupyter notebook, but not in the script based off of that code.
I tried adding this additional code, but it didn't help:
The errors and warnings are coming from
qualifyContractsAsync
:Beta Was this translation helpful? Give feedback.
All reactions