Home

Awesome

trade-frame

Introduction

This is a:

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.

Example

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

Template

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.

Building

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
wget http://www.iqfeed.net/iqfeed_client_6_2_0_25.exe
wine64 iqfeed_client_6_2_0_25.exe

# interactive brokers TWS for linux
wget https://download2.interactivebrokers.com/installers/tws/stable/tws-stable-linux-x64.sh
sh tws-stable-linux-x64.sh

# install and build initial environment and libraries
git clone https://github.com/rburkholder/libs-build.git
pushd libs-build
./build.sh tradeframe
# rdaf is required for the projects in the rdaf subdirectory - optional
# this is a large install, so recommended only for those interested in the CERN toolset
# will require manual installation of libtorch: https://pytorch.org/cppdocs/installing.html
./build.sh rdaf
# one example uses Wt web library as an interface - optional
# not a recommended install, but provided here as a reference web based app
./build.sh wt
popd

# main trade-frame code
git clone https://github.com/rburkholder/trade-frame.git
# if you have access to the up-to-date private library, use this instead:
# git clone https://github.com/rburkholder/tf2.git

# 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:

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

Background

Current Market Data Providers and Execution vendors:

Securities types:

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

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 this time.

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

These are some of the currently supported applications:

The announcement on my blog: http://blog.raymond.burkholder.net/index.php?/archives/679-trade-frame-c++-securities-trading-software-development-framework.html

Some other, possibly, related entries: http://blog.raymond.burkholder.net/index.php?/categories/23-Trading

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.

Testing

Miscellandous