Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
quantopian always execute order at the next bar's close price?

e.g.

def handle_data(context, data):
if ... some calculation ...
order_target(symbol('AAPL'), 10)
print data[symbol('AAPL')] # e.g. last buy signal: 'close': 113.275126, 'dt': Timestamp('2015-10-21 00:00:00+0000', tz='UTC')

and in analyze

print buys.transactions[buys.index[-1]] # e.g. 'price': 115.03770800000068, 'dt': Timestamp('2015-10-22 00:00:00+0000', tz='UTC')

I noticed, the order is executed at the next bar's close price.

I wonder if there is a way to tell quantopian execute order at
-- current.close_price, or
-- next.open_price?

Is this possible? or any doc?

Thx.

2 responses

As far as I know, that's not possible.

In backtesting, an order is always submitted at the close of one bar and filled at the close price of the next bar, per the slippage model. The community shared a hack to get a fill at the open price of the next bar, take a look: https://www.quantopian.com/posts/trade-at-the-open-slippage-model

In live trading, an order is triggered and immediately sent to IB. They fill it within seconds depending on liquidity. The filled order is displayed in the next minute, when the data in your live trading dashboard is refreshed.

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.