How to use the broker.Order.Action.SELL function in broker

To help you get started, we’ve selected a few broker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
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
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
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
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
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
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
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