2
$\begingroup$

What software is available for backtesting trading algorithms written in the C++ programming language? I would not like to use an online service such as Quantopian or Quantconnect (they don’t offer C++ support regardless).

Are there any libraries or applications that can be used for this?

$\endgroup$
3
  • 1
    $\begingroup$ Is my understanding correct that you're looking for a C++ library for creating back tests? $\endgroup$
    – Bob Jansen
    May 24, 2018 at 15:34
  • $\begingroup$ @BobJansen Yes that’s what I’m looking for. $\endgroup$
    – Theodore
    May 24, 2018 at 18:51
  • 1
    $\begingroup$ Quantopian uses zipline (github.com/quantopian/zipline), which is the only open source backtester that I know of. $\endgroup$ May 25, 2018 at 19:25

1 Answer 1

2
$\begingroup$

I developed my own backtesting system for multiple tickers in C++, maybe some of these ideas may help.

Storage: I store every ticker's data into a binary file (one file per ticker), ordered by timestamp. Any other kind of storage (CSV files, SQLITE database), ordered by timestamp will do, for the purpose of backtesting.

Backtesting: I create a priority queue in memory (priority given by timestamp), then I read a single tick from each of the ticker's files and put them into the priority queue, then I start consuming the ticks from the priority queue, lowest timestamp first. Every time I consume a tick, I read another tick from the file from which that tick came out, and put it into the priority queue. In this way I can also simulate a delay for orders going to the market: every time the strategy I'm backtesting generates an order, I put an "order tick" with a delayed timestamp into the priority queue, and I simulate actual execution only when that order tick is consumed from the queue.

$\endgroup$
6
  • $\begingroup$ Would you happen to have any of this on GitHub or anywhere else for us to look at and alter for what we need? Thanks. $\endgroup$
    – Theodore
    Jun 14, 2018 at 5:29
  • 1
    $\begingroup$ The code is messy and in continuous refactoring and the comments are in Italian unfortunately, anyway here it is the backtesting part of my code if you think you can find it useful: github.com/enricodetoma/backtesting It can't be compiled in the present form, because too many other classes are missing, but anyway it should give you an idea of what I wrote in my answer $\endgroup$ Jun 14, 2018 at 7:33
  • $\begingroup$ Thanks, I appreciate it. Will take a look, potentially a new project. I know some Spanish and Google crudely translates Italian to English so I’ll see how I do. $\endgroup$
    – Theodore
    Jun 14, 2018 at 15:19
  • $\begingroup$ I haven't yet decided whether to open source the whole project, being difficult for me to maintain it alone. Or at least share it with a group of contributors. In case I decide that way, I would translate all italian comments before publishing it. $\endgroup$ Jun 14, 2018 at 18:20
  • 1
    $\begingroup$ CQG and IQFEED should be ok for real-time tick data, just to name two. I used CQG. Now I'm using data from an Italian broker for Eurex $\endgroup$ Sep 6, 2018 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.