Now Reading
GARCH Without Pocket Protectors
107

GARCH Without Pocket Protectors

by Trading GangsterMay 16, 2017

Since Mole is out visiting family in the beautiful Euro spring, I’m filling in with a guest post today. Mole and I have been e-mailing a bit and shared some great conversations about trading. It started from the excellent series on Raw Edge Discovery and if you haven’t read it, it’s 10 minutes that might save you years of frustration and a nuclear draw down on your account. We have a lot of similar ideas about things, so hopefully I can share a thing or two that can add some ca$h money to your trading account.

About me – I’m an algo trader, somewhere between a quant geek and a chart trader. I’d rather spend my time developing algos than looking at charts all day, though both work and I respect both sides. After all, there are dudes pulling down $100k a month regularly at my firm using Excel, a notepad and Sterling (which is just another mediocre trading platform with charts and blinky boxes that induce ADD). They think python is a snake and c# is a sexually transmitted disease.

If you’re reading this, then you’re probably familiar with quantitative trading. Geeks meet trading. If you’ve been to any type of quant event, you’ll find it filled with dudes wearing ill fitting sport coats that aren’t familiar with the modern phenomenon known as tailoring.

Many of them enjoy the process of intellectual cock stroking more than they do making money. A quick browse of the discussion forums on Quantopian should make that evident. A discussion about mean reversion quickly turns into a Showcase Showdown about whose method of calculating the inverse of the covariance matrix is better.

A lot of the white papers and discussions by quant geeks require graduate level courses in linear algebra and PhD level statistics to follow along. However often you can lift the core concept of what they are doing without brushing up on Laplace transforms. In this post I’m going to be doing just that – lifting a simple concept from the quant world and applying it without 7 pages of partial differential equations.

On to making money.

A great example of how quant geek speak is lost in translation is GARCH. GARCH is an acronym and what it stands for really is irrelevant. GARCH is a method of forecasting volatility. There are multiple 40 page white papers you can download and read if you’re looking for exceptionally dracone reading material. In most of the papers you’ll see pages of drawn out equations with terms like maximum log likelihoods. Yawn…

If you would like to go through the math of GARCH in depth, there is an academic discussion about GARCH with all of the math involved for those inclined on Quantopian in their Lectures section. I’d recommend going through it in depth – if you see how my example could sharpen your trading edge a bit.

The important thing about GARCH is the core concept: volatility is mean reverting, and the volatility tomorrow has a high correlation to the volatility of the past few days. That’s the core idea and it’s not rocket science. The official definition of volatility is the standard deviation of the close-to-close returns. Even that is a bit much to take in on the first bite, so let us break it down into two parts. First, the close-to-close returns, which heretofore, we will just call returns:

returns = (todays close price  – yesterdays close price)/(yesterdays close price)

So if AAPL closed at 152 today and closed yesterday at 149:

(152 – 149)/149 = .020 = 2.0%

Now that we have the close-to-close returns, we need to compute the standard deviation over the last X trading days. For an in-depth explanation of standard deviations, see Mole’s post from last week. When it comes to volatility, what’s more important to grasp is the concept: that 2/3rds of the data is likely to occur within +/- 1 standard deviation, assuming the data is normal data. In quant speak, this would be called Gaussian data. Even that can cause quant diarrhea, maybe about which I’ll dive into more in depth if I earn my stripes for a second guest blog post.

Thanks to Yahoo Finance, python and pandas magic we can quickly determine the annual volatility on AAPL: 17.5%. I did some quick back-of-the-envelope calculations on some other targets for comparison:

AAPL: 17.5%   PM: 16.3%    PEP: 11.7%    NFLX: 35.1%   SPY: 9.5%  QQQ: 11.3%  VXX: 56.8% 

PM

NFLX

As day traders, we really don’t care much about this number. Except that we’re much more likely to find targets with high volatility much more fruitful for momentum trading and low volatility targets more fruitful for mean reversion trading. You’re probably better off looking for momentum trades in NFLX than in PM. Again, not rocket science and very obvious from looking at the two charts of the daily returns in NFLX compared to PM.

Now back to GARCH. If you read the blog of Quant Jesus Ernie Chan, He has an excellent post on GARCH predicting the direction of tomorrow’s volatility. And His talk on volatility from Quantcon 2016 is well worth watching, you can grasp the core ideas without a text book on stochastic calculus sitting in your lap. Bonus: I’m even in the video at some point, asking Him a question.

The point of Ernie’s post is that using GARCH on SPY, GARCH is over 58% accurate at predicting if tomorrow’s volatility is going to increase or decrease, compared to today’s. Is that useful? Damn straight it is. And Ernie is being modest with 58%, I urge you to verify his results if you find it fruitful. Let’s look at an example.

Let’s say we have a magic intraday momentum strategy (MIMS). Looking at all of our trades, MIMS has:

Win rate of 50% –

Average winning trades are .8R

Average losing trades are .5R

Further looking at our trading data, we find there is a high correlation between big R wins and the returns on that trading day. Digging further, we find that 64% of our winning trades happen when the returns are over 2.0% on that day. That shouldn’t be shocking and you shouldn’t need XGBoost to find there is a high correlation between big winning trades and the size of the move in the stock that day.

Hmmmm. It looks like if we had a way of finding when the close-to-close returns are likely to be over 2.0% before the market even opens, those are days we would want to be in the pool ready to kick ass and take names with our MIMS strategy. And maybe even goose our position sizes up from 1R to 1.25R.

But if yesterday’s return was 1.7% and GARCH is predicting today’s return to be less than yesterday’s 1.7%, what do we do today when a signal fires off in our MIMS strategy? Well there is a high probability, 58%+, that the return is going to be less than 1.7%. Which means there is even a higher probability of it being less than 2.0%. We know that over 2.0% is where the magic happens.

Which means sitting on our hands and do nothing is a good move, or reducing our position size to something like .5R from 1R. Because math tells us there is a high probability that this trade is likely to end up in the negative side of our R distributions. More simply, this trade is likely to suck ass.

Why is that? Well, there is at least a 58% chance (actually closer to 70%) that today’s returns will be less than 2.0%. We know if the returns are less than 2.0%, then the chances of our trade being successful are only 36% (1 – 64%). We simply avoid days when GARCH predicts the returns to be less than 2%.

This sounds magical. Rainbows and unicorns forever. In the real world, it’s rare that anything trading related that looks as magical in iPython notebooks translates into magical results in our account. This included. GARCH can be a solid foundation to improving performance of intraday strategies, however it can be substantially improved upon. I’ll leave that to the astute trader to  research.

In practice, this is likely to improve the expectancy of a momentum system by 0% – 25%. Not bad, but expectancy comes at the expense of trading opportunity. Would you rather take 500 trades with a .25R expectancy or 300 with a .32R expectancy? There is no right answer to that question, it comes down to your personal trading situation.

In summary, we can use GARCH to predict if something is going to move enough that we want to be trading it that day with a momentum strategy. If you’re a mean reversion trader or have a system that trades against breakouts, then knowing when the move in a stock is likely to be small, might be super beneficial to your monthly account statement. This can be beneficial whether you have your 10,000 lines of python strategy running on a colocated Linux server or you’re sitting in front of the computer looking at charts all day – with your itchy trigger finger on the mouse button.

If you recall the recent posts on Raw Edge Discovery, this is just that. Except here it’s not a discovery, it’s a Raw Edge Gift since I’ve done the heavy lifting for you. Go forth and print money.


About The Author
Trading Gangster
  • OJuice

    A guest post, nice and early, and its a good read. Cool. And Thanks.

  • ridingwaves

    Excellent write up TGangster….I find it very interesting with your PM vs. NFLX example, one a core divi play vs tech growth play with the opposite thinking coming out ahead via volatility….
    woke me up kind of….

  • ridingwaves

    might dip into some L volatility down here with opex later this week…

  • OJuice

    If this breakout fails, volatility might get a nice little pop. I’m biased to the upside right now though (for /ES)…

  • ridingwaves

    I’m L a lot thus a little contrarian play only, 1/2 R at most but feel some V might come into play…..ETF inflows over last 5 mos. is off the charts…

  • ridingwaves

    L PIRS at 3.98 Breakout of weekly above 4.30 will push it higher
    S at 3.70

  • OJuice

    How was the trip to South America?

  • ridingwaves

    epic…..
    great time and maybe last chance to spend some quality time in nature with daughter before grad school, work and life in general…..will post a couple pics later so not to clutter the board

  • ridingwaves

    a retest of today’s high will be my entry on vix L for 2-3 day play

  • Mark Shinnick

    Long equities since a bit earlier with tight stops.

  • OJuice

    By my lens so long as the gap from Monday stays open it is a green light to the upside. With some chop over the next couple days possible. I think 2480 SPX is in the cards if we can get a break to new highs, FWIW.

  • ridingwaves

    XLF keeps bumping into 100sma, tight cluster of mv avg.s at 23.78 area

  • http://www.captainboom.com/ captainboom

    Fearless’ view was that when the market was stuck at support or resistance, the easiest way through it was an overnight gap. I have seen this happen.

  • Darkthirty

    ad nauseum

  • Mark Shinnick

    Stood aside and have some puts.

  • http://gerb-reloaded.blogspot.com/ Gold_Gerb

    is it too early to celebrate?
    Mole, take your time. Relax, enjoyyyy.
    😉
    https://uploads.disquscdn.com/images/0bef33ac581e4eeedeaf28eac1d3a700567aba70197605554a0d2e6fad8c7798.png

  • Mark Shinnick

    Why does it seem his timing, even in vacation, is so bankable??

  • Scott Phillips

    Because we are built for pattern matching, and humans have a very poor ability to do instinctive mathmatics. We see something twice and think it happens all the time. Same reason why we believe certain indicators are an edge. Same reason why we buy lottery tickets.

  • Scott Phillips

    THIS IS A SUPERB POST (caps intentional)

    What a fine addition to evilspeculator

  • JH

    This is excellent. To translate it to the chart trader realm, This is the mathematical logic behind the (potential) edge in engulfing candles in certain scenarios, and a large part of why we look for breakout trades on range breaks on increasing volatility and hence bollinger band widening (but try to enhance the R/R by working entries on the break retest ;))

  • http://evilspeculator.com Sir Mole III

    Which is why I don’t explain the lack of comments. Almost embarrassing…

  • Yoda

    and most attribute this sell-off to Trumpf’s memos. Lulz.

  • BobbyLow

    It’s going to take awhile for this to play out but as for today goes it’s a good time to be long Gold and or the Miners.

  • OJuice

    Waves nice work on the volatility play.

    I got stopped out last night at B/E. Re-entered this morning.

    Pretty sure its gonna take more than this to take down the Teflon Don. And if he does walk out of this unscathed, the Dems are gonna start looking like the boy who cried wolf.

  • ridingwaves

    opex shenanigans more likely than political….as we discussed below…

  • BTrader

    zero is frozen again.

  • http://www.captainboom.com/ captainboom

    Frozen for me too. I emailed Mole.

  • RonnieH

    Also frozen screen

  • http://gerb-reloaded.blogspot.com/ Gold_Gerb

    Disney bottom in October last year, about 15 days earlier than the S&P.

    Disney (undeniably) topped in late April, and we have today, 13 days later.

    ..it’s just a theory.

    https://uploads.disquscdn.com/images/839eae64310d015bf39d7731858eff5490a6c9a1a65dc4309b152e64aa62fcbf.png

    one day does not make a trend.
    ..back to the Pool!
    -GG

  • BTrader

    its back working!

  • ridingwaves

    lots of folks jumping in there…..opex is next week for metals

  • Tomcat

    Is this a black swan???

  • ridingwaves

    here is one for reference….
    http://funkman.org/animal/bird/blackswan.jpg

  • ridingwaves

    VIX contango is present. 14.90 target…scalp the rally…

  • Yoda

    (late) Bulls are tasting blood today. Hopefully we’ll get some nice trend moves to play with.

  • BobbyLow

    I’ve said before that I hoped I was wrong about DT. But it’s not looking to good for him right now.

    It shouldn’t matter if you are a Republican, Democrat or Independent. This situation is becoming a festering hemorroid on this administration and on America.

    I remember all the denials during Watergate that began in June, 1972. It took 2 years for all the facts to come out. Some of Nixon’s mistakes was firing people that were getting too close. This could be DT’s mistake as well.

    After Nixon resigned in 1974 he still had 29% support so it will not surprise me that no matter what DT says or does he will still have his following.

    BTW, the original “Teflon Don” John Gotti eventually paid the price. So even Teflon wears out after awhile.

  • Mark Shinnick

    I’m sort of clueless.. What facts of the situation are driving your post here?

  • OJuice

    With the frenzied nature of his opposition and the media, as well as the near constant attacks, I’m sure something will stick eventually. No one has ever accused him of being the smartest man.

  • Mark Shinnick

    Yeah…still seems to have some more upside to go….but just hitting resistance, hanging on to the equity puts.

  • Mary

    The book is always better than the movie because it has more detail.

    Written news is more thorough than video news for the same reason.

    People tend to believe what they want to believe based on what they know.

    Anyone that gets all of their info from TV is relatively weakly informed.

    None of us here know all of the pertinent facts, only those we allow ourselves to be exposed to.

    Time must pass for this to play out and I think many will be completely surprised and need to eat some crow.

    Meanwhile, life goes on.

  • ridingwaves

    vanity is his downfall, hasn’t really changed….
    his problem is he is the salesman walking away without the deal because he just pitched the product without questioning the customer needs, then he begins to negotiate down price, bad mouth the competition, then it becomes its apparent he is talking and no one is listening…

  • BobbyLow

    I agree OJ.

    I also think that if you are going to come off to people the way he does, say anything in almost any offensive way imaginable about anybody without restraint, he put a giant sized target on himself. So whether for him or against him, payback can be a bitch.

  • BobbyLow

    This ain’t my first rodeo Mary. :)

  • Mary

    Nor mine, Bobby …

  • Mark Shinnick

    I suppose draining the swamp would stir up a lot of defensive responses.

  • BobbyLow

    It sure does especially when you try to refill the swamp with toxic waste.

  • Mark Shinnick

    Yeah…let’s not be adding any of our own…stick to trading, ok?

  • ridingwaves

    235 spy likely if it gets thru 236.60 via hourly over next day or 2.

  • Mark Shinnick

    Yeah, doesn’t appear to be one-day thing …so far :) Nice to have you back.

  • ridingwaves

    sold out of VIX L

  • BobbyLow

    That’s fine with me Mark.

    But lastly, there are a lot of issues that I’m sure we can agree on. It’s just that DT is not one of them.

  • OJuice

    He is offensive in a lot of ways. I would go as far to say that many supporters of Trump wouldn’t say they find his character very endearing. With that said, my take is the MSM and a lot of his opposition in DC etc. have sunk down to his level. And its pretty unflattering for everyone.

  • Mark Shinnick

    Looks like this is near the line…you going for the target?

  • ridingwaves
  • BobbyLow

    I agree OJ.

    But this begs the question of whether or not it’s OK for him to go on unchallenged in anyway. Our president is not supposed to be omnipotent and we do not have a dictatorship form of government.

    But on a lighter note, I’ve been long miners (NUGT) since Monday so I guess that’s a good thing. :)

  • Mark Shinnick

    Yes.

  • OzarkHillBilly

    Sorry I’m a little late to the party, but I still wanted to say “nice post.” I’ll be spending some of my time over the next few days catching up with the other great posts I’ve been missing out on lately.

  • OJuice

    If anything I would say he is challenged every step of the way. I’m not clear on where the image of him as a dictator comes from. Yes I’m sure he might like it that way, but, its not how things are going with 24/7 mainstream media barrage, resist movements, protests, what seems like an endless supply of “leakers”, and republicans in the house and the senate that swing from tepid support to full blown opposition.

    Although the constant stream of negativity sucks, it is nice to see people paying more attention. My memory of the Obama administration was much closer to what you would refer to as omnipotent.

  • Mary

    I’ve gotten to the point where I totally disregard everything that comes from anonymous sources – everything.

  • Scott Phillips

    I just don’t know who to believe, Bobby.

    The public servant, famous for impartiality and integrity with a 30 year history of public service.

    Or a toddler who scammed his way to the top job, the scammiest scammer ever to scam his way into anything.

    I’ve voted conservative my whole life, and I’m horrified by this clown. He is temperamentally unsuited to be anything but a used car salesman.

    Get used to the words “President Pence”

  • ridingwaves

    tried 13.55 on UXVY again..

  • Mark Shinnick

    There is always plenty of time…until there isn’t anymore. :)

  • BobbyLow

    Perhaps we can leave it at this.

    It’s taken me many years to do so but I’ve finally “accepted” the fact that different people can see things in a totally opposite way. You certainly have the right to believe what you believe and so do I. This is what America is supposed to be about.

  • http://www.captainboom.com/ captainboom

    I understand your hesitation, but had that happened with Deep Throat, I suspect Watergate would have been covered up.

  • BobbyLow

    Got your message. I’ll be sending you a reply soon.

  • http://www.captainboom.com/ captainboom

    Any time I get into a discussion like this, and I *do* try very hard to stay out of them on line, I’m reminded of Carl Sagan’s ‘Pale Blue Dot’ public lecture at Cornell in 1994, based on a photo taken by Voyager 1 four years earlier. This is worth reading and thinking deeply about.

    https://en.wikipedia.org/wiki/Pale_Blue_Dot#Reflections

  • Mark Shinnick

    There’s that wall again…

  • ridingwaves

    thanks for link

  • ridingwaves

    bears failed to take advantage when they breached it

  • Mark Shinnick

    Yeah…went long eq’s for time being.

  • kim

    Hey guys, anyone long eurusd?

  • Mark Shinnick

    I suppose some blow-off here could make it a one-day thing to your 235…or morning gap to there you figuring?

  • BobbyLow

    I’m not trading them anymore but I’m curious if anyone here was short equity indices before this morning’s open.

  • Ronebadger

    SPXU

  • Ronebadger

    There’s always “Turnaround Thursday” to look forward to…

  • BobbyLow

    And a 3X to boot. Good for you Ronebadger!

  • kudra

    I was, but I’ve been so since Nov. TZA up 8.2% today.

  • http://gerb-reloaded.blogspot.com/ Gold_Gerb
  • StockTalker

    Looks serious

  • kudra

    dip buying algo bots kicking in? The sell’s coming off this sell-off.

  • BobbyLow

    I’m glad you managed to get some of your money back today and we’ve already talked about and you’ve experienced first hand what can happen if you hold onto a trade too long. . .

    Speaking of which, it goes both ways. I held onto a winning trade too long today. After a beautiful gap up on NUGT, I should have closed it out shortly after the open with a substantial profit. However, I let it go down quite a bit before I closed it out. It was still a winning trade but I did not trade it as well as I should have. I need to work at becoming more accustomed to the price action on miners.

  • ridingwaves

    I got out at 14.95 sell order while getting haircut, hiking and diving seem to be natural hair growth products..
    think we get a down leg tomorrow and will buy L VIX on any bull thrust at opening

  • Ronebadger
  • kudra

    Thanks, BL. Stay nimble with the miners. i’ve seen you make great entries but give back by staying too long. Of course, hindsight is 20/20. DUST was a nice mover off the intra-day lows. As for me,TZA up a mere 6.55% now. They love to buy that dip.

  • Mark Shinnick
  • ridingwaves

    fun day, now U2 Joshua Tree Concert…

    get busy living or get busy dying…even when money gets left on table…

    https://www.youtube.com/watch?v=2AVy_opE3E4

  • Ronebadger

    VIX Step One Buy Signal today…above upper BB already

  • Mark Shinnick

    Yeah, Looks to me like bears still have some handles to work with.

  • http://gerb-reloaded.blogspot.com/ Gold_Gerb
  • Darkthirty

    Dji gap filled also………

  • http://evilspeculator.com Sir Mole III

    Hey guys – did I miss anything? :-}

  • Mark Shinnick

    Amazing…:)

  • Scott Phillips

    Trump took a turd all over the markets. I got stopped out of NQ for breakeven, and ZW for breakeven… and scalpius (60m) switched on the CCM on ZN and stopped me out, so I’m assuming you too.

    Not my finest day 😉

    Good looking setups now though. Bonds look solid to the upside tomorrow intraday, and KC looking good long, also if CT breaks daily high looks like retested new uptrend.

    Dollar still taking it in the ass. Euro looks like a steady low volatility march up

  • Ladywandering

    Trading Gangster, I read your post late last night, and now I just reread it. I haven’t gone and done any other reading but does this apply to any stock and etf? Anyway, you have planted some ideas in my head and will go investigating. Thanks

  • Yoda

    Lol.
    Bears (who?) were in control today. It must be a blue moon.

  • http://greenlander1.blogspot.com/ Greenlander

    Gangster does this apply to swing trading, i.e. does GARCH operate over multi-day periods? Looks like GARCH is for next day volatility for intraday trading. This is all above my head.

  • JH

    Yo mole, in case you were still wondering about the milder response to your quantutorial posts, I have this analogy for you.. Watching planet earth on tv gets people raving about nature, but class goes quiet once the teacher says open up your text book, doesnt mean content there is not important or appreciated!
    A la Scotts n TG’s posts about magical edges and how to find them, mesmerizing for the uninitiated and still exciting for those who already code and build systems, vis a vis your posts – tougher going for the uninitiated/chart-oriented set-up chasers, n not much new for those who already code… but i guess my point is, still extremely useful n necessary reading for ones like me who are somewhere inbetween n trying to evolve from the former to the latter!

  • Scott Phillips

    Exactly so. I’m sure Mole could make more money telling you the market’s gonna crash every day, blaming Yellen, and bullshitting you all… but unfortunately he has a bit of integrity.

    The reality of trading doesn’t quite match up to the sales pitch

  • Yoda

    Gangsta. Just read your post, and had to look up for ipython and c#. Awesome stuff and much thanks for sharing it. Quick query, what would be the easiest software platform to run GARCH on?

  • http://evilspeculator.com Sir Mole III

    I was being facetious Scott – but thanks for the update 😉

  • http://evilspeculator.com Sir Mole III
  • StockTalker

    Testing low

  • TradingGangster

    Since I’m not a fan of MATLAB at all, I’ll exclude that but there are standard packages for it. There are implementations in both Python and R, python is probably the most accessible if you’re new to quant geek stuff.

  • TradingGangster

    Good question. You have to not get too lost in the math and think even simpler – is there a relationship between last weeks volatility and this weeks volatility? Even simpler, is there a relationship between thing A (volatility over the last X periods) and the thing B (volatility over the next X days). You don’t need GARCH to do that, you could so a simple linear regression (y=mX + b) and see how well the volatility of different time periods is correlated.

  • TradingGangster

    Yes, both.

  • Yoda

    Thank you Sir. I’m going to look up Python. Also, are there any specific parameters that you use for GARCH, i.e for p and q?

  • TradingGangster

    For SPY, P=1, Q=2 is the best fit, depending on the time frame you’re using. You will need to run what is referred to as a maximum log likelihood test to find the best P,Q for each target. But for many,P=1,Q=2 is a good starting point.