Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable TWS delayed market data?

Here is a script I am using to request market data.

I am not subscribed to the data-feed yet, so I though it would automatically return delayed market data, but apparently I have to enable it, but cannot find where to do that.
Here is the script and the errors I get, all I need is to receive delayed data, so I can test 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()

The error:

<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>
like image 395
TB1 Avatar asked Aug 03 '17 17:08

TB1


People also ask

What is delayed market data?

Real-time market data is disseminated as soon as the information is publicly available. Delayed market data is on a time lag that is usually 10-20 minutes behind real-time quotes. Some exchanges allow delayed data to be displayed without any market data subscription, free of charge.

Can you day trade with delayed data?

It is possible to trade with delayed data because IB allows to trade blind (with no data at all), However, IB will fill the orders according to real-time market conditions.

How do I subscribe to live market data Interactive Brokers?

To subscribe to live market data: Login to your Account Management, navigate to Manage Account -> Trade Configuration -> Market Data and select the relevant packages and/or subscription you wish to subscribe to based on the products you require.

How to request live frozen and delayed frozen market data from Trader Workstation?

The API can request Live, Frozen, Delayed and Delayed Frozen market data from Trader Workstation by switching market data type via the IBApi.EClient.reqMarketDataType # Switch to live (1) frozen (2) delayed (3) delayed frozen (4). from ibapi.client import MarketDataTypeEnum .reqMarketDataType(MarketDataTypeEnum.DELAYED) OR .reqMarketDataType(3)

How long does delayed market data take to display?

Delayed market data is on a time lag that is usually 10-20 minutes behind real-time quotes. Some exchanges allow delayed data to be displayed without any market data subscription, free of charge.

How do I get delayed streaming data from the API?

10-15 minute delayed streaming data is available for many types of instruments without market data subscriptions. By default, the API is in the real time market data mode, so the function IBApi::EClient::reqMktData will request real time data.

What is reqmarketdatatype (3)?

.reqMarketDataType(3) that has to be called beforemaking a market data request with .reqMktData(). When using the reqMktDatafunction, there are four ‘market data modes’ (Market Data Type) available: Live streaming (the default) Frozen (typically used for bid/ask prices after market close)


1 Answers

Documentation suggests ( emphasis and formats added ) :

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

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

from ibapi.client import MarketDataTypeEnum .reqMarketDataType(MarketDataTypeEnum.DELAYED)

OR

.reqMarketDataType(3)

that has to be called before making a market data request with .reqMktData().

When using the reqMktData function, there are four ‘market data modes’ (Market Data Type) available:

  1. Live streaming (the default)
  2. Frozen (typically used for bid/ask prices after market close)
  3. Delayed (if the username does not have live market data subscriptions)
  4. Delayed-Frozen (combination of types 2 & 3)
like image 65
user3666197 Avatar answered Oct 24 '22 04:10

user3666197