Simian Savants LLC Charting Software Logo SSChart Candlestick Stock Charting Software banner
    IB TWS   Using IB TWS as Data Source  
 

Latest News:

IB seems to have raised the symbol limit now to 100. If you spend a lot in commissions, you may get even more. We can now get intraday backfill from TWS, this has now been expanded to go as far back as your preference setting for the number of days of intraday data to keep. (We don't recommend keeping more than about 28, unless you only watch a couple of symbols, otherwise the memory and storage requirements get quite large, but still nothing like the massive amounts of memory TWS itself uses). TWS is now also used for daily chart backfill for any symbol that contains the underscore "_" character which is basically everything except stocks on the US market. We still recommend yahoo for these as the download is much, much quicker and you can get more history. IB currenly limits to the last year.

Usage Tips

The current release works reliably using IB TWS as the quote source, we have been using it here plotting stocks, futures, indices, and options with our IB Universal accounts for more than three years. We are now processing the historical time and sales from CME for the E-Minis and some other futures into updated intraday chart files and posting them here daily. This allows you to get backfill for previous sessions. After the initial setup is working, be sure to check the documentation under {Help | Contents} for info on using the various features and shortcuts.

Startup delay

The startup process can take about a minute to complete, depending on a number of factors. Give it time to finish before you started doing anything. Wait until TWS starts returning data for symbols you already are watching, before you add any or change any of your charts, etc. If you start changing things during while the program is in the process of connecting with TWS, a crash is more likely. If you've several days of data for near the max (100) symbols, it takes about 20 seconds or so when you start SSChart for it to read in all the data and initialize all charts. (You can hear the disk activity, wait for it to quiet down). When you switch on quotes, if SSChart is launching TWS, it takes about a minute for TWS itself to come up and initialize (on my 1.2Ghz system). We've noted recenty a few instances of a chart being totally blank, when we have existing data for it. This seems to be a drawing timing problem during intialization. The data will appear if you select any drawing tool (like horizontal line) and click in the chart. We've notices instances during the startup procedure, when there are underlines blinking on the main program menu. This seems to be related to attempting to perform some activity with the program while it is still very busy initializing data and/or the connection with TWS.  We've are seeing instances where some or all symbols do not get data after starting.Toggling quotes off and on (which cancels market data and rerequests if for all symbols).

Trouble-shooting

Charting futures

By design the market hours designation is fixed by the data source to the normal equities trading sessions. Everything else is considered outside market hours. You can still get data and chart it but this requires you to set the preferences to keep the data, and each chart to "show all sessions" when you want to see the data. When you have a few days of data it can be informative to toggle the show all sessions setting (<right-click> in a chart to get there). To eliminate the stretches where the exchange is shut down, switch the chart to the one minute time frame, and select {Edit | Prices...}. Highlight the span of data where the market was closed (<left click> in the date column of the first closed point, then <shift/left click> on the last) and select [Delete] then [OK], this will remove the span of data. The data will be removed from all intraday charts for this symbol, but the procedure must be done in the 1-min chart. Postion line in graphical trading If you use the graphical trading feature, a position line will be drawn on the chart any time you have and open position, and {Trading | Show Graphical Trading} selected. If you don't see it, under {Chart Color...} in the chart pop-up dialog to make sure the line color is not set to the same as the background color. Note you can set different colors for long vs. short positions. Normal the value used for the Position and Average Cost is what is returned by TWS for real trading, and is calculated internally for paper trading. Near the end of Dec. 2005, TWS started returning wrong values for average cost for FUTURES positions, so in SSChart 2.73 we have added an option to ignore the value returned by TWS for FUTures positions and use one internally calculated from trade confirmations instead. The option is under {File | Preferences...} on the Misc tab as Ignore FUT Avg Cost. Changes in later TWS versions have eliminated the need for this option. When using this option if a trade happens while SSChart is not up, the internally calculated value may be wrong. For this case we provide a means to manually override it as follows. Type in any chart for the symbol (as if you were entering a new symbol) the information in the form: =<av cost><enter> or =<position>/<av cost><enter> Examples: =1234.50
sets the average cost to 1234.50
=-1/1245.25
sets the position to -1 and the average cost to 1245.25. Note if you set the average cost to 0, it automatically sets position to 0 also.
Note: IB now seems to be calculating average cost for futures as the notional value of the position less commissions. Relase 2.74 has adapted to this so the above option should not be necessary unless you want SSChart to calculate average cost internally without taking into account commissions.

Indices

Since IB does not provide historical data, the daily/weekly/monthly data sources must be set to another source (usually yahoo). The index symbols used are different there (e.g. yahoo use ^SPX while IB uses IC_SPX (in SSChart). This presents a problem, if you show a daily chart for ^SPX while collecting quotes, it will also try to get intraday quotes for ^SPX from IB (you will see "invalid ticker" message on the router console). The alias file setting in the { Data | Internet Sources... } dialog addresses this. (None of the free sources support historic futures, if you have a mytrack subscription account, you can get historic futures data from it.)

Charting your account value

SSChart recognizes a special symbol to represent your account value (the reported net liquidating value from TWS). This symbol will be A~<account#>. For example if your account number (shown in the title bar of TWS) is U12345, the the symbol A~U12345 will have your account value. You can add this symbol to an SLFMap, Daily chart, or intraday chart, to track changes in your account value. (We recomend keeping it present in an SLFMap, so that we can build a continuous daily chart of your account NLV).

Miscellaneous details

The trade times shown in charts and time&sales are the local time at the exchange. The exception ,all US markets, including GLOBEX and CBOT, which are actually in Chicago. We are showing New York time for these since most of the trading is during the normal stock trading session. The equities main session (9:30 - 16:00) is also considered the main session for US futures, everything else is included when you select "Show all sessions" in the chart. Symbols entered using the long encoding format, are shown as underlying only, or for futures, the underlying with a 2 character expiry code in the SLFMap and horserace. If you <right click> in a cell in the SLFMap, you will still see the full encoded symbol at the top of the popup dialog. In the horserace, <right click> in any column to see the full symbol for that column.

Alias file

If using yahoo as the data source for historical data (recommended), you can select "IB_yahoo_aliases" as the alias file in the {Data | Internet sources...} dialog. This will translate the long symbols used for the IB quotes into yahoo's symbol when you drag a symbol from the SLFMap or a chart to a daily or longer timeframe chart. The sample alias file included also translates futures symbols into the symbol for the underlying index when you drop it into a daily chart. See the documentation for details on editing this file. If you want to add additional aliases, we recommend you make a new file (with a different name) than those supplied, so your file won't get overwritten by the next version upgrade of SSChart.

Futures Daily Charts

IB returns daily futures data for US futures only. (They briefly supplied daily data for some non-US futures, but don't seem to be doing so now, at least if you have a US account). The daily futures data they supply does not seem to match the trading range for the day, perhaps they use the clearing date, or something else, but it is probably not generally what we want to see. In version 2.76 we have added the ability to update the daily chart for a future, from the intraday that you have collected. We use the total trading range from midnight to midnight to construct the bar for the day. This is actived by selecting a daily chart, then selecting { Data | Update from Intraday Data } from the main menu. (This also works for any type of contract you have data for, not just futures.) If you get the index symbol in the daily when trying to drop in the future symbol, it is because of an entry in the alias file you have selected telling the program to do so. You will need to edit the alias file then restart if you don't want this translation to happen, or just select no alias file and restart. If you drop a symbol in the daily chart that does not have any data already on your disk, the program tries to fetch data from the current daily data source, or in the case contracts other than stocks the program will automatically try to construct a daily chart from existing intraday data. For a daily chart for contracts other than stocks selecting { Chart | Update } will request the historic daily data from IB, { Data | Update from Intraday Data } will update the daily chart from existing intraday data for the same symbol (note the word "existing", so you should update the intraday data if it is not current before using this.)

SSMerge

Version 3.14 added the command-line utility SSMerge. The function of this utility is to merge several daily data files for expired futures contracts (if you have them) into to most recent contract file. Use this to produce a longer daily chart using all accumulated data you have. This utility is installed in the SSChart directory in version 3.14 and later and must be run from a cmd window. (You may want to copy SSMerge.exe into the DATA directory or another location so it will be in your path.)
Use example:

If you have FG_ES_201009.dyd, FG_ES_201012.dyd, FG_ES_201103.dyd in your data directory,

SSMerge FG_ES*.dyd

will merge them into FG_ES_201103.dyd (or the latest contract matching the pattern on the command line). In the days where the contract data overlaps, the one with the highest volume is used.

 

external_portfolio.txt 

Version 3.14 can get information about external (to IB) position from the file ACCOUNTS/External_portfolio.txt.  There is a sample of this file in the SSCHART/USR directory, to use this feature, copy this file to the ACCOUNTS directory and edit it here with notepad.exe. Use it to define positions external to your IB account (say for mutual funds held elsewhere). When you then put one of these symbols in a chart, SSChart will be able to draw position line on the chart showing the position and current value. (The chart colors for the position line must be set to something other than the background color for this to be visible).  Since mutual funds do not have intraday quotes you will want to also list these symbols in CONFIG\INHIBIT.TXT, so SSChart will not request quotes from IB fore these symbols. Add any other symbols you want to inhibit quotes for to CONFIG\INHIBIT.TXT also. (After edits, SSChart needs to be restarted before this takes affect). HINT: Make and SLFMap containing all the inhibited symbols you want to track daily. When you do an "Update all Daily" on the SLFMap, SSChart will update the daily data for these symbols and in version 3.14 and later it now will color the cells of the SLFMap to reflect the change from yesterday's closing price. (If quotes are not on, you will need to minimize and restore the SLFMap to force a redraw after the update. When quotes are on this will happen automatically after a few seconds).

Paper Trading

Note that the paper trading in SSChart was implemented BEFORE IB added paper trading accounts. If you use SSChart's paper trading, you can paper trade in your real trading account, and you will not see the orders sent to TWS. If you connect to an IB Paper Account, then use real trading mode in SSChart, so the orders actually get sent to the TWS paper account. This is a more realistic solution as IB will generate account statements, etc.. With SSChart's built in paper trading, you can connect to your real account, and trade some contracts for real, while paper trading others.


Shortcuts

Here are some of the shortcuts I use constantly:
  • Hotkeys 1 thru 9 (to change the intraday time span of a chart, and change the view units of a tick or volume chart).
  • Hotkeys "shift-1 .. shift-5, and shift-7, shift-8 (to change the time span of a chart, to 1 - 20 days/candle). This works by combining daily data into the new multiple day time unit.
  • <double click> in chart (to toggle between full screen/normal view).
  • Drag-and-drop symbol from SLFMap to/from charts.
 Check the documentation by select {Help | Contents} from the program menu for details on these and more shortcuts. [Back to Top]
 
Last Revised Monday, 28-Mar-2011 02:15:43 EDT
SSChart is a trademark of Simian Savants LLC
Copyright (c) 1999-2011 Simian Savants LLC. All rights reserved.