Recently I am working to get my new trading platform going. This new version is based on Python, uses MySQL to keep a database of all time series of different virtual currencies with automatic backfill from BitcoinCharts and integrates the 3 major exchanges MtGox, BTC-E and Bitstamp. The platform will be used as way to backtest some strategies and engage in automatic trading.
During the run-up to this I decided to pull some data of BTC against USD from BitcoinCharts and based on the ideas of a paper by Hashem and Timmermann (1995) implemented a simple trading strategy. The idea is to forecast the sign of the t+1 period return based on a regression, which is estimated on an automatic selection of technical indicators during the last n period up until t. Then, after t+1 happened, we refresh the model and try to predict t+2 using all the data available of the last n periods until t+1 and so on.
This backtest was done in Matlab. It is crucial that at no point in time the model has a chance to ‘glimpse into the future’ due to programming errors so utmost care has been taken to make sure the appropriate lags are in place at all time. For this first test I omitted trading costs which vary between 0.2 to 0.5 percent per trade, depending on exchange and trading frequency. Also things like market depth and lag (sometimes exchanges can lag extensively because of high trading volume so order execution is delayed) have been ignored but will be added later.
For input values that can be considered common sense among traders results of the model didn’t vary too much (for example no one in their right mind would follow a 17 hour moving average against a 43 min average even if the the backtest result would be extremely good because those results are likely based on overfitting). Since the model is based on a continuous walk forward approach it would be difficult to overfit it anyway (given a long enough training sample and a small enough estimation window), because at all time only a small fraction of the whole training sample is taken into account to estimate and forecast the sign of the following period return. The model only knows two states: buy and stay out. At no point we go short, also because right now it is (theoretically possible but) difficult and it was in the past not always available.
I tested the model on closing prices of 5 min, 1 hour and 1 day time series on BTCUSD prices from BTC-E and compared the results against the buy-and-hold scenario. It has to be noted that the buy-and-hold scenario of Bitcoin did remarkably well in the past and probably will continue to do so for a while. Time is given in Unix Time on the x-axis and the y-axis is measured in cummulative returns (as mentioned before, this is only a first quick look)
[updated]
Using daily returns from 1313971200 (August 2011) until 1384560000 (November 2013), first chart is the model, second one using buy and hold:
Using hourly returns from 1375041600 (July 2013) until 1384603200 (November 2013), first chart is again the model, second one buy and hold for the same period:
Using 5 minute returns from 1383179700 (31 Oktober) until 1384681800 (17 November), first chart is the model, second is buy and hold:
We observe that the model tends to do slightly better than the buy and hold approach, though it is not immune to sudden drawdowns when the market decides to crash. What it does better during a crash is that it takes those recent movements into accounts and tends to stay out while the market continues to crash. Important to mention here again: all does tests were run without transaction costs. Transaction costs can add up substantially, especially in case of the 5 min and 1 hour model when the model frequently changes positions. Also, despite that the results look interesting, one should not forget that the market can be illiquid at times and that jumping in and out of large positions can incur significant slippage.
An idea why this model currently works is that the market seems to be very inefficient at the moment and driven by a lot of emotions and inexperienced traders. I expect to adapt this model in the future in line with changing sentiments and players in the Bitcoin market.
Given all of this I am quite confident in the results of this analysis and can’t wait to finish implementation into my trading platform to get some real life results.
Reference:
Paper by Timmerman: http://www.jstor.org/stable/2329349
The post Predictability of Bitcoin Returns using Simple Trading Strategy appeared first on MATLAB TRADING.