Hi, I want to place some limit orders during after hour in live session, but looks like there is no option in the holding tab to set order properties for trading outside regular trading hours. Is this something QC supports? In case I want to manually liquidate some of my holdings during after hours, this would be a useful feature, especially that IB doesn’t support simultaneous log in so I cannot log in IB from TWS to do that. Thanks!
Mia Alissi
To place limit orders during after-hours using QuantConnect with Interactive Brokers, you can utilize the
InteractiveBrokersOrderProperties
to allow orders to fill outside regular trading hours. Here's how you can set it up:Initialize Algorithm: Set up your algorithm with the desired start and end dates, and initialize your cash balance.
Add Security with Extended Hours: Use the
add_equity
method to add the desired security, ensuring you set theextended_market_hours
parameter toTrue
.Define Order Properties: Create an instance of
InteractiveBrokersOrderProperties
and set theoutside_regular_trading_hours
property toTrue
.Place Limit Order: In your
on_data
method, check if the current time is outside regular trading hours and use thelimit_order
method to place your order, passing the order properties defined earlier.Handle Order Events: Implement the
on_order_event
method to handle any order updates and log them for review.Schedule Liquidation: If you need to manually liquidate holdings during after-hours, use the
schedule
method to set specific times for liquidation orders.Here's a sample implementation:
This code sets up an algorithm that trades SPY during after-hours by placing limit orders and scheduling liquidation after market hours. Make sure your brokerage supports these features and test thoroughly in a backtest environment before deploying live.
Sources: Order Properties - QuantConnect.com, Stop Limit Orders - QuantConnect.com, Limit Orders - QuantConnect.com, Interactive Brokers - QuantConnect.com, Future Stop Market Order On Extended Hours Regression Algorithm
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Louis Szeto
Hi WinJ
In your live trading panel, when you click on security, you will find a button to create a manual order outside of the algorithm.
If the security is not there, you can add the security at the bottom of the panel.
Best
Louis
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
WinJ Chen
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!