Back to Community
Betafishing

Recently I’ve noticed a few posts here discussing various interesting beta-correcting techniques. Usually, the code provided is something you can tack onto the end of any existing strategy, and it works basically like this:

# If beta is positive, sell some SPY.  
# If beta is negative, buy some SPY.  

Rinse and repeat.

First, I want to point out the merits of these strategies, because they do have many great uses. For personal trading algorithms where you are essentially your own fund, they are a great way for you to control your own market exposure! You can even adjust the target beta to anything that suits your needs. These can be a very powerful tool for anyone who has a great personal trading strategy, but wants to maintain a solid 50% or so correlation to the market as a sort of insurance policy against the unknown quirks of their code.

But, more often than not, this code is promoted as a way to boost yourself to the top of the contest leaderboards.

I see two primary issues with using the code for this purpose:

It actually works to defeat the purpose of Q seeking a beta-neutral strategy.

The reason Q and other funds like their underlying strategies to be “pure alpha” is so that they can control their own market exposure, as outlined above. Sometimes, this means targeting zero, but that’s not always the case. Justin Lent does a great job of explaining this here.

What they want is a beta-neutral strategy, not a beta-neutral algorithm. Why? Because if all they cared about was zero-beta, period, they could just correct every allocation algorithm with the above code snippets; just short SPY whenever things are looking a little too much like the market. The thing is, a simple pairs strategy (like ones Q itself has repeatedly touted) in theory has a zero beta and positive returns. But why bother with pairs if you can just buy the “good” half and short SPY instead? Boom, zero beta.

In the end, this isn’t pitching Q a strategy, its pitching Q a carefully beta-controlled fund. As a standalone, it’s fine, but this is unhelpful when taken in the context of dozens or hundreds of other algos in aggregate, as they plan to do.

These strategies are by definition reactive, not proactive.

You need to wait to observe the beta of your strategy to decide how much to correct for with SPY longs / shorts. This is manipulating the metrics after the fact at the expense of the purity and intent of your underlying strategy, plain and simple. If your true strategy is actually good, it won’t need a hedging component that is entirely SPY, VOO, or AAPL & GOOG. In my mind, this is no different than when contest winners were shorting one share of one stock to get the hedging badge.

Often, people realize after adding these “fixes” that the returns, Sharpe, and other metrics of their algorithm has been compromised. It’s easy to hope that fifteen lines of copied-and-pasted code will optimize one metric without affecting anything else, and sure, it can be fun to game the contest, but please, please, please don’t deceive yourself or others about what you have accomplished by doing so.

I'd love for Q and others to weigh in on what I've said here; I'm new to the field relative to many of you, and love being told that I'm wrong for the opportunity to learn about and discuss topics such as these.

Edited for readability and tone.

13 responses

Brandt,

Thanks for the thoughtful post - these are great points and this is a topic I've been ranting about a lot lately inside QHQ. We have been thinking about how to find a good way to communicate this message at scale.

To play these ideas back but with some of my own spin, it's often not a great solution to leave worrying about market beta to the end of your algorithm development process and then look to apply a 'correction' if you discover your beta is too high. Instead, I would suggest that it's better to start off thinking about why your strategy should generate returns, and whether part of that mix is either implicitly or explicitly based on a view that the overall stock market is going to go up or down over some future period.

When it comes to designing strategies that might be attractive to Quantopian for an allocation, we are most interested in strategies whose economic rationale is not tied to a bet on the market's future performance. An example of such a strategy would be an algorithm which assigns an expected profit to a universe of 1,000 stocks based on a multifactor model combining technical, fundamental and event driven signals in some insightful manner, and then selects equally sized long and short portfolios from the top and bottom X-percentile of that list. (To get fancier still you could check whether the resulting portfolio has a bias over time to long or short more stocks from a single sector or market cap range and try to control for this in your portfolio construction)

This approach is by no means the only way to invest intelligently, but it's the approach we chose to focus on initially because it meets a strong market demand we see among institutional investors for pure alpha strategies. Investors (both large and small) have many very cheap options for investing in strategies that are correlated with (even specifically indexed to) the market's performance. Pure alpha strategies on the other hand, while they often generate smaller annualized returns, can offer diversification benefits, as well as much smaller expected volatility and thus can benefit from the application of leverage.

Best regards, Jess

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@BBucher Thanks, my comment edited

I think the notebook + backtest from the recent webinar are a good example of what Jess and Brandt are talking about:

https://www.quantopian.com/posts/how-to-get-an-allocation-writing-an-algorithm-for-the-quantopian-investment-management-team

It holds more than 300 positions per day, uses sentiment signal, and trades daily. I strongly recommend watching the recording of the webinar. Jess gives a very thorough breakdown of the Alphalens and Pyfolio tearsheets in the notebook.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Does zero beta well. With default commission it loses $38k though.

Would love to see something in this direction and profitable:

a universe of 1,000 stocks based on a multifactor model combining technical, fundamental and event driven signals in some insightful manner, and then selects equally sized long and short portfolios from the top and bottom X-percentile of that list.

Thanks for the responses, Q. I'm always happy to help start a conversation... especially when it's something that really bugs me!

Blue, one thing I observed in the careful wording of Jessica's suggestion:

When it comes to designing strategies that might be attractive to Quantopian for an allocation, we are most interested in strategies whose economic rationale is not tied to a bet on the market's future performance. An example of such a strategy would be...

While I'm sure that there are quite a few winning strategies that fit her description, I think that she was deliberately avoiding specifics in order to communicate her point on what an example of a market-neutral might look like. A large number of stocks handled in the way she described, if chosen profitably by the algo, would behave fairly market-neutrally and wouldn't require the aforementioned betafishing (I'm gonna keep calling it that 'til it sticks, by the way).

If there were very many easy ways to consistently choose extremely profitable longs and shorts, well, the "secrets" wouldn't as closely guarded as I assume them to be!

I agree, if one is serious about producing a strategy that will perform well in the real world, it does not make sense to add an automated post-hoc beta correction. In particular, a beta-correcting algorithm that is developed separately from the "main" algorithm is quite different than carefully hedging a strategy based on the economic principles that make the original strategy work.

That being said, I think it is in the power of the Quantopian team to fix the competition to reduce the incentive for people to do this kind of thing. In my (limited) experience, if an algorithm has a huge beta (e.g. magnitude > 0.5), it will probably not turn into a contest-winning algorithm by adding an "off the forum" beta-correcting routine. Unfortunately, however, the contest is structured in such a way that even a "small" beta (e.g. magnitude 0.1) is not great for the contest. The reason is that algorithms are ranked according to the absolute value of beta, and many contest algorithms are beta corrected to very small values.

Consider for example Contest 20. If someone comes up with a strategy that will naturally produce a beta between -0.1 and 0.1 (over a six-month contest inverval), then that person would have ranked around #48 in terms of beta in Contest 20. However, if that person added a beta-correcting routine to get their beta down to 0.01, then they would have ranked #11 in beta. If they managed to get it down to 10^-3, then they would have ranked #2 in terms of beta.

If subject to a serious statistical analysis, the original algorithm (with no beta correction) would be found to be less dependent on the market than the beta-corrected version. The reason is exactly what you said: the beta-correction algorithm is reacting to its correlation with the market. If the algorithm happens to make a lot of money on a day where the market also coincidentally does very well, then it will end up with a transient positive beta, and will shift its beta-correcting hedge to get back to zero. A truly market neutral algorithm would not be checking what SPY is up to and adjusting its positions.

Mathematically there is a flaw with the idea that an algorithm with beta exactly equal to zero over a finite time interval is somehow "more independent" of the market than one that has a small finite value that decreases with increasing backtest or paper trading interval. This would be like claiming that, for a coin toss to be fair, exactly half of the coin flips should be heads, half tails. Actually, it is extremely unlikely to get exactly 500000 heads out of a million coin flips, and if you set up a coin toss that does this every time, then it is certainly not a fair coin toss.

So, I agree that beta-correcting bolt-on modifications are probably worse than nothing in a real market scenario, I think the solution is for the Quantopian team to change the rules such that a beta of 0.0001 is not substantially better than a beta of 0.1, given that the former probably resulted either from luck or a beta-correction scheme, while the latter might be expected from a truly market-neutral algorithm under a random-walk model, for paper trading over a given time period.

Q went to a lot of effort to provide individual security Beta values in pipeline. That's one option for obtaining individual Beta values for stocks. The Beta calc code in my example used on individual stocks instead of just the portfolio is another. And that makes it at least possible for one to dynamically adjust one's universe to accommodate changing market conditions over time to target zero Beta. Pretty tempting.

Quantopian's Optimize is very good at holding near zero beta.

Blue: I definitely don't think what you did is cheating, in fact I think it's only natural to do something like what you did if one hopes to win the competition. Also, your point about optimizing for metrics is well taken, I shouldn't have been so quick to say it was worse than nothing to optimize for a small beta. What I was trying to say was that, if the Quantopian team don't want a bunch of algorithms with automatically adjust their beta by dynamically hedging, then they should change the rules so that they don't encourage that. In particular, I think it's true that if an algorithm naturally produces random, small beta values, then it's a shame that people are encouraged to add automated schemes to do better in the contest metrics, when their algorithms were probably better off without it.

As you say in your comment above, if an algorithm is not market neutral, it's a good point that obviously any hedge fund would hedge one way or another. Furthermore, it makes sense for the parameters for that hedge to be determined automatically, as you suggest. In that situation I see nothing wrong with what you did at all.

Douglas, that's a very interesting way of looking at it. As you say, a zero-beta isn't realistically possible, and isn't even specifically desirable. What we want is a low beta, and it's a noisy stat, so our scoring should better manage that. When we do a future revision of the rules we'll take that into account. We learn new things every month. Writing rules that hold up under all situations, without unintended consequences, is hard!

Going a bit deeper on that last point: we build the contest as a way to generally signal to the community what we're looking for. As incentive, we're giving away $6250 and 100 tshirts every month. In the next few months we hope to dwarf that amount in allocations and royalty payments. When the contest rules are imperfect, it leads to people optimizing for the wrong thing, e.g. getting their beta from .1 to .01. When that happens it's really too bad, both for Quantopian and for the author. There's a much bigger incentive at work here than a $5000 contest.

I think this has been a very constructive debate about ideas, and free of personal criticism. It's vital that, as a community, we are all able to disagree about ideas without personal affront.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Dan: Thanks for your note -- this discussion is the ideal outcome I was hoping for when I chimed in.

Blue, I've reworded the opening and closing sentences of my original post to remove confrontational wording and encourage discussion rather than mere criticism. Thanks for the heads-up.

I also adjusted my comments, after Brandt did. Thanks.

I agree that beta is a noisy statistic, and that depending on the timeframe you're looking at, you're very likely to have some amount of beta exposure even in a return stream truly independent of the market. I also think that setting up a portfolio that is structurally independent of the market is a much better approach than having to go back in and correct for beta on the fly.

In general forecasting beta isn't that easy, and any time you have to manually correct it in the algorithm you're really trying to forecast what it will be going forward. Doug is totally right that you can have knee-jerk reactions. Imagine a strategy in which just happens to move with the market for a month, even though it's mostly independent. A method that just looks at historical beta and updates the portfolio will then incorporate information about how the market is moving into the updated portfolio weights, leading to potential exposure to the market going forward when the best approach would have been to sit tight.

You just need to decide whether a historical measurement of beta is a good forecaster for your strategy, or if you need something else, of if a good forecaster even exists. The default is usually looking at beta over the last N bars, but again that may not work all the time to predict it over the next bar.

For those not as familiar with all this reading this thread, we have a lecture on beta here.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.