Posts

How do I get better at trading?

How do I get better at trading? by Laurent Bernut

Answer by Laurent Bernut:

Hope is a mistake”, Mad Max, post apocalyptic road poet.

3 declinations of the same principles: process

A. Trading edge is not a pretty story , trading edge is a number

Every strategy ever traded boils down to this formula:

Gain expectancy = Win% *AvgWin% – Loss%*AvgLoss%

Your survival only depends on how You can tilt the distribution. Regardless of the asset class, there are only two styles: mean reversion and trend following.

  • Open mindset: there is a nugget in everyone’s story
  1. Read the classics: Lefevre, Schwager, Covel, Van Tharp, Loeb
  2. Podcasts: Michael Covel, Andrew Swanscott, Barry Ritholtz
  3. Investment newsletters are to investment what mangas are to literature, Unsubscribe, no exception
  • Stock picking is vastly overrated
  1. Plain vanilla fundamentals is not enough: 3/4 of professional managers underperform; over 3/4 of them claim to be fundamental stock pickers
  2. 90% of market participants focus on stock picking and entry. 90% of market participants fail. Causality and correlation: unsubscribe from all newsletters
  3. never enter w/o an exit policy: Once in a position, there is 100% chance You will exit. W/o exit plan, 90% chance the market has sth nasty in store for You
  4. Money is made in the money management module. The single largest performance discriminant is bet size: process and math

B. Portfolio management process

  • Risk is not a story in China, Risk is a number

Risk is not a story. Risk is not a high Sharpe ratio or low VAR. Risk is how much You can afford to lose per trade and cumulatively. Whatever You think your risk budget is, divide it by two. By the time You have lost half your budget, You will be a different person, gripped in cortisol and CRH, paralysed by fear.

  • Write strict investment guidelines: risk, exposures, objectives

“People live up to what they write down”, Robert Cialdini. Formalise your process in writing. Execute. Simplify. Running a portfolio w/o strict guidelines is like building a house w/o a plan

C. 90% of trading is mental, the other half is solid math

Above all else, any trading system is worthless w/o the right mindset: process over outcome

Examples of outcome vs process:

  1. Stop loss override: ego over process
  2. Close a position too early clear trading plan: outcome vs process mindset
  3. Too big/small bets: euphoria/depression over process
  4. Focus on performance instead of plan execution: outcome over process
  5. Mood swings depending on performance: outcome vs process

Being right is not being profitable (outcome). Being right is following the plan (process)

Conclusion:

This is an “avant-gout” of the book to come. On the short side, the market does not cooperate. Open and process mindsets are the two keys to survival

How do I get better at trading?

Do you have any advice, analogies, or even abuse that you can give me so that I dont exit my winning positions too early?

Do you have any advice, analogies, or even abuse that you can give me so that I dont exit my winn… by Laurent Bernut

Answer by Laurent Bernut:

Now, that is an excellent question. You have the right approach to solve it. Change your beliefs and your reality changes. The reason you cut your profits is because you have been burnt with losses and wan to protect some profit. The reason you procrastinate on stop losses is your ego taking over. Awesome question, let’s have fun

Tiger Moms math aptitude

Among the numerous studies on the “Tiger Mom” effect, one of the funniest and most interesting ones happened when they decided to test the mothers’ math aptitude. One university assembled a team of Asian mothers. They gave them a mathematical test. They were primed with dis-empowering stereotypes on females, mothers: “ladies, You may not like math. You probably don’t do a lot of calculus, algebra and trigonometry these days. Sorry about this…”. One month later, they gathered the same moms, administered the same level of test. This time, they primed them with empowering Asian stereotypes, emphasis on education“You are Asians, right? Asians are supposed to be good at math”. Voila, with simple priming, average score jumped 20%. Congratulations, Way to go Ladies!!!

Morales of the story:

  1. if You want to solve the Fermat theorem, something that has eluded mathematicians for centuries, round up a bunch of Tiger Moms. Remind them that if wasn’t for them balancing the family budget, looking after the education of kids, making sure future generations will be financially well off, they would all live under bridges and tunnels, courtesy of their drinking, gambling husbands. In addition, tell them that solving that simple problem will guaranty entrance to top schools for their children. Leave a stack of application forms to Harvard for inspiration and motivation. Come back before it is time to pick up the kids for their piano, math, and karate/ballet lessons. Problem solved. Anything else?
  2. Change your beliefs, they will change your reality. Impact goes as far as muscular mass and oxygen retention in muscles

You are facing a common problem: Cut your winners, ride your losers. (BTW, have You considered a position in the mutual fund industry? Popular skill set You have here)

How to reverse it? Re-parent the orphan

First, You need to know that abuse will not work. Part of your problem is ego fighting back. Ego, in the Jungian archetypes, is the orphan. In your brain, this is the amygdala, one of the most primitive defense mechanisms. Any attack will push the orphan deeper. Not a good idea. Forgive yourself for your mistakes. This will soothe the amygdala

Metaphors work

Have You ever wondered why we memorize stories instead of abstract concepts? So, using metaphors will definitely help You.

Time asymmetry

In a world where You want to ride your winners and cut your losers, the latter will come quicker than the former. That means your account will drop before it rises. This time difference is a feature You must accept. That is part of the game. It takes time for good trades to mature.

Exit plan and the geography of divorce

Exit is like divorce. No-one wants to but roughly half of the population divorces anyways. So, if You don’t think about it before getting married, it may get a lot more expensive than You think. There is a reason “divorced Barbie” is so much more expensive than all the other Barbie dolls out there. She comes with Ken’s house, cars, boats.

The point is You need to have a clear uniform exit plan. There is no such thing as customised exit plan for that particular stock or that particular case. This nonsense will confuse your inner idiot. Complexity is a form of laziness.

Switch from outcome to process orientation

May i suggest You read this piece on the psychology of stop loss. The psychology of stop loss: how You can be 100% right despite 60% failed trades by Laurent Bernut on Alpha Secure. Look at Bill Ackman and Valeant for a great counter-example. Ego took over and clouded his judgement. No-one is immune.

Your new metaphors must emphasize process over outcome

The way i did it: trap price in a box

I remember the day when i moved from semi-discretionary to 100% systematic. I remember it because the next day i was not stressing about all open positions.

That day, i made a commitment that until stop loss, partial exit, time exit were triggered i had nothing to do. After entry, there are only 3 ways stock can go: up, down or nowhere (x-axis: time). Price is boxed.

Of course, things did not always look good. But i thought of those exits as booby traps. until one of them gets tripped, no need for premature action.

I remember that day, because in the afternoon i started watching Shaolin flicks on Youtube to cut the boredom. While my colleagues waiting for announcement, my computer made some awesome Bruce Lee sounds. I was at peace following the exit plan.

Peaceful exit

Once you decide on an exit plan, commit to doing nothing until one of those booby traps gets triggered. It will bring immense peace.

Stock market is a highly competitive sport. Every hundredth of percentage point counts. If you put every single position in a their individual exit box, they will be no need to stress over them. The right exit will show up. This will save terabytes of mental bandwidth

Do you have any advice, analogies, or even abuse that you can give me so that I dont exit my winning positions too early?

#Quora: How does one address the issue of regime shift in algorithmic trading?

How does one address the issue of regime shift in algorithmic trading? by Laurent Bernut

Answer by Laurent Bernut:change-of-season

Fascinating topic that has kept me awake for years. It is a thorny issue. As the patent clerk Einstein used to say: answer are not at the same level as questions. Answer is not at the signal (entry/exit) level. These are position sizing and order management issues.

Definition of regime change

Everybody has a savant definition, so i might as well come up with a simple practical metaphor. imagine You drive at 150 km/h on the highway and then all of sudden, this 4 lanes turns into a country road. If You do not react quick, you will go tree-hugging.

There are three market types: bull, bear and more importantly sideways. Each type can be subdivided into quiet or choppy. So, we have six sextants. Regime change is when market moves from one box to another.

It can be either a new volatility regime, or a move from bear to sideways, sideways to bull or vice versa. Markets rarely move from bull to bear. There is some battle between good and evil.

Why it matters?

Many strategies are designed to do well in a particular environment. They make a lot of money that they end up giving back when regime changes. Examples:

  1. Short Gamma OTM: sell OTM options and collect premium. Pick pennies in front of a steam roller. 2008–2009, August 2015, CHF depeg, Brexit etc. 1 day those options will go in the money and game over
  2. Dual momentum: trade the shorter time frame but determine regime on longer time frame. When market hits a sideways period, market participants get clobbered on false breakouts like poor cute little baby seals
  3. Mean reversion: works wonders in sideways markets until it does not. An extreme version of that is Short Gamma
  4. Value to growth and vice versa: that is probably the most lagging one. By the time, my value colleagues had thrown the towel and loaded up on growthy stocks, market usually gave signs of fatigue…
  5. Fundamentals pairs trading: relationships are stable until market rotation. For instance, speculative stocks rally hard in the early stage of a bull market, while quality trails. Example: Oct-Dec 2012, Mazda went up +400% while Toyota rallied +30%

The vast majority of market participants are trend followers, whether it is news flow, earning momentum, technical analysis. Trending bulls they do great, trending bears, they can survive. Sideways is where they lose their shirts on false positives.

The issue often boils down to how to enter a sideways regime without losing your shirt

The value of backtests

I agree that backtests will help you identify when your strategy does not work. This is actually the real value of backtest. This is when you modify the strategy and adapt the position sizing to weather unsavoury regimes. Then trade this version, not the ideal fair weather strategy.

Reason is simple: everybody’s got a plan until they get punched in the teeth. So don’t lower your guard, ever.

Asset allocation across multi-strats

Some market participants like to develop specific strategies for specific markets: sideways volatile, awesome for pairs trading, great for options strangle/straddle short. Breakouts are good for trending markets etc.

How do You switch from one to the next ? Fixed asset allocation is as clunky, as primitive and as MPT as it gets. There is something far more elegant and simple:

  1. Calculate trading edge for each sub-strategy: long Trend Following, pairs etc
  2. pro-rate trading edge for each strategy
  3. Allocate by pro-rata
  4. Allocate a residual minimum even to the negative trading edge strategies

This is a simple way to put money where it works best

Regime change for single strategy

When not to trade

Van Tharp believes that there is no strategy that can do well or at least to weather all market conditions. I believe there is more nuance. Is the objective to make money across all market regimes? For example, sideways quiet are preludes to explosive movements. In order to make any money, you need to trade big and if you are on the wrong side when things kick off, game over

We trade a single unified (mean reversion within trend following) strategy. What follows is our journey through solving the regime change issue. We found that the three best ways to manage regime changes are

  1. Stop Loss:
  2. position sizing:
  3. order management:

Stop Loss

Regime changes are usually accompanied with rise in volatility. Volatility is not risk, volatility is uncertainty #de-friendSharpeRatio

We used to have a complex stop loss rule. Now we have a uniform elegant stop loss. It just lags current position. It is fashionably late, hence its name: French Stop Loss.

The idea there is to give enough breathing room to the markets to absorb changes without giving back too much profit.

Our solution is to consider stop loss as a fail safe and allow the market to switch direction bull to bear and vice versa within the confine of a stop loss.

The result is we end up switching from one regime to the next more fluidly. We have reduced the number of stop losses by 2/3, which in turn has materially increased our expectancy.

Stop losses are costly. They are the maximum you can lose out of any position.So, unless you have a kick ass win rate or extremely long right tail, you want to reduce their frequency and allow the market to transition.

Position sizing

The first thing You need to understand is that You cannot predict/anticipate a regime forecast. You will find out after the facts. This has some immediate consequences on position sizing: always cap your portfolio risk

Many position sizing algorithms use equity in layers or staircase. We base our calculation of peak equity. So, drawdowns however small have an immediate impact on position sizing. This slams the break much faster than any other method i know.

The other side of the equation is risk per trade wich oscillates between min and max risk. When regime becomes favourable again, it accelerates rapidly.

The whole premise is early response to change in regime through position sizing

Another feature is trend maturity. Betting the same -1% at the beginning and at the end of a trend is asking for a serious kick in the money maker. Trends are born, grow, mature, get old and eventually die one day, just like believers in Efficient Market Theory. So, risk less as you pyramid.

Order management and hibernation

Along with the position sizing comes a vastly underrated feature in most order management: trade rejection.

Secondly, we use a position size threshold. When markets get too volatile and we experience some drawdown, stop losses dilate. As a result, position sizes get smaller. When sizes are too small, trades get rejected.

Order management is vastly under-utilised in most systems i have seen. It is often binary, all-in/all-out, or one way scale in or scale out.

In our system, taking profit off the table is a not a function of chart, technical analysis but driven by risk management. Until price goes a certain distance, exits are not triggered. If exits are not triggered, entries cannot be triggered either. Since volatility goes up and position sizes get smaller, the system drops into hibernation.

We have factual evidence that hibernation during an unfavourable regime is a powerful mechanism to weather regime change. It involves a lot more sophistication than muting indicators, slope flattening etc. It encompasses position sizing, order management, stop loss and to a lesser degree signals.

Conclusion

Multi-strat asset allocation based on pro-rated trading edge is the easy way to go.

Single strat across multiple market regimes means acceleration/deceleration but also hibernation. This is not an easy problem. There is one thought that kept me going through the frustration of figuring this out: “Building a system is like watch making. Time will always be off until the final cog fits in”

How does one address the issue of regime shift in algorithmic trading?

@Quora: If most people lose in the stock market or gambling, then would I make money by doing the opposite of the average person?

My answer to If most people lose in the stock market or gambling, then would I make money by doing the opposite of …

Answer by Laurent Bernut:

Statistically speaking, You would be exactly in the same position as the person You go against

There is something called the serenity prayer. Here is a simple adaptation:out_of_balance_-_Google_Search
Allow me to go with the flow when it is in the right direction
Allow me to stand against the crowd when they are running in the wrong direction
Give the wisdom to know which is which

An ethousiastic reader commented on an answer I provided about predictive technical analysis, saying that the win rate of Fibonacci and  iterations of it such as de Mark have a win rate of around 40%. He said I was an idiot (true) but more importantly if it was the case, people would do the opposite and win (false). While I have rarely been accused of being intelligent, probabilities still do not work like that.

There are three types:
Clear wins
Clear miss
Near miss/win

The third category is between 10 to 30%, 10 for simple (elegant) systems, 30 for simplistic (naive) stuff. So, doing just the opposite of what everyone else does will not make You a hero. Sell Apple short because everyone else is buying will achieve one thing only: provide liquidity for other buyers, thank you very much

How to tilt your trading edge

This is an important point for people who develop systematic automated strategies: improving the trading edge comes from reducing false positives, or moving near wins (small losses) into near misses territory (small wins). The compounding effect of tilting the win rate and the average win has dramatic impact on the overall gain expectancy.

For example, in our strategy, we have introduced a lag in the stop loss, called “French Stop Loss”, because it is fashionably late “bien sur”. This gives additional wiggle rooms to each trade. They can mature and are rarely stopped out. Not all of them succeed however. Some are closed because trend reverts. This is far less costly than stop loss though as trend reversals occur around break even. The number of stop losses has come down by almost 3/4 and now trades are closed around the break even point. This has considerably reduced erosion and has allowed us to increase the number of pairs traded from 12 to 36.

If most people lose in the stock market or gambling, then would I make money by doing the opposite of the average person?

Trading Journal 2016/01/20

This is a test. If You find value in this trading journal, please let us know. If there are topics You would like to see covered, please comment and suggest. This journal exists only because You find it useful. So, help us create something You need.

1. No signals today

2. Trading activity Last night. Risk at this stage of a sell-off

3. General considerations:

  1. The vaporetto has left, there will be one coming soon: don’t short now, wait for the squeeze
  2. TIP of the day: counter-interintuitive truths about crowded shorts and performance during sell-offs (must read for novice short sellers)
  3. Position for the squeeze and beyond

Trading

Last night there was another Short EPOL, the ETF for Poland.

Here is how to read the chart:

Direction: Short. Comment: Trend is clearly fast bearish with low volatility. That trade has packed a lot of octane (reward to risk / holding period)

Stop Loss: 18.18

Target price: 15.97

Max Risk Per Trade suggested: -0.39% ( per convexity algo, not the standard -0.10% that will give readers a clean multiple). That is 95% of risk per trade

Trading Journal

RIsk: I elected to allocate -0.29% of risk. Risk is a number, not a dissertation. These are the reasons:

Pros:

  1. This is the third tranche. There is embedded risk free P&L of 0.53% that gives some cushion.
  2. More importantly, the lot size is such that only a small move is necessary to be able to cover a large portion and subsequently break even. It needs to generate 0.08% in order to reach break even level
  3. Current position before trade is getting small. It needs to be replenished

Cons:

  1. Trend is maturing. Borrow cost has increased accordingly. This is the third tranche in less than 4 months. Time for a break maybe ?
  2. Correlation increasing across asset classes, synchronous shorting is dangerous, so tone down the risk, take off -0.05%
  3. Rebound was small in duration and magnitude. It may be a false positive. In those fast trend it is either mid section, either before the rebound, take off -0.05%

Verdict: take the trade, but because of synchronous sell-off, reduce risk

3. General market considerations

If You haven’t shorted yet, it is too late. Vaporetto has left. Do not jump onboard now, You’ ll drown and feel stupid. Be patient, keep your powder dry.

Time is better spent observing the markets and observing your thoughts. Journal your thoughts. Observe the monkey on your shoulder.

Homework: this is a great time to get ready for the next campaign: (I have a system so I don’t need to do this anymore), but here is what I would look for: the weakest stocks that are not heavily shorted. Those are the stocks that Long holders sell.

Now is the time to think about the upcoming squeeze and beyond

The probability of a squeeze increases day by day. It is about time for a bit of mouth flapping. They call it reassuring the markets these days.

When they turned off free monetary booze, they expected a bit of weening turbulence, some whining, so no big deal so far.

Now that the vaporetto has left, let’s wait. When the squeeze comes, cover positions (half if You don’t have a system), or break even level if You use a similar equation as mine.

There is no need to cover it all. Markets have turned bearish, so the idea is to cover a portion, ride the squeeze and then slap another tranche.

Roadmap

When the squeeze is over, I will gross-up my leverage. At 127% Gross, -62% net, -22% net at risk today, I am under-participating. The idea was to start the year slow, build some performance cushion and gross up gradually. Bad idea to start sprinting at the beginning of a marathon.

So, when the squeeze comes, net at risk should drop to sub -10%. After the squeeze, gross up so that the net at risk be around -50/60%. This should be a gross of roughly 180-200% .

Now, life is usually what happens when You had other plans.

TIP of the Day: counterintuitive truth about short selling

You will usually find an inverse correlation with borrow utilisation level and performance in sell-offs. In other words, stuff that is heavily shorted all year round holds its ground during sell-off. Money is not made shorting the same stocks everyone shorts: Elvis has already left the building.

Money is made spotting the stocks that are not heavily shorted but underperform the markets. It makes counterintuitve sense: the market participants selling are Long holders selling their positions. Information has not traveled yet

These are the guys we will stalk, these are the guys whose coat we will tail. They are going through a process of grief: Denial, Anger, Bargaining, depression and acceptance. I quantified the process a few years ago. In fact, it was my first public speaking opportunity.

More about this and the Kubler Ross grief model applied to the markets on my website at www.alphasecurecapital.com . Please subscribe, It keeps me motivated. It is free and has resources for committed traders.

Conversely, make a note of the heavily shorted stuff that outperforms or holds its ground. This is squeeze box material where all the structural short sellers go impale themselves.

What is the difference between stock trading and gambling in a casino?

MonteCarloAnswer by Laurent Bernut:

I’ll give You the same answer I gave two CIOs of Fidelity. The common point between professional poker players, star fund managers and street hookers is that they go to work: it is not meant to be fun.
Excellent question. Beyond taxes and manufactured negative gain expectancy, there is much market participants could learn from professional gamblers:
  1. Gambler’s serenity prayer: grant me the serenity to accept folding a losing hand, the courage to take calculated risk and the wisdom to know the difference
  2. Cut losses and run winners: in poker, money is made by folding a lot and be aggressive a few times. Successful fund managers spend their time cutting losses. The paradox is that the way to win the war is to accept losing small battles
  3. Position sizing: Black jack is a game where You play against the house. It is manufactured to have You lose. Yet, Edwin Thorpe, whose track record towers Warren Buffet’s, beat the dealer. His method forced casinos to adapt. His secret sauce was position sizing, a fraction of Kelly criterion
  4. Position sizing algorithms: Gambling is a far more mature industry than investing in the sense that a lot of position sizing algorithms used in finance come from game theory. Martingale, reverse-martingale, drawdown/run-up of bankroll, Kelly Criterion
  5. Gambling is boring: hookers, poker players and star managers go to work. It is not meant to be fun. They leave their emotions at the door. Treat gambling and markets as a job so that You can fleece the emotional players
  6. Gamblers have a system: gamblers are not smarter, they have smarter gambling habits. Adherence to a system takes discipline. Reinforced discipline is called habit
  7. Gambling as trading is not a zero sum game: one of the most common myths about the market is the zero sum game. Slippage, commissions erode however slightly the account. Take every trade as if You put a chip on the table
  8. Quantified risk: the notion of calculated risk has unfortunately been perverted by those who do not understand it. Risk is not an abstract dissertation at the end of an investment thesis. Risk is a hard cold probabilistic number
  9. Odds and win rates: one of the fallacies of market participants is the belief they need above 50% win rate to be successful. 2 things here: 1. trading edge or gain expectancy shows that low win rate can be compensated by big payouts. 2, Distributions of P&L of most traders (excluding mean reversion and market making) show aggregate win rates over the cycle of 30-45%. Winners compensate for losers. The important lesson here is that traders walk into a trade expecting it to win, when they should be mentally prepared  for a loss. Pre-packaging grief (see my post: The view from the short-side: how we process emotions and the market signature of the 5 stages of grief Kubler-Ross by Laurent Bernut on Alpha Secure ) . This means that throughout the cycle, styles come and go. Making money means knowing when your style is out of favour and betting small and then when in fvaour take risks. Back to the serenity prayer
Conclusion
Investors usually look down on gamblers. Yet, there is much to learn from gamblers. How come a few of them become successful despite built-in unfavorable odds ?
Beginners in both markets and gambling believe they are on to something when they double down after each loss. They believe that their luck is about to turn, so they use martingale (it comes from the French for winning streak). They just forget two things: dice have no memory so each run is independent from the previous one. More importantly, the maximum expected value is break-even. This means that any outcome other than the best one carries an interesting probabilistic property called “certainty of ruin”.
In other words, there is a reason why casinos have gold, marble columns, master paintings and rookie gamblers go broke…

What is the difference between stock trading and gambling in a casino?

Has anybody gotten rich through automated trading?

Happy New Year from Alpha Secure Capital. This was an answer to a question on Quora. It has been read by more than 16,000 people.

Now, I am a digital nomad investor: Viet Nam, Singapore, Tokyo, KL, Venezia, Palermo, Reikjavik. Rents get paid in our sleep, balance gets bigger by 1-3% every week. Dream life, hey (*) ? Well, it came at great sacrifices.

Autotrade sub 30 mn is the tallest order in the trading industry. On the one hand, there are HFT shops, with whom there is no point competing. They already do a wondeful job at killing each other not so softly. On the other hand, point and click prop shops ecking penny after penny. Then, there are Delta one and deriv desks arbitraging small corners away. All those guys have the money, the resources, the access, the info, the programmers You will never have. You are outgunned, outnumbered and let’s face it: outside. Now, let the race begin.

It took me 15 years to mature the concepts, 3,694 hours to code, 3 2/3 years to run  and a lifetime to refine them. This has consumed my life, my waking hours, my sleep. Ever woke up breathless and feverishly write equations ? I nearly burned the house not once, but twice, because i forgot that there was something on the stove, while i was wrestling with some C#. Once, my wife came yelling at me for not taking care of our screaming baby. I just did not hear our daughter crying… on my lap. Well, code would not compile…

Sisyphus stones
Then, there is the sheer frustration of never being enough. Then there are bugs. One rule of thumb, never add, always subtract, always come to simplicity when solving bugs. Then, there are “100 year flood”, perfectly rhyming with the late “100 nights of solitude”. Then, there are platform issues. They are not meant to do scale-out/scale-in and adaptive position sizing. Then, there are those small issues that You will have to face one after the other.  There will be times where You wander and meander like Ulysses, “what if this, what if that ?” But there also those immensely gratifying days when You wake up with light and equations flowing through like when I found my personal holy grail of position sizing

After the Daedalus of development, one day the end will be in sight; it will be there, almost, just a few modules away. But then, there are those shortcuts You took 10 iterations ago that will come back and bite You. They stand between You and the finish line. And You know that tackling them means overhauling the entire architecture.
This is the realm of frustration. The last mile is always the hardest. Please remember this though: autotrade is like watch-making. Until the last cog fits in the right place, your clock will always be off, so don’t give up, never give up.

Then, You run your own money, face drawdowns, go back to fix the last few bugs. Then, You run it on small amounts. The best moments are not when You make your previous monthly salary in a week while kitesurfing or going wine tasting. The most beautiful moments are when You make those few hundred dollars week after week and when You finally know it is viable. It feels like watching a flower blossom. This is the best sleep You will have in your lifetime, well at least for 3 months …

Here are the lessons I learned. A viable trading system is built backward:

  1. Focus on the short side: the short side is notoriously harder. If Your system works on the short side, it will work on the Long side. Any 3 star Michelin chef can flip burgers. Now how many Burger king employees can do 3 star meals ?
  2. Focus on the exit first: a race is never won until the finish line is crossed. Some of your positions are marathonians, some are sprinters. You never know until You see them on the field.
  3. Stop loss: it is the only variable that has a direct influence on 3 out of 4 variables of your trading hedge
  4. Money management is key: how to preserve capital when your system won’t work and how to take calculated risk when it does ? This is where the heavy mathematical artillery should be concentrated, not on the entry. Think about it: everyone owns Apple. The difference that makes the difference is how big You are
  5. Simplicity: complexity is a form of laziness. If your solution is still complex, it means You have not worked hard enough to find a simple one. There is no exception to this truth
  6. Symmetry: once the short side delivers, translate it to the long side. You will have unambiguous signals, unified risk management
  7. Watch Star Trek and the original Kardashians, they were not as villains as the newer ones, breaking bad, desperate house wives etc
  8. Then, last and very least, but first take the dogs out. And then finally, sorry don’t forget to water the plants first. And then finally, oops have You called your mother yet ? And then finally, take the trash out and after a good night of sleep, You may think about entry. Entry is at the very bottom pile of the priority list of an autotrade strategy, long after labeling priorities on multiple positions

In the end, You will realise that the goal was never about money. It was first about the freedom from a paycheck and the long term uncertainty of retirement. Rich and wealthy are not synonymous. Rich should be the experiences You accumulate over your life. Now, we live out of our suitcases, frugally as usual, but what a life! Speaking of which, time for a Prosecco with our neighbours, our landlord the architect and his buddy the last Gondola maker in Venezia

(*) Now, the highlights of our week is to hunt for consecutive stop losses. We have excess capacity. We have suffered a great deal coming up with our strategy on MT4. Most modules had to be built from the ground up. We  genuinely want to spare this Sisyphean ordeal to aspiring autotraders.
So, we will choose 2 or 3 people and help them build their strategy.
I can help anyone formalise their own strategy through a thorough guided discovery process. This is not pleasant.
Then on the MT4 coding side, the person I work with is a senior programmer for the US Department of Defense (be nice to him or he will bring democracy to your computer…). I can code alright, but his stuff is military grade… Reach out if You are interested, or if You like what You read

Has anybody gotten rich through automated trading?

Algorithmic trading: How to get started building an algorithmic trading system?

This is an answer to a question on Quora: Algorithmic trading: How to get started building an algorithmic trading system?

Answer by Laurent Bernut:

If investment is a process, then the logical conclusion is automation.
Algorithms are nothing else than the extreme formalisation of an underlying philosophy.

This is the visual expression of a trading edge
Trading edge = Win% *Avg Win% – Loss% *Avg Loss%
It changed my life and the way I approach the markets. Visualise your distribution, always. It will help You clarify your concepts, shed light on your logical flaws, but first let’s start with philosophy and belief elicitation

1. Why is it important to clarify your beliefs ?
We trade our beliefs. More importantly, we trade our subconscious beliefs. “If You don’t know who you are, markets are an expensive place to find out”, Adam Smith
Many people do not take the time to elicit their beliefs and operate on borrowed beliefs. Unanswered questions and faulty logic is the reason why some systematic traders tweak their system around each drawdown. i used to be like that for many years.
Belief elicitation exercises:

  1. The Work by Byron Katie. After i completed a 2 beliefs a day challenge for 100 days, i could explain my style to any grandmother
  2. 5 why ? Ask yourself a question with “why” and dive deeper
  3. “I am”: beliefs about self are best elicited when we start with this sentence stem
  4. Sentence completion exercises: Nathaniel Branden in his work on self-esteem has pioneered this method. For example, “to me a robust trading is…”

Mindsets: expansive and subtractive or masala smoothie Vs band-aid
There are two types of mindset, and we need both at different times:

  1. Expansive to explore concepts, ideas, tricks etc. Expansive mindset is useful in the early stage of strategy design
  2. Subtractive: to simplify and clarify concepts. Complexity is a form of laziness. Instead of adding yet another redundant factor, try subtracting one or two. Work hard until You find an elegant and simple solution

Systematic traders who fail at being subtractive have a smoothie approach. They throw all kinds of stuff into the optimization blender and waterboard data until it confesses. Bad move: complexity is a form of laziness.
Overly subtractive systematic traders have a band aid mentality. They hard-code everything and then good luck patching
“Essentialist traders” understand that it is a dance between periods of exploration and times of hard core simplification. Simple is not easy
It has taken me 3,873 hours, and i accept it may take a lifetime

2. Exit: start with the end in mind Counter-intuitive truth
The only time when you know if a trade was profitable is after exit, right ?
So, focus on the exit logic first.
In my opinion, the main reason why people fail to automate their strategy is that they focus too  much on entry and not enough on exit.
The quality of your exits shapes your P&L distribution, see chart above
Spend enormous time on stop loss as it affects 4 components of your trading system: Win%, Loss%, Avg Loss%, trading frequency
The quality of your system will be determined by the quality of your stop loss,

3. Money is made in the money management module
Equal weight is a form of laziness. The size of your bets will determine   the shape of your returns. Understand when your strategy does not work and reduce size. Conversely, increase size when it works.
I will write more about position sizing on my website, but there are many resources across the internet

3. Last and very least, Entry
After you have watched a full season of “desperate housewives” or “breaking bad”, had some chocolate, walked the dog, fed the fish, called your mom, then it’s time to think about entry.
Read the above formula, stock picking is not a primary component. One may argue that proper stock picking may increase win%. Maybe, but it is worthless if there is neither proper exit policy, nor money management.
In probabilistic terms, after you have fixed exit, entry becomes a sliding scale probability

4. What to focus on when testing
There is no magical moving average, indicator value. When testing your system, focus on three things:

  1. False positives: they erode performance. Find simple (elegant) ways to reduce them, work on the logic
  2. periods when the strategy does not work: no strategy works all the time. Be prepared for that and prepare contingency plans in advance. Tweaking the system during a drawdown is like learning to swim in a storm
  3. Buying power and money management: this is another counter-intuitive fact. Your system may generate ideas but you do not have the buying power to execute. Please, have a look at the chart above

I build all my strategies from the short side first. The best test of robustness for a strategy is the short side:

  1. Thin volume
  2. brutally volatile: this
  3. shorter cycle: stocks go up the elevator and go out the window
  4. Borrow availability:

Platforms
I started out on WealthLab developer. It has a spectacular position sizing library. This is the only platform that allows portfolio wide backtetsing and optimisation. I test all my concepts on WLD. Highly recommend. It has one drawback, it does not connect position sizer with real live trading.

Amibroker is good too. It has an API that connects to Interactive brokers and a decent poisition sizer.

We program on Metatrader for Forex. Unfortunately, Metatrader has gone down the complexity rabbit hole. there is a vibrant community out there.

MatLab, the expensive weapon of choice for math graduates. No comment…

R: much better cost-performance than Matlab, simply because it is free

Tradestation
Perry Kaufman wrote some good books about TS. There is a vibrant community out there. It is easier than most other platforms

Final advice
If You want to learn to swim, You have to jump in the water. Many novices want to send their billion dollar ideas to some cheap programmers somewhere. It does not work like that. You need to learn the language, the logic.
Brace for a long journey

Algorithmic trading: How to get started building an algorithmic trading system?

What programs are usually used to back-test trading strategies?

Answer by Laurent Bernut:

Testing a strategy is a journey. For any journey, You need the right equipment. I test everything on WealthLab then program on other platforms. Here is why

The objective of back-testing is to simulate real trading. When You trade real money, You face the following problems:

  1. Position size: You do not trade 1 share per trade. You may have sophisticated position sizing algo. Platforms offering position sizing algos in back-testing phase are few and far between: WealthLab & amiBroker. QuantConnect and Quantopian may but I have not tried
  2. Cash constraint: You strategy may generate signals but if You do not have cash to execute either a Buy Long or a Buy to Cover, it is a moot point. WLD and amiBroker
  3. Portfolio rotation: this is similar to the above point. Test may look great/poor on one security but in real life, you trade a portfolio.
  4. Slippage & commission: always set slippage at max. My settings is -0.5% one-way, that is 1% slippage + commission for a round trip
  5. Volume: only academics and efficient market believers trade on thin markets and banking holidays
  6. Borrow and uptick: structural shorts are a dime a dozen. Profitable structural shorts are the unicorns of short-selling. If You find one, capture it safely and let’s study it

The journey:
The first part of the journey is to get the signal right. This is where most people stop. They identify a signal that they test across a population of stocks one after the other. This may seem fine in theory but in practice You will rapidly come across a concept called Buying Power. If You don’t have the cash, You can’t execute. If You can’t execute, then it’s all academic. This excludes primitve versions of Matlab, MT4 and older versions of TradeStation
Math formula for that level is: Signal Validity = Win%

Second stage is when You start testing at portfolio level
You have realised that signals must be executable to be worth anything.
At this stage, You will test signals. These are where most people stop. This is the province of most sell-side quants using R or Matlab. Tradestation does not go any further. Not sure about Ninja, never tested that one
It assumes all positions are equal weight. This is primitive
math is  Win rate = Win% – Loss %
Bloomberg BTST is a rudimentary version of that

Third stage is when You start working on the real trading edge formula
Trading Edge = Win% *Avg Win% -Loss%* Avg Loss%
This is when You start to realise that size does matter in the markets, particularly when strategy fails to deliver.
At this stage, there are only two platforms which deliver: WealthLab Developer and Amibroker. Both have a comprehensive position sizing library.
Matlab can deliver but You will need to buy an additional expensive module. Matlab is an expensive guillotine, hardly suitable for neurosurgery. I do not recommend it.
WealthLab and amibroker are both C#. They both have canned strategies You can learn from and a vibrant community.

Personally WealthLab changed my life. It permanently changed the way I perceive the markets.

A word about optimisation: the masala smoothie approach
When I started working on the strategy, I, as everyone else, ventured on the side of complexity. I resorted to optimistion to find the best indicator value.

Most people, most quants, love to optimise and re-reoptimise and re-re-optimise their optimisations.
Bad news: it gives the right mathematical answer to the wrong question. Optimisation is the monosodium glutamate MSG of strategies: it gives depth and substance to poor quality food.
Work on the logic, not on the value of some hypothetical Billion Dollar idea.
Do not throw everything in hoping it will stick. Optimisers will waterboard the data until it confesses everything

PS: 100% Free Kick -A@#resource:
Andrew Swanscott interviewed me on Better System Trader.
Interview with Laurent Bernut – Better System Trader
Off line, he suggested I should offer something to his audience. Here is a tool I use daily.

The Trading Edge Visualiser User’s Manual
The way to use it to load your backtest data and look at distribution. I use this tool many times a day during strategy development.

What programs are usually used to back-test trading strategies?

The four horsemen of apocalyptic position sizing used by professional investors

4 horsemenDespite picking a fair share of good stocks, it is still tough to generate some consistent serious alpha. Picking the right stocks and exiting them well tells You how often You win. How much You win, however, is a function of how much You bet. Some professional investors pay surprisingly little attention to their bet sizes. Below are four algorithm often practiced by professionals that can

  • Four popular bet sizing algorithms used by professionals that have negative gain expectancy
  • Size does matter in the markets: 1$ or 100 will have a different outcome

 

When it comes to bet sizing, there are only two sizes: either too much, either too little. As a professional short-seller, position sizing is mission critical. Successful positions shrink. Not only do they contribute less and less, but they also tilt exposures (net & net Beta). To add insult to injury, they become less noticeable. On the other hand, unsuccessful positions balloon. They immediately hurt. So, I have spent years studying the science of bet sizing. I sought to learn from other investment professionals. It eventually dawned upon me that Long biased people rarely ask themselves the same questions. For them, bet sizing does not have the same degree of urgency. Worse even, it became apparent that some position sizing algorithms had outright negative expectancy, or nasty side effects that they were never even aware of.

Aral Sea Ships

Insufficient liquidity

Horseman 1: Liquidity. If You can’t get out, You don’t own stuff. Stuff owns You
Getting into a position is like buying a boat, or a second house. You can do that any day of the week. Now, selling a boat is tough (been there, done that). It may take time to build a position in a stock. Time is an expensive luxury few market participants can afford when they want to liquidate.So, no matter how attractive a story may be, if you can’t exit easily, just don’t enter.

Rule 1: don’t size your positions so that they may go Hotel California on You:
“You can check-out anytime You like, but You can never leave!”, Don Henley, Hotel California

 

 

Bernie-Madoff-mugshot

Example of long conviction

Horseman 2: High conviction: feel-good position sizing
Disclaimer: this position sizing is used by the greatest and the worst investors. The classic rationale is: “if You believe in something, then you should go big or go home”. What else is it but a feel good position sizing algorithm ? Risk is not quantified but subjectively assessed. The problem is mental accounting, or the constant emotional revisionism of the situation. Jack Welch said: “what can be measured can be improved”. If You can’t quantify your risk, then don’t expect improvement in consistent alpha generation capability.

The greatest investors also use conviction as a position sizing algorithm. The only difference is that they express conviction in units of risk. They quantify risk first and then put chips on the table according to their perception of the reward. If an idea does not pan out, risk can be parred down.

 

Horseman 3: Equal size: one-size-fits-all and the volatility roller coaster
This position sizing algorithm will not bring ruin, but it has negative side-effects that may prevent You from achieving your obejctives in terms of performance, attractiveness to investors and quality of life…

Equal weight is a form of laziness:
First, let’s look at the math behind equal weight. All trading systems boil down to their trading edge (Avg Win% * Win% – Avg Loss% *|Loss%|). Since all bets are equal, equal weight implicitly puts emphasis on the signal, and excludes the value of money management. In other words, stock picking has to be consistently above 50% to absorb losses and generate a profit. Unfortunately, no system works all the time. So, equal weight carries cyclicality in performance.

Ignoring volatility at the position sizing level invites volatility in the portfolio
Not all stocks have the same personality. Some are more volatile than others. For example, internet stocks tend to be much more turbulent than utilities. If all positions are sized equally, then the most volatile stocks will drive the volatility of the overall portfolio. Morality, ignoring volatility at the position sizing level will in turn invite volatility in the portfolio.

Horseman 4: Average down, martingale and the certainty of ruin
Rookie gamblers always come up with some elaborate scheme to break the casino. It is usually a variation on the theme of doubling down after each loss. They believe that the losing streak will end and they will recoup their losses. This position sizing algorithm is known as martingale. Let’s look at the math behind this algorithm

1. Adding to a losing position reduces the hit ratio
2. even if You had infinite capital, the most favourable outcome would be break-even. First, do You have infinite capital ? Second, any other outcome before the most favourable one carries an interesting probabilistic property called certainty of ruin
3. Doubling down means adding to losers. Resources have to come from somewhere, probably winning trades. Books written by successful market participants always emphasize “cut losers, ride winners”. Do You know any successful market guru who says “cut your winners, ride your losers ?”

In conclusion, there is a reason casinos have gold, marble, paintings from masters and gamblers declare bankruptcy. Double down on losers and You will go broke. One more thing about probabilities, it’s not about if, it’s about when.

Conclusion
Size does matter in the markets. Not paying enough attention to position sizing has consequences that range from unpleasant volatility to certainty of ruin. Position sizing is not a glamorous topic, but in highly competitive sport, every little bit of edge counts