Introduction to MMTP
The Man-Machine Trading Partnership
MMTP is a software program built for the purpose of experimenting with algorithmic trading.
The project is entirely written in C++, operating on Linux and its first git commit was entered on December 24, 2014. From July 2015 to July 2016, MMTP was used for trading real money on a bitcoin exchange and achieved a net return over investment close to 50%.
The term "partnership" in the project's name comes from the idea that software alone is unlikely to succeed without human guidance and a man on his own would not achieve as much without the machine's abilities.
The project is privately owned and operated.
Influences
The two main influences come from Game Theory and Markov Decision Processes. Using these, trading is modeled as an endlessly repeated game, or a game with an endless number of states and transitions. Either way, the goal of the project is to figure out the best action to take at every turn.
Implementation
The project makes full use of the multi-paradigm capabilities of C++. Certain concepts are implemented in classic object-oriented fashion with inheritance and polymorphism and others take advantage of generic programming with the use of templates and lambda expressions. Parallel programming is also used as part of machine learning algorithms. Networking over TCP is used as a means of inter-process communication between nodes of the MMTP system. A unit-testing framework is built into the project and preprocessor macros are used to ease the writing of unit tests.
The code can be divided in two kinds: library code and user code. Together these define the means and the ends respectively. The library code is solidified by use of test-driven development and each tests are run at startup every time user code is executed; if a single test fails, the program will refuse to start. The user code is often more difficult to surround with tests, so the test-driven development philosophy is not adhered to as strongly when working on those parts of the project, however an attempt is still made every time.
The library code of the project makes intensive use of many well known design patterns such as the Factory, Singleton, Bridge, Composite, Flyweight, Observer, Strategy and Visitor patterns.
The code has dependencies with the standard C++ library, the Boost library and SQLite3. And, aside from a few small dependencies on the Linux operating system, the programming should be easy to port to another OS should there be a need for it.
Some facts about MMTP
At the time of this writing, MMTP is...
- 118 code files (*.cpp), 87 header files (*.hpp) and 15 templates definition files (*.templates.hpp)
- 37531 lines of code
- 1472 kilobytes of code
- 95 classes, 22 structs and 18 template classes
- 21 unique namespaces (several of them nested)
- 380 commits in git
- 184 unit tests executing in an average of 70 milliseconds each and each having been executed hundreds of times
- Zero memory leak, as observed using valgrind
- Zero compile-time errors
- Zero compile-time warnings
- A single author for all this
From July 2015 to July 2016, MMTP traded bitcoins 24/7 on Kraken.com...
- It made 1165 trades consisting of one market buy order followed by one limit sell order, all of them profitable.
- The trade with the shortest duration was 18 seconds and the longest was 206 days
- The average trade duration was 3.38 days
- The least profitable trade gave a profit of 0.02 € and the most profitable gave 0.37 €
- The average profits per trade was 0.038 €
- The sum of profits during operation was 41.32 € and the initial investment was 91.20 €
- The estimated annual ROI based on the last 6 months of operation is around 70%
- It required a few minutes of human intervention on a daily basis in the first 3 months, on a weekly basis during the next 3 months and no intervention was necessary for the remainder of the experiment.
While MMTP exceeded expectations, its live operation was stopped in July 2016 to allow its development to continue. The features that have since been added allow multiple algorithms to work in parallel, each following a different strategy, possibly trading different assets on different markets. It also has the means to be fault-tolerant to power and network outages and it can be scaled to spread the various workloads on multiple computers.
--end-of-document