Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Hope is not a strategy

The use of two years of the tail-end of a 6 year bull trend as the criteria for selecting a winning strategy seems like a way to lose a lot of money. With the VIX finally stirring again; the Swiss psychotically slapping the markets around; the EU on the ropes; and the US equity markets suffering from chronic high altitude nosebleeds, are the advisers behind the Q's fund and contest aware of the narrow view they've taken?

Ignoring the volatile years of 2011 or 2008 as part of the vetting process for strategies seems to be taunting the executioner...

20/20 hindsight is handy I know, but still, even a toddler could look at this image and predict the next move.

SPY - long term view

RE: the SNB -- what a negligent band of bumbling buffoons. There will be legal repercussions from their egregious handling of their currency.

7 responses

I'm pretty comfortable with the choices we're making. There's a big difference between the contest and the fund.

The contest is using a 2-year backtest and a minimum of a month of live trading - though we hope to stretch both of those out in future versions of the contest. We will readily agree that is a thin track record. On the other hand, we're backing it with $100,000, and it will stop-out if it drops more than $10,000. That is not a large risk for Quantopian. We don't want to lose $10,000, but it doesn't test our finances, either. In exchange for taking on that risk we get a lot of good things, including a real-money track record that we can start evaluating for the fund.

The hedge fund isn't going to make investments based on any 2-year backtest. We're going to test them over much longer periods and different market regimes. 2008, 2011, and other tests too.

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.

Gary,

The winning algorithm is allowed to invest as much or as little of the $100,000 that it wishes.

If the total value of the assets being managed by the algorithm (cash - short positions + long positions + unrealized gain - unrealized loss) drops below $90,000, we will stop the algorithm.

For example, let's say the algorithm takes the following positions the first day it runs and then holds them:

  • $50,000 cash
  • short 1,000 shares of stock A, originally shorted at $10 per share
  • short 1,000 shares of stock B, originally shorted at $10 per share
  • long 2,500 shares of stock C, originally bought for $10 per share
  • long 2,500 shares of stock D, originally bought for $10 per share

Let's simplify by ignoring the cost of borrowing the A and B shares to short them, though obviously in real life that cost would obviously have an impact on the algorithm's performance.

But let's say, instead, that though the value of stocks B, C, and D don't change, the price of stock A suddenly doubles to $20. The total value of all the assets being managed by your algorithm is now $90,000, because you now have a short exposure of $10,000 in stock A (($20/share current value - $10/share short price) * 1,000 shares). At that point we would stop the algorithm and liquidate all of its holdings.

Similarly, let's say that the value of stocks A, B, and C remain constant, but the price of stock D suddenly drops to $6. Your total asset value is, again, now $90,000, because you've suffered a loss of $10,000 on stock D (($10/share purchase price - $6/share current value) * 2,500 shares). Again, at that point we would stop the algorithm and liquidate all of its holdings.

I've given examples which assume three stable stocks and one moving stock, but of course all of the stocks are likely to move in value. In this particular example the total asset value of your account at any given time would be:

[ NOTE: Edited because I got the formulas slightly wrong when I first posted this.]

$50,000 + ($10 - stock A current price) * 1,000 + ($10 - stock B current price) * 1,000 + stock C current price * 2,500 + stock D current price * 2,500

If the value of this expression ever drops below $90,000, then we stop the algorithm and liquidate all its holdings.

To make it slightly more realistic, we can put back the cost of shorting he stock that I omitted for the sake of the simple examples:

$50,000 - fees charged by IB to date to short A and B + ($10 - stock A current price) * 1,000 + ($10 - stock B current price) * 1,000 + stock C current price * 2,500 + stock D current price * 2,500

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.

I think it would make more sense for Quantopian to stop the algorithm only if it drops below 90% of the value of 100k in the S&P 500 would have, if started on the same day. As is, if the market drops a few points, and the algo is slightly unlucky at the same time, it seems that would be a quick stop.

I think we would expect the algo to have exit triggers built into it to avoid taking a bath if the market drops a few points and the algo is slightly unlucky at the same time, certainly given that we've spelled out the rules of the contest and made it clear that we'll stop the algo if its total assets drop below $90,000.

Hello Jonathan,

Is there a built-in function or code snippet that could be used within algos to be submitted to the Open contest, that would be one-to-one compatible with the Quantopian $90,000 trigger? Is it simply a matter of comparing context.portfolio.portfolio_value to 90000? Or would context.account.net_liquidation need to be used? Or something more complicated?

Also, what are the details on the timing of the evaluation? On https://www.quantopian.com/open/rules, it says:

If the Trading Account's value drops below $90,000 USD, the algorithm will be stopped and the positions liquidated

And above, you say:

If the value of this expression ever drops below $90,000, then we stop the algorithm and liquidate all its holdings.

So, I'm figuring that the evaluation will be made every time handle_data is called by the algo (not necessarily every trading minute, since the algo universe may only contain infrequently traded stocks). Correct?

Grant

Is it simply a matter of comparing context.portfolio.portfolio_value to 90000?

Yes, portfolio_value is the value of the expression I posted above.

So, I'm figuring that the evaluation will be made every time handle_data is called by the algo.... Correct?

Frankly, we haven't completely figured out the implementation yet. We'll figure it out before the end of the first contest, I assure you. ;-)

Thinking off the cuff, I don't know if this is what we're going to end up doing, but it would be neat for this last-ditch stop-loss guard to be available for everyone to use. For example, it would be cool if, in addition to specifying the initial capital base, one could also specify a minimum portfolio value which would trigger automatic liquidation of all assets followed by the algorithm stopping. One way this could be implemented is by automatically replacing handle_data with something like this pseudocode when the stop-loss guard value is hit:

def handle_data(context, data):  
    if 'lost_guard_initialized' not in context:  
        context.lost_guard_initialized = True  
        context.orders_canceled = False  
        context.done_waiting_for_cancels = False  
        context.assets_liquidated = False  
    if not context.orders_canceled:  
        ... cancel all open orders ...  
        context.orders_canceled = True  
        return  
    if not context.done_waiting_for_cancels:  
        if ... there are still open orders ...:  
            return  
        else:  
            context.done_waiting_for_cancels = True  
    if not context.assets_liquidated:  
        ... place orders to liquidate all assets ...  
        context.assets_liquidated = True  
        return  
    if ... there are still open orders ...:  
        return  
    raise Exception('Stopping algorithm after stop-loss liquidation')  

Thanks Jonathan,

I'll play around with a guard to avoid triggering an automatic liquidation when this condition is met:

context.portfolio.portfolio_value < 90000  

As I've thought about it, it's a bit tricky, since it is not just a matter of getting out of the market in some fashion, but also getting back in automatically.

Grant