• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Market Data Types

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 before making a market data request with reqMktData. A successful switch to a different (non-live) market data type for a particular market data request will be indicated by a callback to IBApi::EWrapper::marketDataType with the ticker ID of the market data request which is returning a different type of data.

Market Data TypeIDDescription
Live1Live market data is streaming data relayed back in real time. Market data subscriptions are required to receive live market data.
Frozen2 Frozen market data is the last data recorded at market close. In TWS, Frozen data is displayed in gray numbers. When you set the market data type to Frozen, you are asking TWS to send the last available quote when there is not one currently available. For instance, if a market is currently closed and real time data is requested, -1 values will commonly be returned for the bid and ask prices to indicate there is no current bid/ask data available. TWS will often show a 'frozen' bid/ask which represents the last value recorded by the system. To receive the last know bid/ask price before the market close, switch to market data type 2 from the API before requesting market data. API frozen data requires TWS/IBG v.962 or higher and the same market data subscriptions necessary for real time streaming data.
Delayed3

Free, delayed data is 15 - 20 minutes delayed. In TWS, delayed data is displayed in brown background. When you set market data type to delayed, you are telling TWS to automatically switch to delayed market data if the user does not have the necessary real time data subscription. If live data is available a request for delayed data would be ignored by TWS. Delayed market data is returned with delayed Tick Types (Tick ID 66~76).

Note: TWS Build 962 or higher is required and API version 9.72.18 or higher is suggested.

Delayed Frozen4Requests delayed "frozen" data for a user without market data subscriptions.
  • /*** Switch to live (1) frozen (2) delayed (3) or delayed frozen (4)***/
    client.reqMarketDataType(2);
  • /*** Switch to live (1) frozen (2) delayed (3) or delayed frozen (4)***/
    client.reqMarketDataType(2);
  • '*** Switch to live (1) frozen (2) delayed (3) or delayed frozen (4)***/
    client.reqMarketDataType(1)
  • /*** By default only real-time (1) market data is enabled
    Sending frozen (2) enables frozen market data
    Sending delayed (3) enables delayed market data and disables delayed-frozen market data
    Sending delayed-frozen (4) enables delayed and delayed-frozen market data
    Sending real-time (1) disables frozen, delayed and delayed-frozen market data ***/
    m_pClient->reqMarketDataType(2);
  • 1  # Switch to live (1) frozen (2) delayed (3) delayed frozen (4).
    2  self.reqMarketDataType(MarketDataTypeEnum.DELAYED)

After invoking IBApi.EClient.reqMarketDataType to fetch frozen or delayed data, subsequent IBApi::EClient::reqMktData requests will trigger IBApi.EWrapper.marketDataType as one of the resulting events to indicate the data type (2 or 3) of the returned data.

  • public class EWrapperImpl : EWrapper
    {
    ...
    public virtual void marketDataType(int reqId, int marketDataType)
    {
    Console.WriteLine("MarketDataType. "+reqId+", Type: "+marketDataType+"\n");
    }
  • public class EWrapperImpl implements EWrapper {
    ...
    @Override
    public void marketDataType(int reqId, int marketDataType) {
    System.out.println("MarketDataType. ["+reqId+"], Type: ["+marketDataType+"]\n");
    }
  • Public Class EWrapperImpl
    Implements EWrapper
    ...
    Public Sub marketDataType(reqId As Integer, marketDataType As Integer) Implements IBApi.EWrapper.marketDataType
    Console.WriteLine("MarketDataType - ReqId [" & reqId & "] MarketDataType [" & marketDataType & "]")
    End Sub
  • class TestCppClient : public EWrapper
    {
    ...
    void TestCppClient::marketDataType(TickerId reqId, int marketDataType) {
    printf( "MarketDataType. ReqId: %ld, Type: %d\n", reqId, marketDataType);
    }
  • 1 class TestWrapper(wrapper.EWrapper):
    ...
    1  def marketDataType(self, reqId: TickerId, marketDataType: int):
    2  super().marketDataType(reqId, marketDataType)
    3  print("MarketDataType. ", reqId, "Type:", marketDataType)
    4