SkillAgentSearch skills...

Tradery

A C++ library and utility for algorithmic trading system back-testing

Install / Use

npx skills add adrianmichel/tradery

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Submit your feedback on the issues page, or email it to info@adrianmichel.com.

Refer to the Disclaimer and License sections for important information regarding the use of this library.

Table of Contents

Trading Engine

This project contains an updated version of the Trading Engine (TE) previously used on the tradery.com back end.

The purpose of the TE is to run user defined algorithmic trading systems over historical market data of selected symbols with specified configuration parameters.

The main functions of the TE are:

  1. Trading system back-testing
  2. Generation of trading signals
  3. Trading system optimization (work in progress)

Installation and test

TE is provided as a Visual Studio 2019 solution.

Here are the steps to install, build, test and run TE.

  1. Install the latest version of Visual Studio 2019 Community Edition. Make sure to select C++, SDK, 32 and 64 bit libraries.
  2. Install a recent git client.
  3. Clone the tradery repository to a local directory, for instance "<some_path>\tradery".
  4. Checkout "master" branch.
  5. Open a console window (cmd.exe, or PowerShell), cd to the root of the installation directory, "tradery" in our case, and run "bootstrap.bat" from there. This will download and build 3rd party libraries that the TE depends on.
  6. Optionally, go to https://www.advsofteng.com/download.html and download the evaluation version of the charting library for C++ Windows. The TE will build and run with or without this library, but when the library is present, TE will generate an equity curve chart for each session. Extract the files from the downloaded ChartDirector zip file under the "tradery\external" directory, so the directory structure will be "tradery\external\ChartDirector..."
  7. Start Visual Studio 2019 and open the tradery solution "tradery\src\tradery.sln"
  8. Select the desired debug/release, 32/64 bit combination at the top of the Visual Studio window. Please note that the debug version for either 32 or 64 bit will run much slower than the release counterpart, so for the first run which is intended to ensure that everything works as expected, it is recommended to use "release".
  9. Open the Solution Explorer window.
  10. Right click on the solution icon and click on "Build solution". You will see a fair number of warnings in the output window, some of which are inevitable, and others that will be fixed in future commits, but none of which will cause any issues with the application.
  11. Open the Test Explorer window by clicking on "Test/Test Explorer" on the Visual Studio menu bar
  12. In the Test Explorer Window click on the double green arrow (Run all tests). This will start a build if necessary, and then start all available tests.
  13. Tests will run for a few minutes if release version was selected, longer for debug, after which the test icon should turn to a green check mark indicating that all tests have passed.

Objectives

Here is a list of initial design goals, and how they were achieved.

In order to build an online trading simulation platform, issues like performance, scalability, stability, massive concurrent use etc needed to be considered.

| |Objective | Implementation | |----|-------|--------------| |1| High performance for real-time use |- written in C++<br>- multi-threading and multi-processing<br>- use of data caches<br>- compiled system code<br> | |2| Realistic simulation| support for predefined or user-definable parameters such as slippage, commission algorithms, position size, account size, position size limits etc| |3| Support for trading systems from the most trivial to the most complex| C++ based system definition language<br>with many trading specific constructs| |4| Support for various types of market data (e.g. bar, tick)| internal abstraction of data type| |5| Diversification by asset|Support for multi-symbol runs | |6| Diversification by system |Support for multi-system runs | |7| Ability to handle large datasets| efficient data and memory management| |8| Easy to learn and use script-like language| abstraction of complex trading functions | |9| Support for a variety of common or less common statistical and technical indicators| use of TALib technical indicators library| |10| Potential real trading use|Trading signal generation | |11| Ability to objectively assess the performance and risk of a trading system|Generation of a variety of simulation statistical information|

While there are many other programming languages available, C++ was chosen for its flexibility, large number of third party libraries available for any conceivable functionality, and not least, its ability to generate some of the most efficient code.

What is new

This new version contains many enhancements, internal as well as in terms of usability.

  • Ported to Visual Studio 2019.
  • Updated to use recent C++ language features.
  • Generates both 32 and 64 bit binaries.
  • Contains integration tests for validation and regression testing.
  • Can be run standalone command line utility.
  • Contains a large number of fixes and enhancements.
  • Required 3rd party dependencies are automatically downloaded and built using the bootstrap.bat script.
  • Tedious environment configuration parameters are automatically generated so that only relevant parameters need to be set by the user.
  • It automatically detects and takes into account whether the charting library is available when building and running.

This project is work in progress and more updates will be committed based on your feedback.

The Visual Studio Tradery solution

The Visual Studio "tradery" solution contains the following projects:

  • core - implements the various trading language constructs, and coordinates the multi-processing aspects of running the trading simulation sessions.
  • datasource - dll, reads files containing historical data for various market symbols.
  • fileplugins - dll, contains various plugins implementations (datasource, symbolssource, statistics, charting, commission, slippage).
  • filesymbols - static lib, code for handling lists of symbols.
  • include - no target, container for common include files used across different projects.
  • misc - dll, various general utility classes and functions.
  • miscwin - dll, various windows dependent utility classes and functions.
  • optimizer - exe, trading system optimization utility, work in progress (not functional at this time).
  • plugin - static library, plugin related utility classes.
  • runtimeproj - dll, used at runtime to generate "runnable" plugins containing user system code, not built as part of the solution.
  • systemsplugin1, 2 - dlls, sample systems built to ensure there are no system syntax and structure regressions - will be added to the test suite in the future.
  • tests - unit and integration tests.
  • tradery - static library, contains the entry point to the TE, provides high level APIs used to run sessions.
  • traderyconsole - exe, tradery.exe command line utility

Projects are set to use the most recent set of C++ specs supported by the Visual Studio compiler.

Session

In the context of the TE, "Tradery session", "session" or "run" refer to one run of the TE over one set of input parameters resulting in either success and a set of output data, or a failure.

Configuration

To run a successful session, the TE must receive various input parameters such as build environment paths (lib, include and path locations), session specific environment paths (system code file location, data location, output directory), position sizing, and others.

These parameters are passed as one string with the format:

-short_param_name1 [arg1] --long_param_name2 [arg2] ...

Where short parameter names are one character long preceded by "-" and long parameter names are two or more characters long preceded by "--".

Names are, depending on parameter, optionally followed by one argument each.

The argument string should be surrounded by quote marks if it contains spaces.

Some parameters are optional, others are mandatory, and yet others can appear more than once.

A configuration string can be passed to the console utilty on the command line, or programmatically which is the case of tests for instance.

Some or all of these parameters can be stored in configuration files whose path can then be passed as a configuration argument, which makes it easier to reuse sets of parameters that do not change frequently between sessions such as environment parameters.

An example of a configuration string pointing to two configuration files.

--configfile "c:\tradery\some_config_file.txt" --configfile "c:\tradery\some_other_config_file.txt"
`

Related Skills

View on GitHub
GitHub Stars52
CategoryDevelopment
Updated23d ago
Forks28

Languages

C++

Security Score

95/100

Audited on Jul 16, 2026

No findings