Cancel or Update Stop Market Order

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

Update Backtest

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)

# Cancel an Order:

# 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 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


Cheers Michael.


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

Update Backtest


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.


This discussion is closed