Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def buildExitOrder(self, limitPrice, stopPrice):
if limitPrice == None and stopPrice == None:
ret = self.getStrategy().getBroker().createMarketOrder(broker.Order.Action.SELL, self.getInstrument(), self.getQuantity(), False)
elif limitPrice != None and stopPrice == None:
ret = self.getStrategy().getBroker().createLimitOrder(broker.Order.Action.SELL, self.getInstrument(), limitPrice, self.getQuantity())
elif limitPrice == None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, self.getQuantity())
elif limitPrice != None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopLimitOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, limitPrice, self.getQuantity())
else:
assert(False)
return ret
def buildExitOrder(self, limitPrice, stopPrice):
if limitPrice == None and stopPrice == None:
ret = self.getStrategy().getBroker().createMarketOrder(broker.Order.Action.SELL, self.getInstrument(), self.getQuantity(), False)
elif limitPrice != None and stopPrice == None:
ret = self.getStrategy().getBroker().createLimitOrder(broker.Order.Action.SELL, self.getInstrument(), limitPrice, self.getQuantity())
elif limitPrice == None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, self.getQuantity())
elif limitPrice != None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopLimitOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, limitPrice, self.getQuantity())
else:
assert(False)
return ret
def buildExitOnSessionCloseOrder(self):
ret = self.getStrategy().getBroker().createMarketOrder(broker.Order.Action.SELL, self.getInstrument(), self.getQuantity(), True)
ret.setGoodTillCanceled(True) # Mark the exit order as GTC since we want to exit ASAP and avoid this order to get canceled.
return ret
def buildExitOrder(self, limitPrice, stopPrice):
if limitPrice == None and stopPrice == None:
ret = self.getStrategy().getBroker().createMarketOrder(broker.Order.Action.SELL, self.getInstrument(), self.getQuantity(), False)
elif limitPrice != None and stopPrice == None:
ret = self.getStrategy().getBroker().createLimitOrder(broker.Order.Action.SELL, self.getInstrument(), limitPrice, self.getQuantity())
elif limitPrice == None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, self.getQuantity())
elif limitPrice != None and stopPrice != None:
ret = self.getStrategy().getBroker().createStopLimitOrder(broker.Order.Action.SELL, self.getInstrument(), stopPrice, limitPrice, self.getQuantity())
else:
assert(False)
return ret