(I'm joking about the cheese)

Monday, 27 June 2016

Obligatory Brexit ex-post (Survival, Skew, Politics & Data, )

This is a two part post which blends my favourite subjects: finance, economics, and politics. It's about the stunning victory of the "leave" campaign that has left the UK facing a period of serious uncertainty.

Part one is an ex-post update on whether my portfolio was as robust to Brexit as I hoped it would be in my last post. This is based on market moves on Friday; of course things will continue to move as the full ramifications are digested.

Part two explains how Brexit was a classic negative skew event in more ways than one, how behavioural finance can help explain that, how it was mispriced by the markets, and how I used that information to make a little bit of money.



Say hello to our next Prime Minister. Source: The Sun


Did I survive Brexit?


Yes.

Let me expand.

Trading in GBPUSD


I made no money at all trading cable, the asset most exposed to Brexit. In fact I lost some. When I wrote my last post I had no position in GBPUSD IMM futures. However the swings in sterling sentiment were reflected in first a sell:

11242 GBP 201609 2016-06-15 02:38:16 -1 1.412600

And then I closed that as GBP went stronger in the post Jo-Cox* bounce in remains polling figures.

* It feels wrong to be talking about her tragic death in a grubby post which is mainly, at least at the moment, about money. However it seems likely that what happened to her was clearly linked to the referendum campaign. I had the privilege of briefly seeing her in person. She was on the select committee which I appeared before last year (16:20:00 on the timestamp of the video feed onwards), and I was very impressed with her performance. I'll be doing the politics of this later.


11296 GBP 201609 2016-06-17 18:54:08 1 1.434800

As with a typical trend following system in a range bound market I sold low and bought high. And a further opening buy almost exactly 24 hours before the result would become clear, as the world decided remain was a shoe in (more about this below).


11461 GBP 201609 2016-06-23 02:51:41 1 1.483000

Then, of course it all went wrong. The pound got smashed. With a reversing price and volatility going through the roof, the system closed out it's position.


11509 GBP 201609 2016-06-24 03:54:26 -1 1.366400

Although the price continued to collapse it to around 1.33 then recovered, and closed at pretty much the same level. As I'm writing this the pound is drifting lower, but I have no position to take advantage of this.

I lost the equivalent of nearly 2% of my portfolio on that one lousy GBP contract, about 1.25% of which was lost on the day.

The rest of my futures portfolio


Fortunately, as I said in my last post:

"It doesn't even look like a strong "risk on" or "risk off" theme, though I look to be a little bit more "risk off"."

Yeah, I got that right. I made it all back on the rest of my portfolio. In order of importantce: US bonds and Eurodollar, German bonds (makes sense), Korean bonds (who'd have though it - Korea a safe haven from the UK...), French bonds (the irony) and JPYUSD (though I gave that all back on AUDUSD).

I had no position in Gold, but you can't have everything.

I lost a bit on short positions in VIX and V2X.

Net-net on the main futures portfolio I made a little under 2.5%. Not as much as Crispin Odey is supposed to have made, but then I would imagine he would have hurt a lot more than me if the result had been as expected.

The point here isn't so much "ooh look I made money isn't my system clever" - it is pure luck how much anyone makes on a single day, but that my risk was well managed, such that a 6 sigma event in the markets translated into roughly a 2 sigma portfolio move based on my expected risk going into the vote.


Equities, currency and hedging


Again, from the post:

As I've said before my futures trading account is funded by a long stock position, which is in a mixture of UK stocks and a European ETF IDVY; hedged by a Eurostoxx futures short. This is a more interesting little portfolio; ignoring the effects on stocks if the pound gets hammered then in GBP terms this portfolio will go up in value - there will be a gain in the value of the ETF but the futures hedge won't move since it's unaffected by currency movements.


I was close here. The Eurostoxx did get hammered, more than the FTSE so I got that wrong. However it did indeed lose less in GBP terms because of the devaluation.  Also the UK shares I hold in this account didn't do half badly. Net-net the long stocks plus hedge added another 2% or so.

I also have a long only, buy and hold, portfolio of UK stocks and ETF's covering bonds and equities across the globe.

Here are some more quotes from my Brexit post:

The ETF's are not currency hedged, so a GBP devaluation following brexit would benefit them

This is exactly what happened. The only ETF in my main portfolio that fell in £ terms was a high yield Eurostoxx beast, which suffered from the huge fall in banking shares which wiped out the EURGBP revaluation benefit. All my other ETF's were up in £ terms.


The effect on stocks is a little tricker to predict, but I would imagine my UK stocks would hurt - perhaps 5% at worse? A huge one day drop which will probably be partly reversed, but not the end of the world.

The FTSE100 was down 3.2% at the close, the FTSE 250 7.2%. So on average 5% was a good guess. Some of my UK stocks did much better (Glaxo was up), others much worse (Intermediate Capital Group was done over 14%). 


Overall in my long only account I was flat.

This isn't genius trading, but at least if the book sales fall short then I could probably get a job as a risk analyst.

All of this is on a T+1 analysis. We don't really know how things will pan out over the next N years whilst this little mess gets sorted out.


Brexit as negative skew


Cameron, David


I tweeted a lot on Friday. Here is one of my first efforts:

https://twitter.com/investingidiocy/status/746240000073728000

"Cameron took on the classic short vol trade - high probability of success, small upside, huge downside. And lost.

That is pretty self explanatory. Cameron acted like a muppet running a hedge fund.

"Muppet" is a term of abuse in the south east of England meaning "Idiot". I don't mean an actual Muppet. I have a lot of respect for Kermit. I think he'd make an excellent hedge fund manager. Source: https://autonomousmind.files.wordpress.com/

Your typical muppet HF manager will keep selling OTM options. They kept expiring without value, leaving him with the premium. He begins to confuse luck with skill; he thinks he was invincible. This is the classic behavioural finance effect of overconfidence. Then one day, he blows up.

Why was the referendum like an OTM option?

Firstly, it looked like a forgone conclusion. Promising a referendum was a cheap way to beat down the nascent UKIP vote in last years election (the vote still hit historic highs, but thanks to our bonkers electoral system they were unable to achieve concentrated support to win more than one seat in parliament). It would be so easy, just a half baked (and suspiciously quick) negotiation with the EU to get superficial concessions, hold the referendum, bish-bash-bosh with the handy side effect of destroying his main political rival (By which I mean Boris Johnson. Not the labour party).

Yes there were some tense moments, but he never looked ruffled, or looked like he ever thought he would lose. This looked like a high probability event, but the downside, which doesn't seem to have been properly considered, was enormous - both politically and personally.

Secondly, it had a small payoff if it succeeded. Without the referendum I think it is incredibly unlikely that Boris would be a serious contender for PM.

Thirdly it had a large cost if it went wrong. Both personally, politically and economically.

Overconfidence often seems to affect people from privileged backgrounds.

The whole country is paying for the fact that Cameron has had a smooth path through life with nothing going really wrong. There are many articles in the press pointing out how he's been lucky with several political gambles over the years. Even having to go into coalition with the Lib Dems was a blessing, giving him an excuse to keep the right wing of the party at bay whilst holding Nick Clegg in front of himself to take all the flak for the politics of austerity.

All this made him think he was invincible. Similar (dare I say?) to the careers of many financial traders and asset managers, many of whom come from privileged backgrounds and who sailed through life without failing at anything*, who confused luck with skill, became infected with the fatal disease of hubris; before the inevitable blow up.

* Full disclosure: The author of this blog was privately educated and was admitted to the worlds best university (the first generation in his family to go on to higher education, make of that what you will), but soon found he wasn't as clever as he thought he was, and left after one year. A series of random unconnected jobs followed. On first coming into contact with the financial sector with a job as a trader he hated it. So yes, I've been lucky, to have screwed up my life royally many many times.

Finally both hedge fund managers and David Cameron have the advantage of a fairly soft landing if things go wrong. Collecting 2 and 20 for a few years on a few hundred million or more can set you up for life. Cameron has more than enough personal wealth, his wife still works, and even with his ignominious exit could easily rack up a few million quid a year "advising" banks and private equity firms (a case of "don't do as I did, do as I say"?).


A fair payoff for negative skew


Now, taking negative skew bets isn't automatically a bad thing, if they're fairly priced. The minimum one should accept is something that gives you zero expectation. Ideally you'd get more than this, a lot more, since most reasonably people have a utility function that hates negative skew.

So if the probability of an event is P, and the payoff is a, with a loss of b if the event doesn't happen:

b>a  (definition of negative skew)

aP >  (1-P)b



NOT a black swan. A white one with one grey feather


Before I continue, I'll just point out that Brexit was NOT a black swan - an inconceivable event with a tiny probability of happening. Even at the widest odds the implied probability of the event was more than 10%.


The City, The Bookmakers and The Polls


It wasn't just Cameron who got the probability of this event wrong, it was everyone.

On the day before the referendum implied currency volatility was pricing in something like a 20% chance of Brexit happening:

" on BBG, prob derived from FX options for leave is 19% - but guessing the spread is huge to do the arb trade!!!"

twitter  with thanks to Saeed Amen

Similarly on the betting markets the decimal odds on betfair were also implying roughly a 20% chance, although this was moving around (see image - not up to date, but gives you an idea of the volatility)




It was clear to me that 20% was far too low. See these opinion polls.

Source: Financial Times


Notice that:


  • The vote was on a knife edge; with neither side getting a clear advantage (say 60:40) in any poll
  • There is considerable variation across time
  • There is considerable variation across polls
  • The undecided figure, although narrowing over time, was still averaging about 6% at the end - easily enough to swing it one way or another.
  • Polls have margins of error (MOE), which are shamefully absent from public discourse. Most polls of the size done in the referendum campaign would have MOE of 3-5%. Polls of polls have a smaller MOE; maybe a couple of percent.

Personally I thought on Thursday that given the final poll of polls figure of 48:46, with undecided at 6%, and an MOE of a couple of percent.... well this wasn't an event with just a 20% chance of happening. It was pretty close to a coin flip; but let's call the odds of remain P=60%. But the ratio of the two payoffs in the betting market was more than 5.0 (decimal odds of 1.2 and 6.0 respectively). So the expectation of the two options is:


0.6 x 1.2 = 0.72 
0.4 x 6.0 = 2.4

The second option (betting on leave) is clearly more attractive than the second.

Why this apparent mispricing? Well the markets (betting and FX) move depending on weight of money. Mostly wealthy well educated people of a higher social class play in both markets. Exactly the sort of people who voted remain. They ignored the polls and focused on their own prejudices. Again this is behavioural finance at work. Could be one of several effects, but lets go with narrative bias. The "story" that Brexit was terrible and nobody would vote for it was more attractive than the statistical evidence in the polls.

That is the specific effect. But generally people are really bad at understanding data when measured with uncertainty; and this is particularly dangerous when the outcome is binary - people will naturally try and assign probabilities of 100% and 0% to binary options.


My little flutter


So how best to exploit this? A straightforward way would be to sell GBP eithier in USD or EUR. Or do the same thing via options, although note that buying OTM options is an expensive business due to the spread. You could also bet on the outcome.

However although all of these bets have positive expectation, it will also on average lose money (assuming there was say a 60% chance of remain). Since we can only bet on brexit once this is somewhat annoying.

I opted for a combination trade (and here); a bet on Betfair on Brexit, and a purchase of GBP against EUR (so a bet on remain). I sized the latter trade so that my expected payout in the event of eithier remain or leave would be the same.

Actually I probably got the size wrong. I doubt that GBPEUR would have rallied enough with a remain vote to make up for my loss on Betfair. The resulting depreciation of GBPEUR was also relatively small; as it turned out Brexit is bad for Europe as well and all the capital fleeing to safe havens went to America - it was GBPUSD that really got crucified.

As a result I ended up making much more than I expected (also here) on a leave vote. However this was a fun trade done for relatively small amounts of money. This kind of global macro discretionary trading isn't my forte. It seems like a lot of work.


Summary



Generally betting on a coin toss isn't a good idea, unless the market is mispricing the chances of heads as just 20%.

However these opportunities are few and far between, and require a lot of work and analysis. Systematic trading is far easier. A properly structured (diversified, risk managed) investment portfolio or trading system will not be vulnerable to shocks like Brexit. 

So I made some money. I take absolutely no pleasure in this because I genuinely feel it was the wrong decision which will have, and already has had, terrible consequences (both economically, and in a sharp rise in racism). There is already discussion that Brexit may never actually happen; I hope this is the case.


Tuesday, 14 June 2016

Obligatory Brexit post

I've had a few questions along the lines of "what are you going to be doing to prepare your trading system for Brexit?" (and I'll admit there is a strong element of bandwagon jumping here). The short answer is nothing. The slightly longer answer forms the rest of this post.

(This is not a post about whether we should be in or out. If you're interested, I'm voting to remain. Rather than retread all the arguments about this I can't do any better than recommend you read chapters 8 and 9 of this excellent book.  If you're too lazy to do that then I will point out that nearly every respected economist or grouping thereof has suggested that leaving will have significant negative economic costs. I could also point out that you probably shouldn't be voting unless you've done some proper research first.

Any blog comments attempting to engage me on the political side of this debate will be deleted. That's what twitter is for guys.)

Nigel Farage used to be a commodities broker. Draw your own conclusions. Source: mirror.co.uk (photo shopped of course, but too good not to use)


Change of direction

Firstly should I change the direction of any of my trades? For example, put on a short GBPUSD position in anticipation?

Lest you've forgotten I run a systematic trading system, trading nearly 40 futures markets across the world. A couple of important points there. The first is the "across the world" bit. Quite a lot of the portfolio will be mostly unaffected by Brexit. 

The second, more important, point is the word systematic. I didn't put "systematic mostly, except when I feel like putting on a different position".  If you want to trade in a discretionary way, be my guest (though you'd still benefit from using a systematic position management framework like the one described in my book). But if you're going to trade systematically, then do it properly. We can't backtest these kinds of interventions, yet we made money in our backtests.

Actually I'd seriously question why anyone would bet on Brexit. It's a very close run almost binary event and there is no insider knowledge available (though this might work and even then the exit polls on a very close vote might come out wrong). But it's your money.


Change in risk

This is a more interesting point. I scale my positions according to expected risk. But for expected risk I actually use historic volatility. What I do not use is option prices, i.e. implied volatility. Now if you have a terrifying binary event approaching then historic volatility may well not reflect the true uncertainty in the market. 

It's not the same time scale but going into payroll numbers the market often becomes eerily quiet but if you wanted to sell one week vol you'd get a much bigger premium (this is something the author did whilst still trading options at an investment bank. Never again).

It does seem reasonable then that we should increase our expectation of volatility, and thus cut our positions, to reflect the upcoming Brexit event.

(If this is a subject you're interested in it would be remiss of me not to plug this excellent paper)

In practice however I am not going to reduce my positions. This is for a few reasons.

Firstly I don't have a GBPUSD position, or indeed EURUSD, although I suppose I could stop myself taking any on before polling day. My positions in other markets are less obviously exposed to Brexit.

Secondly historic cable vol is actually pretty high already, reflecting the swings in the polling numbers. Using realised instead wouldn't make that much difference. 

Thirdly, and most importantly, this isn't something I've done systematically before or properly backtested. I don't have the technology or the time to implement this properly, and frankly the benefits would be very small compared to other projects I want to work on so I probably never will. It's not worth doing in a half assed way. 

Note that large hedge funds like my former employers AHL do use implied vol as an input into position scaling, but then they have the time and the resources to do it properly.


Just out of curiosity...


Out of curiosity I thought I'd see if my portfolio looks to have a strong sensitivity to an in or out.

I don't trade FTSE, but even if I did it would only be a few percent of my portfolio. I trade both GBP and EUR against the dollar, but as it happens I'm flat in both right now. I trade European equities, which I guess could suffer a bit, and also short European equity vol. I'm long german bonds, which I guess might go up, and French bonds which might do anything (probably go on strike). 

My biggest positions right now are: long soybeans, Eurodollar, French bonds, short VIX, long US 20 year bonds, bunds, short copper, long Korean bonds and long the S&P 500. Apart from the French bonds and Bunds there is nothing there that is exposed to Brexit, and even these will be second order effects. It doesn't even look like a strong "risk on" or "risk off" theme, though I look to be a little bit more "risk off". Overall my risk is around 3/4 of the long run average, reflecting relatively weak signals.

I trade pretty slowly, so it's unlikely this will change before polling day. As always diversification is the best weapon against instrument specific risk.


Equities, currencies and hedging


In fact my biggest sensitivity to Brexit is in the non-futures part of my portfolio. I have some UK equities that I trade purely systematically (though not automatically), and a buy and hold diversified portfolio of ETF's covering various asset classes and countries. Again it's "buy and hold" not "buy and then sell if I get a bit scared with some tactical trading when I feel like it". There will be no trading here.

The ETF's are not currency hedged, so a GBP devaluation following brexit would benefit them (I measure everything in GBP value), ceritus paribus. The effect on stocks is a little tricker to predict, but I would imagine my UK stocks would hurt - perhaps 5% at worse? A huge one day drop which will probably be partly reversed, but not the end of the world.

As I've said before my futures trading account is funded by a long stock position, which is in a mixture of UK stocks and a European ETF IDVY; hedged by a Eurostoxx futures short. This is a more interesting little portfolio; ignoring the effects on stocks if the pound gets hammered then in GBP terms this portfolio will go up in value - there will be a gain in the value of the ETF but the futures hedge won't move since it's unaffected by currency movements.

I try and keep my currency balances spread fairly evenly, so I do have some Euros for margin purposes and a bit extra which again could gain in value.


Conclusion


It's my policy (read this) to rarely intervene in my portfolio (this was the last time when 2 year german interest rates went below zero - 10 year rates have now done the same but I'm still trading bobl and bunds since their volatility has remained high enough). So it shouldn't be a huge surprise that I'm not intervening now. 

Handily it doesn't look as if Brexit will affect my portfolio too much, since otherwise it would be more difficult than ever to sit on my hands - something that is usually the best course of action.


Wednesday, 8 June 2016

Capital correction (pysystemtrade)

This post is about how should you adjust the trading capital you have at risk given the profitability (or not) of your trading account.

I'm posting this for three reasons. Firstly it's a pretty important topic. I address, in some detail, how to set your risk target for a given amount of trading capital in chapter 9 of my book. I only briefly discuss what you should do thereafter, once the size of your account changes*.

* There was actually a lot more on this in an early draft of the book, but I had to do some drastic editing to get it down to a size when it could be lifted with one hand.

Secondly in my open python backtesting package pysystemtrade there has been as yet no facility for variable capital - the trading capital is fixed. I've lost count of the number of people* who have asked (a) if the capital is fixed, (b) why the capital is fixed, and (c) if I plan to modify the code so the capital changes over time. It's probably one of the most requested features (the others being the ability to pull in futures prices from quandl.com and stitch them... don't worry it's coming... eventually).

* Actually I haven't. As of the time of writing exactly eleven people have asked about this.

In the first part of this post I'll explain more about the difference between fixed and variable capital. The second part will discuss the different methods of adjusting capital that I think are reasonable to use. In the final part I'll show how to use the latest and greatest version of pysystemtrade to work with adjustable capital in it's various guises.

A very quick primer on capital


For those who haven't read my book let me briefly explain the concept of risk capital. We assume we're prepared to lose a certain amount of money, say $250,000 (I'm using US dollars, because according to Google most of the readers of this blog will shortly be living under the yoke of President Trump or Clinton). We then decide how much risk we want to take on that, which I measure in as an average of annualised volatility of returns over a long period. At 10% annualised risk, that would be $25,000, or around $1,560 per day. That figure is then used to scale our positions; if we doubled our risk capital our positions would also double.

This post then is essentially about whether the $250K is a fixed number or variable.


Fixed versus variable capital


If you understand the difference between simple and compound interest, then you already know the difference between fixed and variable risk capital. With fixed capital if you earn a 5% return on £100 (£5), and then lose 5% the next day (also £5), then you will be flat and still own £100. With variable capital you will earn a 5% return on day one, and then have £105. A 5% loss on day two starting with £105 is £5.25; bringing you down to £99.75.

This quote may be apocryphal. Einstein probably wasn't that into finance. Though had he been alive today, he'd probably have got a job as a quant in a Swiss investment bank instead of as a patent clerk. And he would never have had time to write ground breaking physics papers.
Source: http://www.rohitdhir.com/compounding-the-8th-wonder/ 


This is easily illustrated with a few pictures. Here I've generated 20 years of monthly random Gaussian returns in a spreadsheet, with an annualised Sharpe ratio of 1.0, and a standard deviation of 20%.


Column G: Fixed capital, Column H: Variable capital

Column G: Fixed capital only to make the picture clearer

Column H: Log scale of variable capital
Notice that:


  • The variable capital line grows much more than the fixed capital line.
  • Over time the volatility of the variable capital line increases.
  • On a log scale the variable capital line looks exactly like the fixed capital line; though the numbers on the y axis are different.

Traders who aren't used to the idea of targeting a particular risk level will usually think in terms of variable capital. If you're a long only unleveraged stock investor this makes complete sense; your risk level will naturally grow with the size of your investments unless you sell on gains to keep risk capital constant. Derivatives traders who don't have a full and complete understanding of the right way to do money management often trade arbitrary sizes, low to begin with and then step suddenly, or pyramid up on individual positions. For them risk capital will be all over the place.

Notice here that I'm assuming that the variable capital grows and shrinks with the percentage returns that we're making. I'll look at a different ways of doing capital correction later in the post.


Why looking at constant capital account curves usually makes sense...


I find it extremely difficult to look at variable capital lines. Returns are barely visible at the start of the backtest, and look scarily huge at the end. They are fine for short backtests of a few years (unless you have a very high risk target and /or performance in which case compounding will happen quicker). However you need decades of data to have confidence in your performance.

Take for example the drawdown that happens around month 210 in the simple excel charts above. On the variable capital line this looks as severe as the earlier drawdowns such as the one up to month 85. But in reality it's nowhere near as bad.

It's for this reason that pysystemtrade up to now has used fixed capital (and will continue to do so apart from a few extra methods I'll discuss below).


When variable capital might make sense

As far as I can tell the only reason you would want to use variable capital is to fantasise about how rich you will be if you run your system for 20 years; and how you'll be pushing around the Eurodollar market with the thousands of contracts you'll need to trade (see below for more on this).

The other reason you might use variable capital in a backtest is to test out your chosen method for capital correction, and see what effect it has. Again, more on these below.

It might also make sense if you want to know if your bet size is Kelly optimal, in which case you'd want to generate variable account curves using different leverage, and pick the one with the highest terminal account value (which is equivalent to the maximum log utility or geometric mean). This is a lot of unnecessary work and will probably result in you having too much risk, rather you should use the rule of thumb based on the Sharpe ratio and skew I discuss briefly here, and in more detail in chapter 9 of my book.



Live trading


In live trading you're probably going to want to use some kind of variable capital. The main reason for this is that the first rule of money management is to scale your risk down when you lose money. The famous Kelly criteria implies that if you lose 10% of your money, you should reduce your bet size by 10%, or using my measure of risk your annualised volatility target should come down by one tenth. Long only unleveraged investors don't have to worry about this, it just happens naturally.

In theory this means you can never lose all your money (just 99.999999% of it...!); although this ignores the fact that prices jump and we can't trade continuously.

However you may also be interested in earning a compounded return on your assets. Again Kelly says you'll maximise your expected geometric return (and final account value) if you increase risk capital when you make profits (assuming you weren't targeting a Kelly fraction bet that was too high to begin with). I'll discuss these options in more detail below.

Normally in live trading you'd key your risk capital calculation straight off the brokerage value of your account, which will be more reliable than your back-tested p&l. Future versions of pysystemtrade will include the ability to do that.

Notice that you will need to think about how to handle withdrawals and deposits from your account. If you want to take money out / put money in but keep the same risk then there needs to be some kind of manual adjustment to your account value.


The three methods of capital correction


Fixed capital


This is the trivial case where our capital doesn't change regardless of any losses or gains we make. Here's an example:



Capital % profit Profit Cum profits Drawdown
100.00 1.00 1.00 1.00 0.00
100.00 -2.00 -2.00 -1.00 2.00
100.00 -1.00 -1.00 -2.00 1.00
100.00 3.00 3.00 1.00 0.00
100.00 1.00 1.00 2.00 0.00
100.00 3.00 3.00 5.00 0.00
100.00 -1.00 -1.00 4.00 1.00

Full compounding


This is the case where we increase capital for losses, and reduce it for gains. Here's an example using the same % profits as above:


Capital % profit Profit Cum profits Drawdown
100.00 1.00 1.00 1.00 0.00
101.00 -2.00 -2.02 -1.02 0.00
98.98 -1.00 -0.99 -2.01 2.02
97.99 3.00 2.94 0.93 0.99
100.93 1.00 1.01 1.94 0.00
101.94 3.00 3.06 5.00 0.00
105.00 -1.00 -1.05 3.95 0.00
103.95



Half compounding


This is the method that I use. Any losses are used to reduce risk capital. Any gains that bring us up to the point where we recover those losses are used to increase capital. However once we are at the original capital level again we don't increase risk if we go above this. Any further drawdown off the new high water mark (HWM) will mean risk capital is reduced. If you like you can think of this as running a hedge fund with a 100% performance fee.


Capital % profit Profit Cum profits Drawdown
100.00 1.00 1.00 1.00 0.00
100.00 -2.00 -2.00 -1.00 2.00
98.00 -1.00 -0.98 -1.98 0.98
99.02 3.00 2.97 0.99 0.00
100.00 1.00 1.00 1.99 0.00
100.00 3.00 3.00 4.99 0.00
100.00 -1.00 -1.00 3.99 1.00
99.00




I find it suits me since I live partly off my trading income; I'm not letting it "roll up" for use when I retire. So I have to pay taxes (so I can't use all the income) and because I already run my account at the maximum risk I'm comfortable with. It makes it psychologically easier to be a trader; I can treat my trading account as an investment that periodically and randomly generates a "dividend" in the form of the "performance fee"  (profits over the high water mark); but which otherwise I can't touch. It also means my maximum loss is limited to my notional starting capital. 

It's possible to use a partial compounding method, between half and full compounding. "Three quarter" compounding would mean taking half of any profits generated above the high water mark and adding these to risk capital; losses below the HWM would still impact on capital in their entirety. This might be suitable if for example you wanted to reserve a proportion of your profits to pay taxes. I haven't implemented this.


Capital in pysystemtrade


Quick and dirty


If you are just curious how your account curve will look with compounding, then there is a new method for any account curve type object: .cumulative() which will give you a pandas Series of cumulated returns with a compounding effect. You can plot this, and also run the normal statistical methods, but their results won't be accurate due to the volatility changing over time.



More accurate with positions for live trading


For live trading you are going to need to be able to see what impact your capital correction has on your actual positions.

The existing portfolio object method system.portfolio.get_notional_position outputs notional position, based on the notional fixed capital and risk denoted by the config parameters: percentage_vol_target, base_currency, and notional_trading_capital.
It also calculates some buffers used to reduce over trading with get_buffers_for_position (using the concept of position inertia defined in chapter 11 of my book).

The accounts object now has a new method system.accounts.capital_multiplier(). The capital_multiplier is a number we multiply the notional trading capital by. So if this is just a string of 1.0 then we're using fixed capital. Numbers less than 1.0 indicate we have less capital than we started with, and so on. The function specified by the config parameter capital_multiplier_func (which defaults to syscore.capital.fixed_capital will determine how the multiplier is calculated.

Use syscore.capital.fixed_capital, syscore.capital.full_compounding and syscore.capital.half_compounding as desired.

In live trading I'll eventually be replacing this with a function that uses the actual account value.

Then there are new portfolio methods  get_actual_position and get_actual_buffers_for_position. These return the notional position, and buffers, multiplied by the capital_multiplier. Augmenting the existing accounts method get_buffered_position is get_buffered_position_with_multiplier.

Finally there is a new accounts method system.accounts.portfolio_with_multiplier(). This calculates the p&l of the entire portfolio using the actual positions (rather than the notional positions with fixed capital used by system.accounts.portfolio).

There's some more information in the user guide here.


The three methods with pysystemtrade


To illustrate what's going on with a specific example, here are some plots. In all cases I'm using the standard system from chapter 15 of my book. I've chosen the Eurodollar market as it performs especially well, hence we can see the effect of compounding more clearly. Here's the basic system:


from systems.provided.futures_chapter15.basesystem import futures_system
from matplotlib.pyplot import show

system = futures_system(log_level="on")
system.config.instrument_weights=dict(EDOLLAR=1.0)


Fixed capital


To illustrate what's going on with a specific example, here are some plots. In all cases I'm using the standard system from chapter 15 of my book. I've chosen the Eurodollar market as it performs especially well, hence we can see the effect of compounding more clearly.

Let's start by looking at the p&l with fixed capital

## We don't need this line as it's the default behaviour

system.config.capital_multiplier['func']='syscore.capital.fixed_capital'
system.accounts.portfolio().curve().plot()
show()

So we made about 3 million bucks, but on what capital?

system.accounts.portfolio().capital
Out[19]: 250000.0

This is a scalar, so capital is fixed.

We can also see this as a percentage:

system.accounts.portfolio().percent().curve().plot()

Again we've made just over 10 times our capital. If we wanted to know what our performance was on a cumulative basis then there is the quick and dirty option:

system.accounts.portfolio().cumulative().curve().plot()

... and this is why I dislike looking at compounded graphs. The performance in earlier years is now almost impossible to see. Apparently we could make $300 million trading this thing - that's what compounding $250K for decades at 30% a year will give you. It's a hairy ride however! 


According to t'internet Damian Hirst, who creates art like this, is worth $300 million. I leave you to draw your own conclusions. Source: Guardian.com


Full compounding


Let's introduce a compounding method.

system.config.capital_multiplier['func']='syscore.capital.full_compounding'




First, let's check out the capital multiplier. This is the varying number which we multiply fixed capital by to get variable capital. It starts at 1.0:


system.accounts.capital_multiplier().plot()

Since we're allowing capital to track profits this looks exactly like the line above. We finish with about 1000x as much capital as we started with.

What effect does that have on our p&L:


system.accounts.portfolio_with_multiplier().curve().plot()


Naturally this is exactly like the curve produced above with the 'cumulative()' method. By the way  system.accounts.portfolio_with_multiplier().capital would now give a time series rather than a fixed vale.

So we'll start with $250K and end up $300 million. (or perhaps if you have just $2500 you can see yourself ending up with $3 million).  Okay, yes, at one point in the backtest we drop $400 million, but you can cope with that right? 



What could possibly go wrong?

Well... what about positions? Let's compare the multiplied variable capital, and fixed capital positions:

system.accounts.get_buffered_position_with_multiplier("EDOLLAR", False).plot()
system.accounts.get_buffered_position("EDOLLAR", False).plot()

The barely visible green line is the positions we have with fixed capital. It peaks at about 120 lots. With variable capital we have the blue line, peaking at 300,000 lots. I currently own slightly fewer Eurodollar in the June and September 19 delivery. Total open interest across those two months is about 340,000 lots. In my last job, managing a large portfolio for multi billion dollar quant fund AHL, we never had a position that big. 

At the very least we'd have to do some very serious research on modelling the execution costs associated with turning over that kind of position. At one point we sell 150K lots, pretty much overnight.

The moment the trader realised that selling 150,000 contracts might be a little tricker than he originally thought. Source mirrodaily.com

Half compounding


Finally let's look at the method I use myself, "half compounding", where we ratchet down our risk on losses, but do not increase it beyond the high water mark.

system.config.capital_multiplier['func']='syscore.capital.half_compounding'


Here's the capital multiplier


system.accounts.capital_multiplier().plot()

Notice it is always at, or below 1.0. A value of 0.5 means we are currently in a 50% drawdown.



system.accounts.portfolio_with_multiplier().capital.plot()


Similarly the capital at risk is always equal to the maximum fixed value of $250K, or less.


system.accounts.portfolio_with_multiplier().curve().plot()

Notice that the volatility of the account curve is dampened during the drawdowns.



system.accounts.get_buffered_position_with_multiplier("EDOLLAR", False).plot()
system.accounts.get_buffered_position("EDOLLAR", False).plot()
show()





Positions with fixed capital (green) are always greater than, or equal to, those with variable capital (blue).

We can't plot full compounding and fixed capital together, because the scale would be crazy. But here's the account curves for fixed capital (in blue) and half compounded (in green):

Fixed capital makes more (33.4% a year vs 22.7%) than variable, but with higher risk (annualised risk of 62% vs 43%). The Sharpe comes in very slightly higher (0.54 vs 0.51) and the Sortino a little lower (1.47 vs 1.5). The variable capital has lower average drawdowns (14% vs 20.5%) but we'd expect this given the lower volatility; but also more positive skew of returns (0.77 vs 0.59 on an annual basis) hence the improvement from Sharpe to Sortino.

However this stats are somewhat misleading because the volatility of the variable account curve is non stationary, whereas it's more stable with a fixed account curve (only changing as signals weaken or strengthen).

Half compounding is better in the sense that it's safer and you'll "never" run out of money (jumps aside). But unless your trading strategy is unprofitable you will always end up with less money than with fixed capital; and definitely less than with full compounding.

Conclusion


I hope I've put you off looking at compounded account curves. They have little or no value for system evaluation and understanding. If you want to fantasise about being as rich as Damian Hirst, then feel free but do not bother backtesting the journey.

For actual trading though I recommend you use eithier the full compounding method or half compounding method; both of which you can backtest easily if you wish.

Many traders might fall somewhere between these two stools; letting some of their returns compound but making withdrawals to cover taxes and augment other income. It's hard to backtest this, but in live trading setting your risk capital equal to your account value will ensure you have your risk correct. It will mean however that you will reduce position size when you make withdrawals, possibly incurring transaction costs.