Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Confused - no orders carried over?

Hi,

I've just been reading the get_order command and found this statement:

All orders are good-til-cancelled, except for algorithms that are connected to a brokerage. Orders placed with a brokerage (both paper trading and real-money trading) are cancelled at end-of-day. In the future we will most likely change backtest order behavior to also cancel on end-of-day, to make the backtester more accurate.

Now I'm confused! Does this mean any outstanding orders that haven't been filled? Or does this mean an outstanding order will be cancelled at the end of day meaning no daily/weekly/monthly trading can occur?

Could some enlighten me please?

Thanks,
Andrew

5 responses

This one of the few differences between the backtest and live trading. In backtesting, orders persist day-after-day until they are filled or cancelled. In live trading, all orders are cancelled at the end of the day at 4PM. For more details on this, take a look at: https://www.quantopian.com/posts/why-cancel-orders-at-end-of-day

daily/weekly/monthly trading is still possible depending on how your code is written. For example if you have order_target(), the algorithm will seek to that position the next day, since it didn't reach its target.

We'd like to bridge this difference between backtesting and live trading. In the meantime, take a look at these helper functions, and particularly the one used to close orders at the end of the day in simulation.

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.

Thanks.

Ok, so does that mean that I pay commissions on orders made ever day?

I don't understand how order_target() can help during day trading. If I set an order amount on day 1, the position will be closed at the EOD only to be reopenned the next day and the whole process repeats.

Have you an example of a complete day trading example as this will help me greatly?

Thanks again,
Andrew

Commissions are paid when the order is filled, so if you trade every day then you will pay IB commissions daily. Here is an example of a live trading strategy, and we are running a version of this on our IB account: https://www.quantopian.com/posts/rebalance-algo-9-sector-etfs

And a description of the strategy is available here: https://www.quantopian.com/industries-portfolio

To clarify, your positions are not closed out - the securities you have in your portfolio will remain untouched at the end of day.

The only thing that is cancelled at 4PM are any open orders, ones that have not yet been filled by IB.

Ah! I thought that's what a said earlier. Oh well, that changes everything! Thanks for the clarification and I've some difficult decisions to make now!

Cheers,
Andrew