How do I enable TWS Pending Market Data?

Here is the script I am using to query market data.

I haven't subscribed to the data feed yet, so even though I would automatically return pending market data, but apparently I need to enable it but can't find where to do it.
Here is the script and the errors I am getting, all I need is to get the lagged data so I can check my algorithm.

from ib.opt import ibConnection, message
from ib.ext.Contract import Contract
from time import sleep

def fundamentalData_handler(msg):
    print(msg)

def error_handler(msg):
    print(msg)

tws = ibConnection(port=7496, clientId=100)
tws.register(error_handler, message.Error)
tws.register(fundamentalData_handler, message.fundamentalData)
tws.connect()

c = Contract()
c.m_symbol = 'AAPL'
c.m_secType = 'STK'
c.m_exchange = "SMART"
c.m_currency = "USD"

print "on it"

tws.reqMktData(897,c,"",False)
sleep(50)

tws.disconnect()

      

Mistake:

<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:hfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:eufarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:jfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfuture>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:cashfarm>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm.us>
<error id=-1, errorCode=2104, errorMsg=Market data farm connection is OK:usfarm>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ilhmds>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:euhmds>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:fundfarm>
<error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ushmds>
<error id=897, errorCode=10168, errorMsg=Requested market data is not subscribed. Delayed market data is not enabled>

      

+3


source to share


1 answer


The documentation suggests (accents and formats added):



The API can request Live, Frozen, Delayed and Delayed Frozen Market data from the Trader workstation by switching the market data type using IBApi.EClient.reqMarketDataType

# Switch to live (1) frozen (2) delayed (3) delayed frozen (4).

.reqMarketDataType( MarketDataTypeEnum.DELAYED )

      

to be called prior to making a request for market information from .reqMktData()

.

+5


source







All Articles