开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Error 162, Historical Market Data Service error message:API scanner subscription cancelled:


 

Hello,
?
i am using a basic scanner, that is repeated in a loop:

? ? ? ? ? ? ? ? if ENABLE_BUYING and ((is_premarket() and PREMARKET_ONLY) or not PREMARKET_ONLY):
? ? ? ? ? ? ? ? ? ? scan_sub = ScannerSubscription(
? ? ? ? ? ? ? ? ? ? ? ? instrument='STK',
? ? ? ? ? ? ? ? ? ? ? ? locationCode='STK.US.MAJOR',
? ? ? ? ? ? ? ? ? ? ? ? scanCode='TOP_PERC_GAIN'
? ? ? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ? ? ? scan_results = ib.reqScannerData(scan_sub)
? ? ? ? ? ? ? ? ? ? scan_results = scan_results[:10] ?# Limit to top 10 results
Everything works fine, but my terminal gets flooded with this error:

Error 162, reqId 33346: Historical Market Data Service error message:API scanner subscription cancelled: 33346
?
They only mention of this error in the docs is that you can ignore it. I found other posts in the TWSAPI group, but they also dont know how to fix it.?
?
Any suggestions?


 

Hey saschaludo,?
?
I'm not real great at coding in Python, but the logging library may provide an adequate band-aid for this problem. Try this:?
?
import logging
util.logToConsole(logging.CRITICAL) # limit messages to critical only
# scanner code goes here
util.logToConsole(logging.WARNING) # reset logging to the default, WARNING level
?
If you're interested in knowing more about what the logging library can do for you, then I would take a look here:
?
Regards,
Some Guy