Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
testing on dailies doesn't make sense

The main point is that you obviously won't be able to sell at the daily closing prices (as well as to buy at the daily open prices). Hence, strategies should be tested in a minute mode and most of the end of a day buys should occur around 3:59pm EST when testing daily strategies

20 responses

Agreed, it definitely could be more convenient to make market-on-close and market-on-open orders.

Hi Alex,

Great point, thanks for bringing it up. We've been talking a lot about adding new simulation modes that could facilitate end of day trading. For example, one which only streams the last 10 minutes of each day to your algorithm.

I also wanted to share some quick background: zipline, the opensource backtester powering quantopian, has a modular implementation for modeling how orders are filled. We refer to the calculation of how much and at what price an order is filled as slippage. We provide two slippage models now, and we expect to add more over time. You can read about in our help documentation: https://www.quantopian.com/help#ide-slippage, and if you're really game, you can add new slippage models to the zipline project: https://github.com/quantopian/zipline The slippage models all live here: https://github.com/quantopian/zipline/blob/master/zipline/finance/slippage.py

The current behavior for both models is to fill orders placed in bar B starting with the closing price of bar B+1. So, if you place an order while handling the daily bar of 1/3/2002, the model will begin filling your order based on the closing price of 1/4/2002. The models differ in how they then calculate the amount of stock that is filled, and the change in the price from the market to your filled order.

thanks,
fawce

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.

Hi John, what I actually missing is the ability to get the bars for different periods (other than 1 day and 1 min) - some popular time frames like 1 hr, 15 mins, 5 mins, 3 mins will be good to have for day trading strategies.

But what will be a real killer feature if you would be able to provide access to let's say to all today's 5 min bars when running a daily strategy...

Another cool feature is to provide referencing of historical bars through an array, e.g. bars[0] - current bar, bars[1] - previous period bar, bar[2] - bar before previous, etc.

Also, some popular CME futures (such as ES, CL, NQ, GC) and FX (at least euro, yen, cable, aussie) would be really good to have as well. Especially, FX - by adding just it you will be able to increase your community substantially as algo FX trading becomes really popular and liquidity is much higher there.

Adding ability to test with leverage would be also good to have.

Hope that helps.

WBR,
Alex

Hello Alex,

Some of the functionality of interest to you should already be available (with a bit of custom coding). Since the datetime stamps are available for each market event, analyses, trading decisions, and orders can be restricted in time with an if-then statement (e.g. if five minutes have passed, then do something). I recall seeing an algorithm posted to Quantopian that had a 15-minute frequency, for example. Also, Quantopian has the pandas module, which can be used for "slicing & dicing" a trailing window of data (I'm slowly making my way through Python for Data Analysis by Wes McKinney, and it seems well-suited).

Regarding referencing bar data as an array, the feature is already available, via numpy. I've attached a backtest as an example. Note that on the second day of the backtest, it starts updating a trailing window of data every minute, with the window stored in a type 'numpy.ndarray' object.

Regarding FX trading, I've seen it requested many times on this forum...why is it so popular? Perhaps you could point me to some papers/articles?

Grant

Thanks, Grant. I will take a look

FX is mostly popular because you do not need USD 25k to start day trading and leverage is very generous over there, you can start with 1k and this is why it attracts most

Ah...thanks...perhaps Fawce can comment on the barriers to entry for quantitative trading by individuals of the securities presently available in the Quantopian database? Last I heard, it would take at least $10K in capital and potentially $300/month-$500/month in fees. --Grant

Hello,

Fawce - Perhaps it is a proprietary detail you are unwilling to share, but why do you not have FX data? Does your data vendor not carry it? Too expensive? Data not in a format compatible with Quantopian? Not on your roadmap for an initial launch of live trading? Regulatory issues? Etc.

Alex - What online broker(s) do folks typically use for FX?

Thanks,

Grant

FX data is freely available and should not carry any copyrights on it (e.g. histdata.com)
I would also like to have futures as well - those are very popular for intraday trading

As for brokers - there are tons of them, the majority of stock brokers also support FX (such as IB, AmeriTrade,etc.) but in addition there are tons of FX brokers like FXCM, Currenex, etc.

Grant, you can't trade US stocks intraday if you have less than 25k (by SEC regulations).

Also, there are at least several types of quantitative trading one can do - starting from algo trading and finishing with HFT and ultra HFT trading

I aggregated the minute bars into quasi-equal-volume bars in https://www.quantopian.com/posts/silly-very-slow-system-to-try-out-some-stuff but it didn't work terribly well. Using pandas is a better idea.

Thanks Alex,

Interesting info. regarding FX. I don't work in the trading field and have no experience...just an interesting hobby at this point. I'll see if I can find some articles about the Forex market.

So, if I understand correctly, in Europe (presumably), Forex trading is much more accessible to individuals than in the U.S.?

Any idea why the SEC has set such a high limit for intraday trading?

Grant

I can't help but think that Quantopian aiming at stocks is the wrong way to go -- ignoring any of the requirements, I've heard several prop traders say there is just no point intraday trading on stocks with less than 100k because there is not enough return.

FX (at least in Europe) has very low entry requirements and means people can trade on Quantopian with more realistic amounts like 5k (or even less). eToro has a minimum upload amount of $50, for instance.

I'm worried that Quantopian's pricing model will reflect the capital requirements of people who can reasonable trade stocks. And that counts me out!

Thanks James,

Interesting. I suppose that's a good thing, since it suggests that stocks are relatively fairly priced and that the markets are efficient in eliminating "free lunches." In the end, one would hope that stock prices are pegged to the corresponding underlying business fundamentals, right? Of course, in light of the recent dot.com/telecom bubble and the mortgage/credit crises, one has to wonder...

Quantopian has well-publicized that they intend to offer live trading. It would be informative to get a feel for the anticipated barriers-to-entry for the "99%." I'm definitely in the $0-$50 camp at this point.

Grant

Any idea why the SEC has set such a high limit for intraday trading?

To reduce the number of "I put my retirement savings into the stockmarket and they vanished like smoke, why weren't there more regulations??" letters to the editor.

You can make money in day trading, but it is fairly seriously contested territory. A team at an investment bank in this space might be four or five folk working on a system for six months, re-calibrating their model on two years of per-tick market data every night (cause it takes all night), system set up to deliver sub-millisecond order to market...

James,

Regarding the $100K you reference above, presumably it is initial working capital, right? Then on top of that, some amount of leverage (borrowing) would be applied, as well, right? In order to do intra-day trading of stocks, assuming that you have $100K cash sitting around, how much would you need to borrow on top of that to have a realistic trading "business" as an individual?

Grant

Hi Grant, for intraday trading you can usually get leverage 1:4 on accounts up to 100k. After 100k some brokers have portfolio accounts which can potentially provide higher leverages (up to 1:10 or even higher), but they imply that once you open up portfolio account - you should know what you're doing when using bigger leverages (and proper risk control/money management becomes a must).

For novice traders trading stocks intraday is not generally the best option - I would better advice to start with swing trading (you do not need 25k for that, but max margins are only 1:2) first.

Intraday trading is far more rewarding with futures as commissions are much smaller proportionally (as well as almost guaranteed nil slippage for most of the time), you can start with 5-10k capital for 1 contract trading, number of tick-to-tick Level 1/2 simulators are available for free (e.g. NinjaTrader's one) - hence, it's a perfect practicing ground for intraday trader.

BTW, HFT trading is a totally different story - I know couple of guys who are currently working on sub-micro signal-to-market solution for HFT, hence, on 5-minute and 15-minute timeframes, which are mostly used by intraday traders, HFTs are generally out of competition.

Alex

See Alex's response who answered better than I would have ;)

I think it would be useful to understand what the most realistic strategy is depending on the amount of money you have. Obviously this has an effect on the design of the algorithm. If I have 5k in my account, with only a few manual trades logged against my account, then I have very different design goals compared with even a 25k account.

I'm guessing its something like

5k -- hold from Monday to Friday, leverage?
25k -- hold overnights, leverage 1:2
50k+ -- intraday, leverage 1:4
etc

Thanks Alex & James...very interesting...more questions to follow. --Grant

Returning to the original post, why exactly doesn't trading on dailies make sense?

Hello ISystems,

Quantopian only offers live trading running on minute bars. So, I think the point of the original post was that certain types of backtests run on daily bars may be misleading. Probably the most dramatic difference is that order filling is delayed by 1 trading day for daily bars (unless you use a work-around, such as the custom slippage code, https://www.quantopian.com/posts/trade-at-the-open-slippage-model).

Grant