It is possible to fetch different kinds market data from the TWS:
In order to receive top-of-book, depth-of-book, or historical market data from the API it is necessary have live market data subscriptions for the requested instruments in TWS. The full list of requirements for real time data:
(1) trading permissions for the specified instruments
(2) a funded account (except with forex and bonds), and
(3) market data subscriptions for the specified username
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.
One way to determine which market data subscriptions are required for a given security is to enter the contract into a TWS watchlist and the right-click on the contract to select "Launch Market Data Subscription Manager". This will launch a browser window to the market data subscription page of a subscription covering the indicated instrument.
Alternatively, there is also a "Market Data Assistant" utility for determining market data subscriptions:
Once you have selected the relevant packages, click on the "Continue" button and confirm you have made the right choices in the following screen.
Important: Market Data subscriptions are billable at the full month's rate and will not be pro-rated.
Market data subscriptions are done at a TWS user name level, not per account. This implies that live market data subscriptions need to be purchased per every live TWS user. The only exception to this rule are paper trading users. To share the market data subscriptions simply access your Account Management and navigate to Manage Account -> Settings -> Paper Trading where you will be presented to the screen below. It will take up to 24 hours until the market data sharing takes effect.
Important: since your paper trading market data permissions are bound to your live one, you can only obtain live market data on your paper trading user if;
Whenever a user requests an instrument's real time (top-of-book) market data either from within the TWS or through the TWS API, the user is making use of a market data line. Market data lines therefore represent the active market data requests a user has.
Example: To clarify this concept further, let us assume a user has a maxTicker Limit of ten market data lines and is already observing the real time data of say five stocks within the TWS itself. When the user connects his TWS API client application to the TWS, he then requests the real time market data for another different five instruments. At a later point while all 10 requests are still active, the user tries to subscribe to the live real time market data of an eleventh product. Since the user is already making use of ten market data lines (five in the TWS and another five in his client application), the TWS will respond with an error message telling the client application it has reached the maximum number of simultaneous requests. In order to request the market data of the eleventh product, the user will have to cancel at least one of the currently active subscriptions (either within TWS or from his client program.)
By default, every user has a maxTicker Limit of 100 market data lines and as such can obtain the real time market data of up to 100 instruments simultaneously. This limit however can be further extended either through the purchase of quote booster packs or by increasing the equity and/or commissions of the user's account. For further details on how to increment the number of market data lines or how is your market data lines' entitlement calculated, please refer to our website's "Market Data Display" section within the Research, News and Market Data page.
Note: It is important to understand the concept of market data lines since it has an impact not only on the live real time requests but also for requesting market depth and real time bars.