Back to Community
'Gaming' the contest.

What's the minimum percentage I need to be hedged in order to meet the simultaneous long and short requirement? I'll explain further. My algo predicts, with some success, when the market is in bull or bear mode. I'm using that tactic to bring down my beta so the simultaneous long and short requirement is a bit of a bother. For example I don't want to hold a lot of SPY short when the market is in bull mode. Ideally one wouldn't hold any at all, one would only hold it short when the indicators suggest the market is going to drop. I could 'game' the contest by holding just 1% short and 99% long to meet the simultaneous long and short requirement but I don't want to trip any red flags. Is 5% or 10% short while in bull mode an acceptable number? If not what is?

14 responses

Warren, I think you're asking the wrong question. I'd suggest that a better question is, "How can I improve this algo such that I can get an allocation from Quantopian?" Here's why: If you win the contest, you get $5000. If you get an allocation, and your algorithm continues to perform well, you can earn much, much more (see below).

The contest is a way for us at Quantopian to signal to the community what we're looking for in an algorithm. If you're trying to "game" the contest, you're taking yourself out of the running for an allocation. We are looking for algorithms that are beta- and dollar-neutral. If your strategy is explicitly trying to be long, it can't get an allocation.

Also, the contest was created before we were making allocations. In 2015, all we could offer was $5000. It's 2017, and now the payouts can be much larger. How much larger? I'm going to update an answer I gave in the past:

An author's royalty payments essentially depend on three factors: 1) the size of their allocation 2) the performance of their algorithm and 3) the fraction of the net profit that the author receives. Our allocations in April maxed out at $3 million. Our goal is to significantly increase the size of the allocations that we make in 2017. Our goal is to make allocations as large as $50 million by the end of the year.

I'll give you a completely hypothetical, back-of-the-envelope example answer. Please understand that this is for illustration purposes only and the actual details of any future allocation will vary. The details of the calculation of net profit and the payment schedule, which are included in our author licensing agreement, are not covered in this simple example.

  • allocation: $50 million trading allocation on January 1 (that's gross market value, which includes leverage)
  • algorithm net profit: $1.5 million as of December 31 (reflects a 3% annual return)
  • author's share of net profit: 10%
  • author's annualized royalty income: $150,000

With that kind of potential, I'd suggest that you refocus your efforts. If you're gaming the contest, you're playing the wrong game.


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.

To be sure my algo predicts with some success when the market is going to rise or fall. I could be argued that the best hedge against market crashes is to know when the market is going to crash so you can go short.

Also to quote me 'Is 5% or 10% short while in bull mode an acceptable number?'. I'm trying to ensure that I'm not 'gaming' by looking for an acceptable figure.

It all begs the question, is being able to predict when the market is going to rise or fall an acceptable substitute to hedging? If that simply isn't what you are looking for with regards to allocations then yes, I can examine algo's that are fairly balanced simultaneously and don't flip back and forth between short and long positions with high frequency.

I agree that being able to predict if the market will rise or fall is likely valuable to someone.

In our case, though, it's only useful if you can take advantage of that prediction while remaining beta- and dollar-neutral. Your last paragraph hits this point fairly clearly - for our allocations, we need to be continuously neutral, not flipping long and short.

To be clear, I'm not saying that your method is "wrong." It's just not the method that we're supporting through allocations. Our allocation decisions are driven by the financial product that we're trying to create for our investors.

Thanks Dan, I'll refocus my approach.

Dan, I have a related question. If I day trade in and out of just one ETF (say SPY) always closing my positions before market end, will I violate any rules for the contest. I wont be maintaining long and short simultaneously in my algo and it appears to me that strategy will break the hedging condition (long+short) for the contest. I could create a basket of say 20 stocks from S&P500 and follow the same strategy to increase the number of symbols in consideration but feel that SPY is a far better choice (in terms of scale issues and slippage and diversificatino) than just me picking and choosing a sample set of S&P500 stocks to day trade. Please advice.

Leo, I'm going to repeat the points from my earlier reply, and perhaps they will be more understandable.

  • Quantopian is making allocations.
  • Our allocation decisions are driven by the financial product that we're trying to create for our investors.
  • We have a set of criteria that we use to make allocations
  • One of the most important criteria is that your algorithm minimize market risk by being hedged
  • The contest rules are designed to guide the community in the direction of an allocation, and therefore the contest rules are similar to the allocation criteria

So, if you have an algorithm that goes in and out of SPY, it might be a perfectly fine, money-making algorithm for you or for someone else. But it's not an algorithm that meets our specific requirements for the contest or future allocations.

Any long = short rule can be trivially worked around by being short a cash or short-dated government bonds ETF, or a cash-like stock, e.g. a done deal cash takeover with a few days to go before delisting.

Getting beta within the expected range is the hard part. A SPY day trading algo could in theory achieve that if it is not random and the alpha > churn costs. Good luck with that.

I asked that question so that I get some context on how to think about writing algorithms for contest and for fund. I am thankful to Dan for clarifying what Quantopian is looking for in the contest and their fund. And I will be retooling my thinking towards that. I am software programmer who primarily works on big data analytics for modeling. My finance background is zero. Having gone through the lectures and Dan's reply it gives me a whole new perspective now on what is being sought, than when I just started my first algorithm by myself without looking into the requirements or the material on the quantopian lecture site.
I'll be working within the "framework" of requirements of Quantopian for the contest. It has likely saved me a couple of months of meandering through unrelated areas of finance and types of trading algorithm by just asking this naivete question on the forum.

Leo, can you post a screen shot of your algo? I'd really like to see a working spy prediction strategy.

I'm not Leo, but here is a screenshot of a Spy prediction algo. Results previous to 2007 are not as impressive, I'm not sure if that's due to overfitting on my part, or changing market dynamics, or some other reason.

Spy Prediction Screenshot

Toan. I haven't coded an algo yet. Just ideas on how to build a predictive model for spy. I was going to start working on that but now I am going to refocus my attention on what Quantopian wants which seems to be very specific and requires a different type of approach than what I had initially envisioned to work on. Glad I got that sorted out here in the forums without wasting time on tangential stuff.

@Leo Here's a simple mean-reversion strategy for SPY using RSI2

Clone Algorithm
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
import talib

def initialize(context):    
    schedule_function(setAlerts, date_rules.every_day(), time_rules.market_close())
    schedule_function(rebalance, date_rules.every_day(), time_rules.market_open())
    set_slippage(slippage.VolumeShareSlippage(volume_limit=0.025, price_impact=0.1))
    context.asset = symbol('SPY')
    context.rsi_period = 2
    context.OB = 50
    context.OS = 30
    context.pct_alloc = 1.00
    context.leverage = 1.00
    #Alert to buy or sell next day.
    context.buyAssetAlert = False
    context.sellAssetAlert = False
def setAlerts(context, data):    
    asset_price = data.history(context.asset, 'price', 3, '1d')
    rsi = talib.RSI(asset_price, context.rsi_period)

    if rsi[-1] < context.OS and data.can_trade(context.asset):        
        #order_target_percent(asset, context.pct_alloc * leverage)
        context.buyAssetAlert = True
    elif rsi[-1] > context.OB and data.can_trade(context.asset):
        #order_target_percent(asset, 0.00 * leverage)
        context.sellAssetAlert = True

    record(leverage = context.account.leverage)
def rebalance(context, data):
    if context.buyAssetAlert and data.can_trade(context.asset) and context.portfolio.positions[context.asset].amount == 0:  
        order_target_percent(context.asset, context.pct_alloc * context.leverage)
        context.buyAssetAlert = False
    if context.sellAssetAlert and data.can_trade(context.asset):
        order_target_percent(context.asset, 0.00 * context.leverage)
        context.sellAssetAlert = False
There was a runtime error.


is it the #1 of any leaderboard is selected for allocations? Do you notify authors that you are making an allocation? And how does one setup bank account details to receive whatever payments may come his/her way?


@Kory, your RSI2 SPY looks nice for personal trading.

@Leo, " I am going to refocus my attention on what Quantopian wants which seems to be very specific and requires a different type of approach..."
@Warren, " Thanks Dan, I'll refocus my approach."
Yes, I also appreciate the clarity with which you, Dan, are advising (helping) us to broaden our scope. For me also, what Quantopian wants is very different from what I have been designing for years for my own small personal trading account. What I am finding interesting and enjoyable is how much I'm learning from the need to be totally flexible and to shift approaches to suit the ongoing very different contexts.

Best wishes to all traders & algo coders :-)