Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Daily vs. Minutely confusion?

I see some confusion going back to 2012 over running day only tests vs. minute by minute. The basic 2 questions are:

  1. Can you use indicators calculated from daily data to screen / filter your universe of stocks you intend to trade intra-day

    • would it be correct to assume that Pipeline is doing exactly that, from the example:

      sma_10 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=10)

      assuming it's running 1x per day, pre-open, it follows that you would be interested in a 10 day moving average. Does that mean the USEquityPricing is a database of day bars?

  2. Can you trade / backtest using only day bars

    • if so, how to implement opening and closing orders - OPG & MOC?

Any help is appreciated!

3 responses
  1. Yes, what you are saying is correct! You can use indicators calculated from daily data to filter your universe of stocks that you later want to trade intra-day -- this is exactly what Pipeline does. Your example is correct as well, USEquityPricing is a database of day bars.

  2. I think what you're looking for with the question is schedule_function(). With schedule function, you could schedule one function in the first minute bar of each day, or the last minute bar of each day, or both, or multiple bars. In this case, you can also define handle_data() to be:

def handle_data(context, data):  
    pass  

This will mean that you only actually run your scheduled functions, and handle_data won't do anything. You will still need to run this in minute mode, however.

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.

OPG and MOC orders are not supported. The best you can do is place an order at 9:31am or 3:59pm, which can only be simulated in a minutely backtest. You can backtest using day bars, but the orders, by default, will not be 'executed' until the following close. There is a third-party TradeAtTheOpen slippage model somewhere, which lets you backtest with orders filling at the open, but those aren't strictly implementable in live trading, which as I said, the best you can do is an order you place at 9:31am.