# Mechanical Trading System Performance/Equity Curve



## rx2 (13 January 2012)

Hi,

How I am just starting to think about how I am going to record and monitor the performance of a mechanical short term eod system. One metric that I want to monitor is the equity curve.

For a live system - how are people recording the equity curve? My thoughts started with developing something in Excel. However, the problem with this is that I will need to record the prices daily for all open positions - this will allow me to work out MaxSysDD.

To record the daily prices for all open positions is going to require a little thought in developing the spreadsheet if I want it to be automated. i.e. do I write some automated code to pull prices from Yahoo, or do I just use my data provider, PremiumData and their Data Converter utility.... 

Anyway - whatever way I go about getting the pricing data it seems like it will be a little bit of work in Excel. The other option is using something like Stator-AFM which does it all for me and has integration to pull prices from PremiumData; but I feel this may be buying a Ferrari when all I need is a Toyota.

What methods / systems are people using to track the live equity curve of a system?

Cheers


----------



## Punta (13 January 2012)

I write java code for IB that logs the open/close of everything on my watch list, as well as the trigger values, and the executed prices of any transactions that the system actually makes.  I just write a separate .txt file with this info every day, and for every strategy that I have working.  Then I can come along later and load the data into some analysis software, and check that it matches up with the backtesting system that spawned the strategy in the first place.


----------



## tech/a (13 January 2012)

*Stator-AFM *

Definately
At $300 ish its the cost of a billy cart!!


----------



## rx2 (13 January 2012)

tech/a said:


> *Stator-AFM *
> 
> Definately
> At $300 ish its the cost of a billy cart!!




Thanks tech/a - I am definitely leaning towards this. I assume this is what you use?


----------



## tech/a (13 January 2012)

rx2 said:


> Thanks tech/a - I am definitely leaning towards this. I assume this is what you use?




Did do for ages.
Had a computer crash and never re loaded it.
My equity curve has been my capital balance.

Should do again as its nuts and bolts trading.
Gives you that hands on blueprint I keep harping on about!
Frankly Im doing very little.
Just a bit of Index futures Trading.
Most everything else is a waste of time and rescourses.

Fortunately I dont have to make a living from the market.


----------



## notting (13 January 2012)

It really annoys me that PC's can stuff people up like that.
Techa PC's are pretty cheap these days! Build it again and get a copy of Ghost -  image the PC to an external hard drive so you can just flip in a disc and bingo your whole system is back on a new hard drive!


----------



## tech/a (13 January 2012)

notting said:


> It really annoys me that PC's can stuff people up like that.
> Techa PC's are pretty cheap these days! Build it again and get a copy of Ghost -  image the PC to an external hard drive so you can just flip in a disc and bingo your whole system is back on a new hard drive!




Yeh I know.
lost 8 yrs of research once!
All sorted now Son has it under control.
Have ghost but lost the 8 yrs of stuff!
including a lot of great Systems testing!

Still this time I have a PHD in Physics on my team so nothings going missing and the research is much higher quality!


----------



## mazzatelli (13 January 2012)

Off Topic

tech/a, I see a father who is very proud and adoring of his son!
Every thread I see with your participation: "my son the PhD"


----------



## tech/a (13 January 2012)

mazzatelli said:


> Off Topic
> 
> tech/a, I see a father who is very proud and adoring of his son!
> Every thread I see with your participation: "my son the PhD"




Yeh sorry will cease
Learn a lot though.


----------



## mazzatelli (14 January 2012)

tech/a said:


> Yeh sorry will cease
> Learn a lot though.




lol, nothing to be sorry about...was just an observation
It is definitely handy to have your own free in-house quant!!!


----------



## Wysiwyg (18 February 2016)

The equity curve is a definitive metric. Below are examples of postion size on equity curves traded over the same period. The first curve is 20% of equity per buy trade. Second 10% of equity per buy trade and third 5% of equity per buy trade. The kicker is the final curve using 100% of equity per buy trade. The returns and curve get worse with the greater number of positions allowed to take (smaller position size).

What is happening here? Obviously the more money placed on a trade the greater the return over time with a positive expectancy. *So why not trade a system with 100% equity on each trade?* One reason would be eventually getting caught in a position of loss beyond risk by a swan dive or two.


----------



## howardbandy (18 February 2016)

Greetings --

The risk, and consequently the profit potential, of a trading system is determined by the distribution of the trades.  Each equity curve can be seen as a single example of the large set of possible equity curves.  An equity curve is sequence-dependent.  Do some further analysis before relying on equity curve as your metric.

Best,
Howard


----------



## Wysiwyg (18 February 2016)

howardbandy said:


> Greetings --
> 
> The risk, and consequently the profit potential, of a trading system is determined by the distribution of the trades.  Each equity curve can be seen as a single example of the large set of possible equity curves.  An equity curve is sequence-dependent.  Do some further analysis before relying on equity curve as your metric.
> 
> ...



Thank you Howard. So I run the system over a different period being a complete year before the last test which will produce a completely different distribution and sequence of trades. Again the equity curves are in order of 20%, 10%, 5% and 100% of equity. System drops away with smaller position size and I see it often. This cannot be coincidence so position size (fixed percent of equity in this case) is a variable that is paramount in system trading success is the point I make. Around 20% of equity per trade consistently returns better results. I conclude position size is paramount in system success and is there anything I am not seeing in this conclusion?


----------



## howardbandy (18 February 2016)

Greetings --

Position size is critically important.  But we cannot determine what it is until after doing some analysis.  The order of analysis is:
0.  Decide on your personal risk tolerance.  It will be a statement such as:  I am trading a $100,000 account and forecasting two years into the future.  I want to hold the probability of a drawdown greater than 20% to 5% or less.  This is your risk tolerance for all uses of your money, including trading.  Do it once.  Use it as you analyze many alternative trading systems.
For each system:
1.  Create a set of trades that are the best estimate of future performance.  These might be the trades from the out-of-sample runs of the walk forward testing.
2.  Use this set to estimate drawdown.  Do this by creating many trade sequences, each drawn from the best estimate set using Monte Carlo techniques.  For each trade sequence, compute the maximum drawdown.  Form the distribution of drawdowns.  
3.  From the distribution of drawdowns, estimate the probability of a drawdown that exceeds your personal risk tolerance.
4.  Adjust the fraction of the account used for each trade until the risk of the set of trades is "risk-normalized."  That is, the highest fraction -- the highest position size -- where the risk of the set of trades does not exceed your personal risk tolerance.  The fraction that results is "safe-f."  It is almost always less than 1.00, meaning that only a portion of funds can be used to trade, while the remainder is held in a risk-free account to act as ballast when the drawdown of the traded portion exceeds the risk tolerance.
5.  At a fraction of safe-f, estimate the account balance at the end of the two year forecast period.  This is also a distribution.  I recommend looking at the 25th percentile of that distribution and computing the compound annual rate of return that corresponds to.  Call it CAR25.  CAR25 is as near a universal objective function as I have found.
6.  Compare the CAR25 values of alternative systems or other uses of the funds.  Trade the system that has the highest risk-normalized CAR25.

Best regards,
Howard


----------



## Wysiwyg (18 February 2016)

Thanks Howard and I will give this idea one go to comprehend as you posted it.



howardbandy said:


> Greetings --
> 
> 
> 4.  Adjust the fraction of the account used for each trade until the risk of the set of trades is "risk-normalized."  That is, the highest fraction -- the highest position size -- where the risk of the set of trades does not exceed your personal risk tolerance.  The fraction that results is "safe-f."



 Set of trades does not exceed risk tolerance is the drawdown, yes? If so, to me this means the fraction of 1/5 (20% of equity per trade) or "safe-f" is 0.20 "risk normalised". 


> It is almost always less than 1.00, meaning that only a portion of funds can be used to trade, while the remainder is held in a risk-free account to act as ballast when the drawdown of the traded portion exceeds the risk tolerance.



This bit I don't understand because it assumes we are still trading. Do you mean exit losing positions and only trade 20% of equity when the account goes into a drawdown beyond risk tolerance and keep 80% in cash? If so when do we go back in 100%? 


> 5.  *At a fraction of safe-f, estimate the account balance* at the end of the two year forecast period.  This is also a distribution.



I don't know how to estimate the account balance at a fraction of safe-f (safe-f 0.20 in my case).


----------



## howardbandy (19 February 2016)

Greetings --

Regarding:
Set of trades does not exceed risk tolerance is the drawdown, yes? If so, to me this means the fraction of 1/5 (20% of equity per trade) or "safe-f" is 0.20 "risk normalised". 

-----------------------

The risk metric comes from the distribution of drawdown of many equally likely trade sequences.  After finding what the risk is when the system is traded at 100%, which is f = 1.00, adjust f so that the risk of the system matches your personal risk tolerance.  That value is safe-f.  It is almost always less than 1.00.  Say it is 0.70.  Your account for trading this system is $100,000.  When you get the next signal to buy, buy as many shares as you can with $70,000.  The other $30,000 remains in a risk-free account.  The drawdown of the portion exposed will exceed your risk tolerance, but since there is no drawdown in the risk-free account, the drawdown of the entire $100,000 is within your tolerance.

The drawdown you will experience on the portion of funds exposed to the trades will be the drawdown you expressed in your risk tolerance statement divided by safe-f.  If your risk tolerance is a 5% chance of a 20% drawdown, and safe-f is 0.70, the funds exposed to the trades will have a drawdown of 0.20 / 0.70 or about 30%.  That will happen no matter what else you do.

Using the example figure of safe-f of 0.20, the drawdown of the funds exposed will be 100%.  0.20 / 0.20 == 1.00.  Systems that have low safe-f values will have high drawdowns in the trades made.  I recommend setting a limit, say 0.60, for the safe-f.  Systems that have safe-f below this limit will have high drawdowns and require substantial ballast funds.  Since profit potential is a function of safe-f, and safe-f is low, then profit potential is low.  So a system that has a low safe-f has high risk and low return.  

Side note:
If you were to trade two systems (and rationally you would only do this if their CAR25 metrics were the same -- otherwise you would trade the better system with all your funds) -- say the two systems had safe-fs of 0.70 and 0.60.  The first system requires keeping $30,000 of the $100,000 allocated to it in risk-free.  The second system requires keeping $40,000 of its $100,000 risk-free.  Do not "share" the risk-free amounts and set aside only $40,000.  You need them both.  You need to set aside $70,000.


Best,
Howard


----------



## Wysiwyg (5 March 2016)

howardbandy said:


> Greetings --
> 
> The risk metric comes from the distribution of drawdown of many equally likely trade sequences.  After finding what the risk is when the system is traded at 100%, which is f = 1.00, adjust f so that the risk of the system matches your personal risk tolerance.  That value is safe-f.  It is almost always less than 1.00.  Say it is 0.70.  Your account for trading this system is $100,000.  When you get the next signal to buy, buy as many shares as you can with $70,000.  The other $30,000 remains in a risk-free account.  The drawdown of the portion exposed will exceed your risk tolerance, but since there is no drawdown in the risk-free account, the drawdown of the entire $100,000 is within your tolerance.
> 
> ...




Excellent portfolio risk management practice. Thank you Howard.



> Gringott Bank posted -
> I stopped trading two systems 2 months ago because they'd been flat and I got bored/pissed off. In the last two months, combined, they would have returned nearly 100% with miniscule draw down. Had I been patient.... *That's trading for you*.




Same with switching off when the equity curve hits a draw down of e.g. 5%. Soon enough the system picks up again but profit is missed when the system is switched off. I looked at this countless times and it is impossible to know when the system will draw up again. The worst case scenario is (apparently) known through experience so confidence that the system will recover is a must. Nothing wrong with having several lower frequency/higher accuracy systems running together.


----------



## howardbandy (6 March 2016)

Wysiwyg said:


> Excellent portfolio risk management practice. Thank you Howard.
> 
> Same with switching off when the equity curve hits a draw down of e.g. 5%. Soon enough the system picks up again but profit is missed when the system is switched off. I looked at this countless times and it is impossible to know when the system will draw up again. The worst case scenario is (apparently) known through experience so confidence that the system will recover is a must. Nothing wrong with having several lower frequency/higher accuracy systems running together.




Our goal is to have confidence in the trades we take with actual money.  Confidence that the reward is adequate compensation for the risk.  Trading through a drawdown without adjusting position size to lower the risk is an act of faith, not an act of confidence.  There is no way of knowing whether the system is in a temporary drawdown or the beginning of a complete failure with no recovery.    

Position size adjustment can be a binary switch -- take the system completely offline based on some rule such as a drawdown of some percentage or the crossing of the equity below its moving average.  

Or position size adjustment can be incremental -- which is what I suggest with the "dynamic position sizing" technique that reduces position size in response to recent losses and increases it in response to recent gains. 

In either case, trading management is itself a system -- a combination of a model and some data.  The data is recent trades.  The model is position size adjustment.      

Compare with the traditional trading system -- a combination of a model and some data.  The data is price and volume.  The model recognizes conditions that precede profitable trades and generates signals to be long, flat, or short.

Best regards,
Howard


----------

