My Algorithmic Test Centre

Rationale behind this strategy

After having studied Finance for over 5 years, the top 2 question that I get asked every time I tell someone about stock trading is “What is the return?” and “How much did you beat the market by?”. Although these questions are quite important but there is more to learn in Finance than just beating the market. Not everyone has the objective of making a large profit; some people may even want wealth preservation strategies, or even hedge themselves from risk they don’t want to bear.

Although I was initially wanting to make a market beating strategy, but the forward testing actually give me quite a surprise: A beta neutral strategy.

I believe that Hedge Funds started out with the same basic ideology; a fund setup for/by high net worth individuals so that they can hedge their portfolios against certain risk they were exposed to and didn’t want to take (i.e. turning themselves “market neutral” vis-a-vis that particular risk). Although the definition of a Hedge Fund has changed over the years (with the advent of double digit alpha funds), i believe they were originally meant to serve this purpose.

Basic Code

I have been messing around with some code on Quantopian’s backtesting platform and started running some very simple code on moving averages.

Screen Shot 2016-02-03 at 16.29.14

What the Algo does

I picked 3 ETFs as I felt they might outperform the market index and have better long term growth opportunity:

XLY a Consumer Discretionary Fund

XLK a Technology Fund

XLV a Healthcare Fund

I then went on to add two Moving Average parameters, namely:

MA1: a 100 day moving average

MA2: a 200 day moving average

Finally I set the conditions that “if” the 100 day moving average is greater than the 200 day moving average, then buy the ETF at the tune of 11% of the portfolio. If the opposite conditions exist then short sell the ETF at up to 11% the value of the portfolio

Backtesting the Algo

Screen Shot 2016-02-03 at 16.51.47

Well the strategy does not beat the market but follows it quite closely. It falls when the market goes very bearish, but on the whole it reduces the volatility quite a bit. Thats to be expected as moving averages are meant to look at data from a longer time horizon (in this case 100 and 200 days) and smoothen out the noise and volatility. The drawdown is visibly low at just under 4% which I think is pretty decent when compared to the market portfolio.

Live Testing

I have only live tested this algo for 1 day but the effects of what its trying to do is quite visible. There is however a problem with the Quantopian platform that the 100 and 200 days on the moving average is now considered as 100 and 200 minute average price. So its trading based on short term horizon of minutes rather than days.

Screen Shot 2016-02-03 at 17.00.04

The cool thing about using this with minute data is that this strategy is almost market neutral at this point! Although I would like to see what happens with a large rise or fall of the market index, the short term bias on the moving average means that constantly keeps up with the current market prices and rebalances itself quickly.

Live Trading Stats

Screen Shot 2016-02-03 at 17.05.47

With the exceptions of a few spikes, which are attributable to the fact that a market order is pending to be executed to rebalance itself, the beta is keeping itself quite close to zero. By doing this it is basically taking the market risk off the table !



My Algorithmic Test Centre