Skip to content

C++ 17 based library (with sample applications) for testing equities, futures, etfs & options based automated trading ideas using DTN IQFeed real time data feed and Interactive Brokers (IB TWS API) for trade execution. Some support for Alpaca & Phemex. Notifications via Telegram [irc: Libra #tradeframe ]


Notifications You must be signed in to change notification settings


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation



This is a:

  • library of functions to sink market data, organize time series, build indicators, author algorithms, and issue orders to a broker for high-capacity, low-latency trading applications
  • collection of projects using the libraries to carry out various manual & automated trading scenarios

A primary goal of this solution is to provide a means of tracking an Option Combo Order through the birth to death life-cycle. It is easy to enter into a option combo with Interactive Brokers with their user interface, but there does not seem to be an effective way to keep the legs grouped for tracking overall profit/loss.

This library provides a means of Tracking a Combo Leg with a Position. Positions can be grouped together to form Portfolios. Portfolios representing Combos can be grouped together to represent the overall profit/loss of a trading Portfolio.

Positions are composed of a Watch class to record bid/ask/tick of Instruments.

Options inherit from the Watch class to provide Greeks, which are computed in real time with an Option Engine.

A Simulation Interface is provided for testing strategies off-line. The simulator will accept Orders of type Market and Limit assuming bid/ask data has been captured from the exchange during a live session. A 50ms - 100ms delay queue has been implemented to better simulate round-trip and slippage effects of order submission.


Picture from the ComboTrading project showing an instrument list, with a chart for one of the listed instruments. Bid, ask, spread, and greeks are charted for the option (charted real-time).

Option Greeks Timeline

More pictures under ComboTrading


The AutoTrade project can be used as a template to building your own automated high-frequency trading application.

Build Environment

A C++17 compiler is used to build the libraries and code. Initially, it was built on Windows a number of years ago, but the focus changed towards supporting a Linux environment. Some work will be needed to make it build on Windows again.

CMake is used for build management.

Note the use of '-march=native' in the root CMakeFiles.txt. This will cause code to be not necessarily transportable across CPU types. Comment out the option if you intend to compile across CPU types, ie, various releases of the Intel instruction set. See the referenced URL for the variety of instructions across CPU releases.


Scripts are library version specific. Build notes are as of 2021/11/22. There are some wxWidget requirements for using a GTK variation of video drivers (I've used Nvidia and Radeon cards successfully).

You'll need to have about 10G drive space free to build the project, the related libraries, as well as the installs (from my libs-build repository).

Debian Bookworm is used as the platform. The library installer is specific to this distribution. The installer may or may not work with other distributions or flavours.

DTN/IQFeed requires Wine to run. Starting with the 6.2 release of IQFeed, wine32 is no longer required. An x64-only installation of wine may generate some wine32 messages and errors, but they can be ignored.

# run with bash
# git for latest code, wine for IQFeed daemon
sudo apt-get update && apt-get install git wine64 wget
wine64 iqfeed_client_6_2_0_25.exe

# interactive brokers TWS for linux

# install and build initial environment and libraries
git clone
pushd libs-build
./ tradeframe
# rdaf is required for the projects in the rdaf subdirectory - optional
./ rdaf
# one example uses Wt web library as an interface - optional
./ wt

# main trade-frame code
git clone
# if you have access to the up-to-date private library, use this instead:
# git clone

# if you build manually (this is not required if you load the folder into vscode):
cd trade-frame
mkdir build
cd build
cmake ..
# use parallel to use more cpu cores
cmake --build . --parallel 4 --config Debug
# cmake --build . --parallel 4 --config Release   # alternate build flavour
# cmake --build . --target clean  # clean for rebuild

I use Visual Studio Code as my IDE. I have the following extensions installed:

  • C/C++ [Microsoft]
  • clangd [LLVM Extensions]
  • CMake [twxs]
  • CMake Tools [Microsoft]

The clangd extension provides the language library to provide symbol lookup and cross-referencing.

I have notes for this combination at Visual Studio Code with CMake and Clangd

Starting Up

  • Start the IQFeed daemon by starting Apps -> Wine -> Programs -> IQFeed -> Watchlist [or from the command line: wine ~/.wine/drive_c/Program\ Files/DTN/IQFeed/iqconnect.exe -autoconnect & ] Login with your credentials and checkbox the Save Username/Password and Autoconnect the first time
  • Start Interactive Brokers TWS and connect to a paper trading account .* Do Not use an active account for testing .* when connecting via an application, you will need to go into the settings to enable the API, and to activate the port
  • IQFeedMarketSymbols project:
    • run the app:
      • Actions -> New Symbol List Remote
      • the program will spend a few minutes downloading, parsing, and saving the latest IQFeed symbol list
      • lots of messages will be generated, no need to evaluate them, other than the summary stats at the end
      • File -> Exit
  • IQFeedGetHistory project:
    • obtains daily ohlc values, used to refresh data
    • repeats the symbol download, which was done with IQFeedMarketSymbols
    • run the app:
      • ensure the iqfeed daemon is running (you should see active updates in the quote monitor)
      • 'turn on' IQF
      • Actions -> download n # of days:
        • 0 to download full history of symbol, can take a while
        • 10 to try a test
        • a symbol download will commence
        • there will be a couple of minutes of no activity while the symbol list is scanned
        • data for a series of symbols will start
        • once the message 'Process Complete' shows, the download is complete
      • 'turn off' IQF
      • File -> Exit
  • more apps to be described here ...


Current Market Data Providers and Execution vendors:

  • IQFeed: real time market data and historical data
  • Interactive Brokers: real time market data, real time order execution
  • Alpaca: real time data and order execution
  • Phemex: real time data, order execution (work in progress)

Securities types:

  • Equities
  • Options
  • Futures
  • Futures Options

Libraries used (use my lib-build respository to download and build the various dependencies):

  • wxWidgets
  • boost
  • curl
  • zlib
  • hdf5
  • sqlite (included in source)
  • exelformat (included in source)
  • rdaf aka ROOT - library from CERN providing the cling C++ interpreter - optional

NOTE: The code started out on Windows using Visual Studio, and is now predominately tested on Linux Debian. Some work is required to port back to Windows. There are various Windows based artifacts in various directories. They are not fully functional at the moment.

The lib directory has a series of libraries I use throughout the various projects/applications. Primary libraries include:

  • TFTimeSeries - manage trades, quotes, greeks, level II order book
  • TFSimulation - simulation engine
  • TFIQFeed - engine to talk to DTNIQ Feed for Level1 & Level2 data (ask me for a referral)
  • TFInteractiveBrokers - engine to talk to IB
  • TFIndicators - some indicators
  • TFHDF5TimeSeries - wraps the HDF5 library for storing time series
  • TFOptions - options calculations
  • TFTrading - manages orders, executions, portfolios, positions, accounts,
  • TFVuTrading - provides a number of forms, panels, and related user-interface elements
  • OUCharting - wrapper around ChartDirector for plots and charts
  • OUSQL - which is an ORM wrapper around a sqlite database for maintaining trading records

These are some of the currently supported applications:

  • AutoTrade - code as template for automated trading
  • ComboTrading - basics of trading multiple securities, such as various options strategies
  • BasketTrading - a work in progress for trading futures based options combinations
  • IndicatorTrading - view and trade with futures level II data
  • DepthOfMarket - use a level II ladder to trade futures
  • Dividend - console app to query IQFeed for possible dividend based equity investments
  • Hdf5Chart - view the contents of the hdf5 data set
  • LiveChart - view an instrument in real time
  • IQFeedMarketSymbols - automatically download and decompress the latest mkt_symbol.txt file from dtn/iqfeed
  • IQFeedGetHistory - load up with historical data for looking for trading ideas
  • StickShift2 - some rough code for some option trading ideas
  • HedgedBollinger - some experiments in futures, mostly tracking at the money implied volatility

The announcement on my blog:

Some other, possibly, related entries:

NOTE: During its infancy, the code used MFC (Microsoft Foundation Classes), some Berkeley DB code, and various other modules, which I now no longer support. The code remains in the repository for historical value, and for the time it might be re-written for current use.


  • IQFeed testing: you can utilize the symbol TST$Y, this symbol sends a loop of data 24/7. (2019/03/12)


  • 2022/07/16 additional package requirement (incorporated into libs-build/

    • sudo apt install portaudio19-dev
  • 2022/07/25 additional package requirement (incorporated into libs-build/;

    • sudo apt install libcrypto++-dev


C++ 17 based library (with sample applications) for testing equities, futures, etfs & options based automated trading ideas using DTN IQFeed real time data feed and Interactive Brokers (IB TWS API) for trade execution. Some support for Alpaca & Phemex. Notifications via Telegram [irc: Libra #tradeframe ]








No releases published


No packages published