How to suppress Interactive Broker error warnings Jupyter, Python

  interactive-brokers, jupyter, python, tws

In a Jupyter notebook, I am trying to suppress Error 200 messages from the Interactive Broker’s TWS API, such as the following:

Error 200, reqId 12755: No security definition has been found for the request, contract: Option(symbol=’SPY’, lastTradeDateOrContractMonth=’20210721′, strike=407.5, right=’P’, exchange=’SMART’)

Error 200, reqId 12761: No security definition has been found for the request, contract: Option(symbol=’SPY’, lastTradeDateOrContractMonth=’20210721′, strike=412.5, right=’P’, exchange=’SMART’)

I have used the following code to no avail:

import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')

or

import warnings
warnings.filterwarnings('ignore')

Source: Python Questions

LEAVE A COMMENT