Quantcast
Channel: Analysis – MATLAB TRADING

Predictability of Bitcoin Returns using Simple Trading Strategy

0
0

Screenshot 2013-11-25 19.30.56

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 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:

Screenshot 2013-11-25 13.36.22

Screenshot 2013-11-25 13.36.42

 

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:

Screenshot 2013-11-25 13.43.57 Screenshot 2013-11-25 13.44.17

 

Using 5 minute returns from 1383179700 (31 Oktober) until 1384681800 (17 November), first chart is the model, second is buy and hold:

Screenshot 2013-11-25 13.51.09 Screenshot 2013-11-25 13.51.22

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.


Bitfinex introduces mining contracts

0
0

Bitfinex announced today the start of mining contracts as a trading product on their platform. In total 100 THS (terahashes per second) with an expiration in 3 months have been made available for trading under the name TH1BTC. The 100 THS are part of a larger pool of 3500 THS so more mining contracts might become available in the future. Interestingly, this marks the first time that it is possible to short a mining contract.

Shorting a mining contract means to receive an amount of Bitcoin now (the price we sell it at) and subsequently paying dividends (in Bitcoin) over the following 3 month until the contract expires in the middle of December. A profit is made if the sum of all the dividends paid out (plus the interest we paid to short the contract) is less than what we received at the beginning when we sold the contract (to someone else obviously).

This means the price of TH1BTC should depend on 3 variables (in decreasing order of importance):

  1. The change of the mining difficulty until 15 December
  2. The time remaining until 15 December
  3. The interest rate (swap rate)

If difficulty increases dividend payments become smaller because 1 THS represents a smaller fraction of the whole network hashing power. Therefore the price of one contract should decrease if difficulty increases. The closer we get to expiration the fever Bitcoins can be mind with 1 THS in total. Therefore the price of one contract should decrease the closer we get to expiration and reach a price of 0 at expiration.

The higher the interest rate the more costly it is to enter and keep the contract over the full length of 3 month. Bitfinex does not offer 90 days swaps, therefore entering a contract with the goal to hold it until the end contains quite a bit of interest rate risk because at some point a new swap has to be taken out (at a potentially unfavorable interest rate). This is less of a problem when going long (Bitcoin rates are typically low) than when going short (there is only a maximum of 100 contracts available in total, no naked shorting). To compensate for the risk prices should increase when swap rates are increasing.

The big unknown is of course the change in the mining difficulty over the next 90 days. In the following figure we see how difficulty changed over the previous 6 month.

Change in difficulty over previous 6 month

The data is from Tradeblock and it shows not only a graphical representation of past changes in the difficulty (difficulty changes every 14 days depending on past hash rate. More info can be found in the wiki) but also some basic summary statistics. On average difficulty has increased 27% over the last 30 days and 77% over the last 60 days.

To estimate the fair price of one TH1BTC we will assume that difficulty will increase on average 15% per month over the next 3 month. Currently the price of buying one contract worth 1 THS is 2 BTC. The pool fee is 3% and we will ignore interest rates. Filling in all the information we get the following results:

Inputs and Results

Hence if we go long one contract based on our assumptions we would make a loss of about 0.39 Bitcoin (a bit more in reality since we will start mining in the middle of September until the middle of December) because the expected dividends (monthly revenue) is not going to cover our initial costs of 2 BTC before the contract expires.

On the other hand, going short at a price of 2 Bitcoin would have generated a profit of about 0.39 Bitcoin per contract. Keep in mind that we didn’t include swap costs which are currently at around 1% per day (!).

There are two ways to look at the results. Either we could say prices for TH1BTC are currently overvalued and should be closer to around 1.5 BTC. If we assume difficulty will increase more than 15% per month then prices should be even lower than that. Or we could say that the market is efficient and prices are correct, which would imply that the market is expecting difficulty to decrease on average about 2% per month over the next 90 days. Either way, results will be known with certainty in 90 days.

The post Bitfinex introduces mining contracts appeared first on MATLAB TRADING.





Latest Images