QuantRocket Blog

QuantRocket offers a lot of power and flexibility under the hood. The Quick Tips series helps you know what QuantRocket can do and get the most out of your trading. For more tips like these, follow QuantRocket on LinkedIn or X.

This article's tips:

  • Quick Tip 1: Reuse code for multiple variants of a strategy
  • Quick Tip 2: Chain multiple commands with the pipe ( | ) character
  • Quick Tip 3: Dry run your Zipline or Moonshot strategy

Quick Tip 1: Reuse code for multiple variants of a strategy

Need to run multiple variants of a trading strategy, such as a large-cap variant and a mid-cap variant, or a long variant and a short variant? Don’t resort to copying and pasting the same code into multiple files, which is error-prone and hard to maintain. Moonshot and Zipline offer a better approach: use inheritance to create multiple variants of the same strategy without code duplication.

Learn more about code reuse in Zipline or Moonshot.

Quick Tip 2: Chain multiple commands with the pipe ( | ) character

The pipe character ( | ) allows you to chain two or more commands together, sending the output of one command as the input to the next command. Using Moonshot with pipes, you can send your trading strategy’s orders to the broker for execution or to the logs for troubleshooting or review.

Quick Tip 3: Dry run your Zipline or Moonshot strategy

With Zipline's "dry run" option, you can write orders to a file instead of sending them to your broker. This lets you troubleshoot your strategy without placing orders, manually inspect orders before placing them, or generate orders for manual execution outside QuantRocket. Learn more about dry runs with Zipline.

Similar functionality is available for Moonshot.

About QuantRocket

QuantRocket is a Python-based platform for researching, backtesting, and trading quantitative strategies. It provides a JupyterLab environment, offers a suite of data integrations, and supports multiple backtesters: Zipline, the open-source backtester that originally powered Quantopian; Alphalens, an alpha factor analysis library; Moonshot, a vectorized backtester based on pandas; and MoonshotML, a walk-forward machine learning backtester. Built on Docker, QuantRocket can be deployed locally or to the cloud and has an open architecture that is flexible and extensible.

Learn more or install QuantRocket now to get started.

QuantRocket LLC is not a financial advisor and nothing on this website or in any materials created by QuantRocket LLC should be construed as investment advice. All results are hypothetical unless otherwise noted. Past performance is not indicative of future results.

The material on this website and any other materials created by QuantRocket LLC 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 QuantRocket LLC.

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. Neither QuantRocket LLC 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 QuantRocket LLC 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. QuantRocket LLC 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. Past performance is not indicative of future results.