Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trading "realtime" possible to backtest in Q'topian?

Hi,

I am currently programming a very promising algo, but now I have reached a problem and not sure if its even possible to solve.

My algo is high frequency day trading, actually on tick base.

Nevertheless a main indicator to generate signals is a Simple MA on minutes basis.

Basically the signal should trigger, when the actual price ("tick") is reaching the Simple MA.

As the Simple MA of the current period needs the actual closing price of the minute bar, its actually not possible to compare actual price and "potential" Simple MA that included the recent period.

Therefore I have programmed a routine that is forecasting this Simple MA and the algo should buy/sell when the actual price is reaching this forecasted interval even before the "real" Simple MA can be calculated. This is fundamental as the price is very often bouncing at this SMA level.

The question is now, is Quantopian somehow able to backtest trades in "realtime" or do we need to trade based on closing prices of e.g. minute bars.

Thanks

1 response

All of Quantopian's infrastructure runs on a minute-level or daily-level basis. This includes research, backtesting, and live trading. Tick data and high-frequency trading is a different ballgame and one that we're not tackling. If you have a strategy that works on minute data then I encourage you to try it out and also simulate the impacts of commission. You can also use research to simulate what levels of broker commissions make your strategy profitable, and when the edge slips away. Here is a webinar covering the topic and showing how to construct a trading strategy.

In backtesting, all orders are submitted at the close of one bar and filled at the close of the next bar. So in minute mode, an order is submitted at 10:00AM and is filled at 10:01AM (per the slippage model) . If you want the orders to fill at the open of the next bar, a hack was shared in the community as a workaround: https://www.quantopian.com/posts/trade-at-the-open-slippage-model

In live trading, the same idea persists with slightly different execution. An order is submitted at one bar, for example at 10:00AM and it's sent immediately to the broker. They fill it within seconds (depending on the security's liquidity). The filled order gets updated in your live algorithm dashboard in the next minute, at 10:01AM.

If you have a different datafeed that you want to try with higher resolution, take a look at Zipline. It's our open-sourced backtester (the same one that powers the IDE). There is also a Google Group for discussions and questions.

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.