Market Simulation
Overview
Challenge: Provide a true view on trade strategy performance using historic data, instead of widely available "sum of percent gain/loss"
Solution: Built and deployed a toolset to test trading strategies against actual historical market data using configurable capital allocation strategies
Technologies: AWS (EC2, CodeCommit), Python, Flask, Wireguard
Misleading Returns
There are many-many bots out there that are supposed to generate their users enormous returns. Many times, the performance is presented with charts that shows the "capital" as it grows rapidly. In fact, many such charts are built using flawed math:
Start at 0 (or some arbitrary number)
+ 2.1%
- 1.2%
+ 1.0%
+ 0.5%
End with +2.4% (or at a much higher number...)
These charts do not take into account capital, fees and compounding, and reflect the unrealistic scenario that the user could take all possible trades with 100% of the capital.
Realistic Simulation
In reality, only a portion of the capital would be allocated
to any given trade, and overall performance will be an outcome
of the combination of the trading strategy and the capital allocation strategy.
In addition, exchange fees would likely render trades like + 0.5%
as an overall loss.
The backtesting simulation I developed used a two-stage process:
- Replay the trading strategy against the historical data to identify the events
- Simulate the actual change in capital based on the capital allocation strategy
By splitting the process into two, the longer first step could be executed once for a new trading strategy and then various capital allocation strategies and exchange fee rates could be assessed quickly.
The system allows drilling down into each transaction, assessing the behaviour of the trading strategy in detail, as well as analysing the overall returns.