Monday, 5 September 2016

Systematic risk management


As the casual reader of this blog (or my book) will be aware, I like to delegate my trading to systems, since humans aren't very good at it (well, I'm not). This is quite a popular thing to do; many systematic investment funds are out there competing for your money; from simple passive tracking funds like ETF's to complex quantitative hedge funds. Yet most of these employ people to do their risk management. Yes - the same humans who I think aren't very good at trading.

As I noted in a post from a couple of years ago, this doesn't make a lot of sense. Is risk management really one of those tasks that humans can do better than computers? Doesn't it make more sense to remove the human emotions and biases from anything that can affect the performance of your trading system?

In this post I argue that risk management for trading systems should be done systematically with minimal human intervention. Ideally this should be done inside an automated trading system model.

For risk management inside the model, I'm using the fancy word endogenous. It's also fine to do risk management outside the model which would of course be exogenous. However even this should be done in a systematic, process driven, way using a pre-determined set of rules.

A systematic risk management approach means humans have less opportunity to screw up the system by meddling. Automated risk management also means less work. This also makes sense for individual traders like myself, who can't / don't employ their own risk manager (I guess we are our own risk managers - with all the conflicts of interest that entails).

This is the second in a series of articles on risk management. The first (which is rather old, and wasn't originally intended to be part of a series) is here. The final article (now written, and here) will be about endogenous risk management, explain the simple method I use in my own trading system, and show an implementation of this in pysystemtrade.


What is risk management?


Let's go back to first principles. According to wikipedia:

"Risk management is the identification, assessment, and prioritization of risks (defined in ISO 31000 as the effect of uncertainty on objectives) followed by coordinated and economical application of resources to minimize, monitor, and control the probability and/or impact of unfortunate events[1] or to maximize the realization of opportunities. Risk management’s objective is to assure uncertainty does not deflect the endeavour from the business goals. "

This slightly overstates what risk management can achieve. Uncertainty is almost always part of business, and is a core part of the business of investing and trading. It's often impossible to minimise or control the probability of something happening, if that something is an external market event like a recession.

Still if I pick out the juicy parts of this, I get:

  • Identification, assessment and priorization of risks
  • Monitoring of risks
  • Minimize and control the impact of unfortunate events 
This suggests that risk management can be boiled down to the following

  1. Identify some important risks.
  2. Work out a way to measure them
  3. Set levels at which action should be taken, and specify an action to take.
  4. Monitor the risk measurements
  5. Take action if (when) the measurements exceed critical levels
  6. When (if) the situation has returned to normal, reverse the action

I would argue that only steps 1,2 and 3 are difficult to systematise. Steps 4 to 6 should be completely systematic, and if possible automated, occuring within the trading system.


Types of risk


It's very easy to forget that there are many types of risk beyond the usual; "the price will fall when we are long and we will lose our shirts". This is known as market risk and whilst it's the most high profile flavour there are others. Pick up any MBA finance textbook and you'll find a list like this:


  • Market risk. You make a bet trade which goes against you. We quantify this risk using a model.
  • Credit / counterparty risk. You do a trade with a guy and then they refuse to pay up when you win.
  • Liquidity risk. You buy something but can't sell it when you need to.
  • Funding risk. You borrow money to buy something, and the borrowing gets withdrawn forcing you to sell your position.
  • (Valuation) Model risk.You traded something valued with a model that turned out to be wrong. Might be hard to distinguish from market risk (eg option smile: is the Black-Scholes model wrong, or is it just that the correct price of OTM vol is higher?).
  • (Market) Model risk. You trade something assuming a particular risk model which turns out to be incorrect. Might be hard to distinguish from market and pricing model risk ("is this loss a 6 sigma event, or was our measurement of sigma wrong?"). I'll discuss this more later.
  • Operational / IT / Legal risk. You do a trade and your back office / tech team / lawyers screw it up.
  • Reputational risk. You do a trade and everyone hates you.

Looking at these it's obvious that some of them are things that are hard to systematise, and almost impossible to automate. I would say that operational / IT and Legal risks are very hard to quantify / systematise beyond something like a pseudo objective exercise like a risk register. It's also hard for computers to spontaneously analyse the weaknesses of valuation models, artifical intelligence is not quite there yet. Finally reputation: computers don't care if you hate them or not.

It's possible to quantify liquidity, at least in open and transparent futures markets (it's harder in multiple venue equity markets, and OTC markets like spot fx and interest rate swaps). It's very easy to program up an automated trading system which, for example, won't trade more than 1% of the current open interest in a given futures delivery month. However this is beyond the scope of this post.

In contrast it's not ideal to rely on quantitative measures of credit risk, which tend to lag reality somewhat and may even be completely divorced from reality (for example, consider the AAA rating of the "best" tranche of nearly every mortgage backed security issued in the years up to 2007). A computer will only find out that it's margin funding has been abruptly cut when it finds it can't do any more trading. Humans are better at picking up and interpreting whispers of possible bankruptcy or funding problems.

This leaves us with market risk - what most people think of as financial risk. But also market model risk (a mouthful I know, and I'm open to using a better name). As you'll see I think that endogenous risk management can deal pretty well with both of these types of risk. The rest are better left to humans. So later in the post I'll outline when I think it's acceptable for humans to override trading systems.


What does good and bad risk management look like?

There isn't much evidence around of what good risk management looks like. Good risk management is like plumbing - you don't notice it's there until it goes wrong, and you've suddenly got "human excrement"* everywhere

*Well my kids might read this blog. Feel free to use a different expression here.

There are plenty of stories about bad risk management. Where do we start... perhaps here is a good place: https://en.wikipedia.org/wiki/List_of_trading_losses.

Nick Leeson. Bad risk management in action, early 90's style. Source: Daily Mail


Generally traders are given a small number of risk management parameters they have to fit within.

For example my first job in finance was working as a trader for Barclays Capital. My trading mandate included a maximum possible loss (a mere million quid if I remember correctly), as well as limits on the greeks of my position (I was trading options). I also had a limit on everyones favourite "single figure" risk measurement, VAR.

Bad traders will eithier willfuly, or through ignorance, bend these limits as much as possible. For example if I return to the list of trading losses above, it's topped by this man:

Howie. The 9 billion dollar man. Not in a good way. Source: wallstreetonparade.com

Howie correctly called the sub prime mortgage debt collapse. He bet on a bunch of mortgage related derivative crap falling. But to offset the negative carry of this trade (which caused a lot of pain to other people doing this trade) he bought a bunch of higher rated mortgage related derivatives. For boring technical reasons he had to buy a lot more of the high rate stuff.

On paper - and presumably according to Morgan's internal models - this trade had minimal risk. It was assumed that the worst that would happen would be that house prices stayed up, and that the long and short side would remain high. Hopefully though Howie would get it right - the crap would fall, and the good stuff would keep it's value.

However it turned out that the good stuff wasn't that good eithier; the losses on the long position ended up dwarfing the gains on the short position. The risk model was wrong.

(The risk management team did [eventually] warn about this, but Howie succesfully argued that the default rate they were using to model the scenario would never happen. It did.)


Risk management embodied by trading systems


From the above discussion we can derive my first principle of risk management:

Good traders do their own risk management 

(and by trader here I mean anyone responsible for making investment decisions, so it includes fund managers of all flavours, plus people who think of themselves as investors rather than traders).

Good traders will take their given risk limits as a starting point. They will understand that all risk measurements are flawed. They will think about what could go wrong if the risk model being used was incorrect. They will consider risks that aren't included in the model.

Similarly good trading systems already do quite a lot of risk management. This isn't something we need to add, it's already naturally embodied in the system itself.

For example in my book I explain how a trading system should have a predetermined long term target risk, and then how each position should be sized to achieve a particular target risk according to it's perceived profitability (the forecast) and the estimated risk for each block of the instrument you're trading (like a futures contract) using estimates of return volatility. I also talk about how you should use estimates of correlations of forecasts and returns to achieve the correct long run risk.

Trading systems that include trend following rules also automatically manage the risk of a position turning against them. You can do a similar thing by using stop loss rules. I also explain how a trading system should automatically reduce your risk when you lose money (and there's more on that subject here).

All this is stuff that feels quite a lot like risk management. To be precise it's the well known market risk that we're managing here. But it isn't the whole story - we're missing out market model risk. To understand the difference I first need to explain my philosophy of risk in a little detail.


The two different kinds of risk


I classify risk into two types - the risk encompassed by our model of market returns; and the part that isn't. To see this a little more clearly have a look at a picture I like to call the "Rumsfeld quadrant"


The top left is stuff we know. That means there isn't any risk. Perhaps the world of pure arbitrage belongs here, if it exists. The bottom left is stuff we don't know we know. That's philosophy, not risk management.

The interesting stuff happens on the right. In green on the top right we have known-unknowns. It's the area of quantifiable market risk. To quantify risk we need to have a market risk model.

The bottom right red section is the domain of the black swan. It's the area that lies outside of our market risk model. It's where we'll end up if our model of market risk is bad. There are various ways that can happen:

  • We have the wrong model. So for example before Black-Scholes people used to price options in fairly arbitrary ways. 
  • We have an incomplete model. Eg Black-Scholes assumes a lognormal distribution. Stock returns are anything but lognormal, with tails fatter than a cat that has got a really fat tail.
  • The underlying parameters of our market have changed. For example implied volatility may have dramatically increased.
  • Our estimate of the parameters may be wrong. For example if we're trying to measure implied vol from illiquid options with large bid-ask spreads. More prosically we can't measure the current actual volatility directly, only estimate it from returns.

An important point is that it's very hard to tell (a) an extreme movement within a market risk model that is correct from (b) an extreme movement that isn't that extreme, it's just that your model is wrong. In simple terms is the 6 sigma event (should happen once every 500 million days) really a 6 sigma event?

Or is it really a 2 sigma event it's just that your volatility estimate is out by a factor of 3? Or the unobservable "true" vol has changed by a factor of 3? Or does your model not account for fat tails because 6 sigma events actually happen 1% of the time? You generally need a lot of data to make a Bayesian judgement about what is more likely. Even then it's a moving target because the underlying parameters will always be changing.

This also applies to distinguishing different types of market model risk. You probably can't tell the difference between a two state market with high and low volatility (changing parameter values), and a market which has a single state but a fat tailed distribution of returns (incomplete model); and arguably it doesn't matter.

What people love to do, particularly quants with Phd's trapped in risk management jobs, is make their market models more complicated to "solve" this problem. Consider:




On the left we can see that less than half of the world has been explained by green, modelled, market risk. This is because we have the simplest possible multiple asset risk model - a set of Gaussian distributions with fixed standard deviation and correlations. There is a large red area where we have the risk that this model is wrong. It's a large area because our model is rubbish. We have a lot of market model risk.

However - importantly - we know the model is rubbish. We know it has weaknesses. We can probably articulate intuitively, and in some detail, what those weaknesses are.

On the right is the quant approach. A much more sophisticated risk model is used. The upside of this is that there will be fewer risks that are not captured by the model. But this is no magic bullet. There are some disadvantages to extra complexity. One problem is that with more parameters they are harder to estimate, and estimates of things like higher order moments or state transition probabilities will be very sensitive to outliers.

More seriously however I think these complex models give you a false sense of security. To anyone who doesn't believe me I have just two words to say: Gaussian Copula. Whilst I can articulate very easily what is wrong with a simple risk model it's much harder to think of what could go wrong with a much weirder set of equations.

(There is an analogy here with valuation model risk. Many traders prefer to use Black-Scholes option pricers and adjust the volatility input to account for smile effects, rather than use a more complex option pricer that captures this effect directly)

So my second principle of risk management is:

Complicated risk model = a bad thing

What I prefer to do is use a simple model of returns as part of my trading system. Then I handle market model risk systematically: either endogenously within the system, or exogenously.


Risk management within the system (endogeonous)


The disadvantage of simpler models is their simplicity. But because they're simple, it's also easy to write down what their flaws are. And what can be written down easily can, and should, be added to a trading system as an endogenous risk management layer.

Let's take an example. We know that the model of fixed Gaussian volatility is naive (and I am being polite). Check this out (ignore the headline, which is irrelevant and for which there is no evidence):

S&P 500 vol over time. Source: Seeking Alpha

Now I could deal with this problem by using a model with multiple states, or something with fatter tails. However that's complicated (=bad).

If I was to pinpoint exactly what worries me here, it's this: Increasing position size when vol is really low, like in 2006 because I know it will probably go up abruptly. There are far worse examples of this: EURCHF before January 2015, Front Eurodollar and other STIR contracts, CDS spreads before 2007...

I can very easily write down a simple method for dealing with this, using the 6 step process from before:
  1. We don't want to increase positions when vol is very low.
  2. We decide to measure this by looking at realised vol versus historical vol
  3. We decide that we'll not increase leverage if vol is in the lowest 5% of values seen in the last couple of years
  4. We monitor the current estimated vol, and the 5% quantile of the distribution of vol over the last 500 business days.
  5. If estimated vol drops below the 5% quantile, use that instead of the lower estimated vol. This will cut the size of our positions.
  6. When the vol recovers, use the higher estimated vol.
Here is the implementation of this idea in pysystemtrade https://github.com/robcarver17/pysystemtrade/blob/master/syscore/algos.py#L39 (Default values can be changed here).

It's easy to imagine how we could come up with other simple ways to limit our exposure to events like correlation shocks, or unusually concentrated positions. The final post of this mini series will explain how my own trading system does it's own endogenous risk management, including some new (not yet written) code for pysystemtrade.


Systematic risk management outside the system (exogeonous)


There is a second category of risk management issues. This is mostly stuff that could, in principle, be implemented automatically within a trading system. But it would be more trouble than it's worth, or pose practical difficulties. Instead we develop a systematic process which is followed independently. The important point here is that once the system is in place there should be no room for human discretion here.

An example of something that would fit nicely into an exogenous risk management framework would be something like this, following the 6 step programme I outlined earlier:


  1. We have a large client that doesn't want to lose more than half their initial trading capital - if they do they will withdraw the rest of their money and decimate our business.
  2. We decide to measure this using the daily drawdown level
  3. We decide that we'll cut our trading system risk by 25% if the drawdown is greater than 30%, by half at 35%, by three quarters at 40% and completely at 45% (allowing some room for overshoot).
  4. We monitor the daily drawdown level
  5. If it exceeds the level above we cut the risk capital available to the trading system appropriately
  6. When the capital recovers, regear the system upwards

[I note in passing that:

Firstly this will probably result in your client making lower profits than they would have done otherwise, see here.

Secondly this might seem a bit weird - why doesn't your client just stump up only half of the money? But this is actually how my previous employers managed the risk of structured guaranteed products that were sold to clients with a guarantee (in fact some of the capital was used to buy a zero coupon bond). These are out of fashion now, because much lower interest rates make the price of the zero coupon bonds far too rich to make the structure work.

Finally for the terminally geeky, this is effectively the same as buying a rather disjointed synthetic put option on the performance of your own fund]

Although this example can, and perhaps should, be automated it lies outside the trading system proper. The trading system proper just knows it has a certain amount of trading capital to play with; with adjustments made automatically for gains or losses. It doesn't know or care about the fact we have to degear this specific account in an unusual way.

In the next post I'll explain in more detail how to construct a systematic exogenous risk management process using a concept I call the risk envelope. In this process we measure various characteristics of a system's backtested performance, and use this information to determine degearing points for different unexpected events that lie outside of what we saw in the backtest.

For now let me give you another slightly different example - implied volatility. Related to the discussion above there are often situations when implied vol can be used to give a better estimate of future vol than realised vol alone. An example would be before a big event, like an election or non farm payroll, when realised vol is often subdued whilst implied vols are very rich.

Ideally you'd do this endogenously: build an automated system which captured and calculated the options implied vol surface and tied this in with realised vol information based on daily returns (you could also throw in recent intraday data). But this is a lot of work, and very painful.

(Just to name a few problems; stale and non synchronous quotes, wide spreads on the prices of OTM options give you very wide estimates of implied vol, non continuous strikes, changing underlying mean the ATM strike is always moving....)

Instead a better exogenous system is to build something that monitors implied vol levels, and then cut positions by a proscribed amount when they exceed realised vol by a given proportion (thus accounting for the persistent premium of implied over realised vol). Some human intervention in the process will prevent screwups caused by bad option prices.




Discretionary overrides


Ideally all risk managers at systematic funds could now be fired, or at least redeployed to more useful jobs.

Risk manager working on new career. Source: wikipedia


But is it realistic to do all risk management purely systematically, either inside or outside a system? No. Firstly we still need someone to do this stuff...

  1. Identify some important risks.
  2. Work out a way to measure them
  3. Set levels at which action should be taken, and specify an action to take.
... even if stages 4-6 should still be done by computers.

Secondly there are a bunch of situations in which I think it is okay to override the trading system, due to circumstances which the trading system (or predetermined exogenous process) just won't know about.

I've already touched on this in the discussion related to types of risk earlier, where I noted that humans are better at dealing with hard to quantify more subjective risks. Here are some specific scenarios from my own experience. As with systematic risk management the appropriate response should be to proportionally de-risk the position until the problem goes away or is solved.


Garbage out – parameter and coding errors


If an automated system does not behave according to its algorithm there must be a coding bug or incorrect parameter. If it isn't automated then it's probably a fat finger error on a calculator or a formula error on a spreadsheet. This clearly calls for a de-risking unless it is absolutely clear that the positions are of the correct sign and smaller than the system actually desires. The same goes for incorrect data; we need to check against what the position would have been with the right data.


Liquidity and market failure


No trading system can cope if it cannot actually trade. If a country is likely to introduce capital controls, if there is going to be widespread market disruption because of an event or if people just stop trading then it would be foolish to carry on holding positions.

Of course this assumes such events are predictable in advance. I was managing a system trading Euroyen interest rate futures just before the 2011 Japanese earthquake. The market stopped functioning almost overnight.

A more pleasant experience was when the liquidity in certain Credit Default Swap indices drained away after 2008. The change was sufficiently slow to allow positions to be gradually derisked in line with lower volumes.


Denial of service – dealing with interruptions


A harder set of problems to deal with are interruptions to service. For example hardware failure, data feed problems, internet connectivity breaking or problems with the broker. Any of these might mean we cannot trade at all, or are trading with out of date information. Clearly a comparison of likely down time to average holding period would be important.

With medium term trading, and a holding period of a few weeks, a one to day outage should not unduly concern an individual investor, although they should keep a closer eye on the markets in that period. For longer periods it would be safest to shut down all positions, balancing the costs of doing this against possible risks.


What's next


As I said I'll be doing a another post on this subject. The final post will explain how I use endogenous risk management within my own trading system.

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.