Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
restrict full backtest to daily data?

I'd like to run the full backtest, but trade daily rather than minutely? Can the backtester be configured so that it runs the full backtest but uses daily rather than minutely data? If not, perhaps someone can provide a code example that will do the same thing effectively (or point me to an algorithm posted in this forum).

10 responses

We do plan on building this as a feature, but it hasn't happened yet. Until then, code is the way. Thanks, as always, for the request. It tells us what to prioritize!

Dan

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.

Yes, that is an error! We've got a bug filed to fix that one, thanks.

Hello Dan,

I'm a bit confused about daily versus minutely bars (data). On your help page, you state "Currently, we have minute bar data for US equities for 2002 to summer 2012." In this post (and I think in another post), Fawce has mentioned that your database actually has both daily and minutely bars. As best I can tell from skimming through the help, there is no way to access the daily bar data, correct? Although perhaps daily bars are used in the quickie backtest/debug routine?

It would be great if the API allows a user to select the data frequency of interest..i.e. (daily, 4h, 15min)
I wrote a wrapper to convert minute bar to 4 hour or 1day... but still it would be so much better if those data are readily available

Grant - In a technical sense, once you have minute bars, you have all of the larger timeslices by definition. You can build minute bars into day bars, day bars into month bars, month bars into year bars, etc. (What you can't do is get smaller - you can't derive second bars from minute bars).

In a more practical sense: we use both minute and daily bars under the covers. We use daily bars when you run the "instant backtest" that you see when you press build in the IDE. We use minute bars when you "run a full backtest." (I thought we'd put all this in our help doc, but evidently we didn't. I'm going to update that shortly).

We absolutely plan on making the daily bars more easily available so you can "run a full backtest with daily bars" but we haven't built it yet.

Jay - Interesting, we'll look at that. There might be an interesting way to make the size of the timeslice configurable.

Do you care to share your wrapper? It sounds very useful!

Dan

I'd encourage Quantopian to think about making it convenient for users to run algorithms on different time scales. For some applications (e.g. quarterly re-optimization of a retirement portfolio), minutely data are overkill. Also, I question how many individuals have the expertise, discipline, and time commitment to trade on a minutely/daily basis and make consistent profits over many years, taking into account all costs. Is there any evidence that algorithmic/quantitative trading by individuals is doable over the long-haul (e.g. academic/industry studies)? If it is feasible, how much capital is required to keep costs down?

Hello Grant,

I agree, we can provide different timeframes. One of the nice things about having fine grained data like minutes is that it can be used at many, many larger granularities.

How many people can do it? There are a lot of people doing it today at home by themselves. I've interviewed a couple dozen now, just through word of mouth. The real question is, how many new people can we bring into the industry? My estimation is many thousands.

Dan

Hi Dan & others,

It'd be helpful to understand how best to backtest a daily strategy using the full Quantopian backtester (which runs a minutely loop). The goal of the backtesting is to emulate a realistic live trading scenario. In practice, on a daily basis, what is the preferred approach? For the algorithm I am working on, I can imagine it being run after the market closes on Day 0 and using the Day 0 closing prices (along with a moving average over multiple days). The order would be submitted (with the market closed), to be fulfilled the next trading day, Day 1. In a real-world scenario, how does the order get fulfilled on Day 1? Would the entire transaction (involving multiple securities) go through in the first minute of trading on Day 1, or would it go through at some random time later in the day? Or would the individual securities get transacted at separate random times throughout the day? What is the likelihood of part or all of the order not getting fulfilled at all during Day 1 (even though all of the securities are highly liquid and the orders are small compared to their respective trading volumes)?

Also, more generally, I'd be interested in comments regarding managing the risk of price-impacting events that occur after the market closes and over the sometimes multiple days between a market closing and its re-opening (e.g. a weekend). For practicing individual quantitative/algorithmic traders, how is this risk managed?

Hi Grant,

Some of these questions I've got a solid answer for and others I don't. I've never been a programmatic trader, but I've interviewed many of them this year.

  • Some people go home from their day jobs, update their Excel sheets,
    and place orders for the next day. Those orders might be market
    orders or they more often limit orders. Those orders are sometimes
    disrupted by events overnight that make them obsolete.
  • Another set of people trade with a daily frequency, but they trade
    just before the close. They check prices at 3:45PM or so, run their
    models, and then execute a blizzard of trades just at the close. I
    think that is the most common method to manage the risk of
    price-impacting events.
  • Some people break their trades up over the course of the day. The
    most common is when it's a huge order, something that would move the
    market.
  • If you are trading a small amount of a highly liquid stock, those
    orders are filled. There is just very little risk of failure. You
    might not get the price you want, but you'll get a price.

Right now our backtester is most "tuned" for minute-bar testing. When we get to making daily-bar testing, we'll be thinking of the best way to make these details available.

I'm also curious in what other traders think about your questions.

Dan