Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
New Feature: Trading guards for your algorithm

We’re continuing to add features that support our live trading pilot. Today we’re introducing trading guards for your algorithm.

Everyone knows that code has bugs, and bugs that cause excessive trading are particularly problematic. We’re adding another layer of defense against a whole class of possible mistakes. You can now set limits to prevent runaway or excessive orders by your algorithm.

In the initialize() method you have the option to add:

  • Maximum Order Count: Sets a limit on the number of orders that can be placed by this algorithm in a single day.
  • Maximum Order Size: Sets a limit on the size of any single order placed by this algorithm. This limit can be set in terms of number of shares, dollar value, or both.
  • Maximum Position Size: Sets a limit on the absolute magnitude of any position held by the algorithm for a given security. This limit can be set in terms of number of shares, dollar value, or both.
  • Long Only: Prevent the algorithm from taking short positions.

These were customer-requested features and we’re happy to deliver them! Try these out in your backtests and live trading algorithms.

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.

2 responses

Another 3 ideas:
1) Limit on leverage
2) Place limit on short exposure than stop shorting completely
3) Some guards against exchange rules like triggering day trading rules on small accounts, margin related issues and rules, short restrictions etc. through helper methods

Another things that might be useful is to be able to check a possible order violates any guards. This information can be exploited by the algo.