Hi Guys,
Quick question. Let's say I create a market order for a security using SetHoldings() function and immediatelly after that I create a stop market order using StopMarketOrder() function.
1) If I sell the security again using SetHoldings(security, 0). The stop order is instantly cancelled or I have to explicitly implement that?
2) If I rebalance my position and want to update the stop market order should I cancel the previous one or there already an update function?
Many thanks
Michael Manus
second qquestion is easy:
the documentation says:
# Creating an Order:
limitOrderTicket = self.LimitOrder("SPY", 100, 205)
# Updating an Order:
updateOrderFields = UpdateOrderFields()
updateOrderFields.LimitPrice = decimal.Decimal(207.50)
limitOrderTicket.Update(updateOrderFields)
# Cancel an Order:
limitOrderTicket.Cancel()
# Cancel all open orders from SPY
cancelledOrders = self.Transactions.CancelOpenOrders("SPY")
# Cancel order #10
cancelledOrder = self.Transactions.CancelOrder(10)
# Get open orders
openOrders = self.Transactions.GetOpenOrders()
# Get open orders from SPY
openOrders = self.Transactions.GetOpenOrders("SPY")
# Get open order #10
openOrder = self.Transactions.GetOrderById(10)
# Get all orders
orders = self.Transactions.GetOrders()
# Get order ticket #10
orderTicket = self.Transactions.GetOrderTicket(10)
# Get all orders tickets
openOrderTickets = self.Transactions.GetOrderTickets()
1) you would have to implement it i think.......like the example above because maybe you would want to go SHORT at this point?? who nows? only you
i mean its not a bracket order you would have to implement something like a bracket order
Nick Georgiadis
Cheers Michael.
Michael Manus
if you need an idea how it should work thats an c# example
but you could copy the logic if you want and try that in python
T. Todua
what is answer to #1 question?Â
Derek Melchin
Hi T. Todua,
In regards to question #1, the stop order is not automatically canceled if we SetHoldings to 0, but it is if we use the Liquidate method. See the attached backtest and logs for reference.
Best,
Derek Melchin
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.
Nick Georgiadis
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!