How to use the broker.Order.Action.SELL_SHORT 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 hongbin0908 / pytrade / main / common / plotter.py View on Github external
def onOrderUpdated(self, broker_, order):
		if self.__plotBuySell and order.isFilled() and order.getInstrument() == self.__instrument:
			action = order.getAction()
			execInfo = order.getExecutionInfo()
			if action in [broker.Order.Action.BUY, broker.Order.Action.BUY_TO_COVER]:
				self.getSeries("Buy", BuyMarker).addValue(execInfo.getDateTime(), execInfo.getPrice())
			elif action in [broker.Order.Action.SELL, broker.Order.Action.SELL_SHORT]:
				self.getSeries("Sell", SellMarker).addValue(execInfo.getDateTime(), execInfo.getPrice())
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
def __init__(self, strategy, instrument, limitPrice, stopPrice, quantity, goodTillCanceled):
		if limitPrice == None and stopPrice == None:
			entryOrder = strategy.getBroker().createMarketOrder(broker.Order.Action.SELL_SHORT, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.SELL_SHORT, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, limitPrice, quantity)
		else:
			assert(False)

		Position.__init__(self, strategy, entryOrder, goodTillCanceled)
		strategy.getBroker().placeOrder(entryOrder)
github Yam-cn / pyalgotrade-cn / pyalgotrade / plotter.py View on Github external
def onOrderEvent(self, broker_, orderEvent):
        order = orderEvent.getOrder()
        if self.__plotBuySell and orderEvent.getEventType() in (broker.OrderEvent.Type.PARTIALLY_FILLED, broker.OrderEvent.Type.FILLED) and order.getInstrument() == self.__instrument:
            action = order.getAction()
            execInfo = orderEvent.getEventInfo()
            if action in [broker.Order.Action.BUY, broker.Order.Action.BUY_TO_COVER]:
                self.getSeries("Buy", BuyMarker).addValue(execInfo.getDateTime(), execInfo.getPrice())
            elif action in [broker.Order.Action.SELL, broker.Order.Action.SELL_SHORT]:
                self.getSeries("Sell", SellMarker).addValue(execInfo.getDateTime(), execInfo.getPrice())
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
def __init__(self, strategy, instrument, limitPrice, stopPrice, quantity, goodTillCanceled):
		if limitPrice == None and stopPrice == None:
			entryOrder = strategy.getBroker().createMarketOrder(broker.Order.Action.SELL_SHORT, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.SELL_SHORT, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, limitPrice, quantity)
		else:
			assert(False)

		Position.__init__(self, strategy, entryOrder, goodTillCanceled)
		strategy.getBroker().placeOrder(entryOrder)
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
def __init__(self, strategy, instrument, limitPrice, stopPrice, quantity, goodTillCanceled):
		if limitPrice == None and stopPrice == None:
			entryOrder = strategy.getBroker().createMarketOrder(broker.Order.Action.SELL_SHORT, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.SELL_SHORT, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, limitPrice, quantity)
		else:
			assert(False)

		Position.__init__(self, strategy, entryOrder, goodTillCanceled)
		strategy.getBroker().placeOrder(entryOrder)
github gbeced / pyalgotrade / pyalgotrade / strategy.py View on Github external
def __init__(self, strategy, instrument, limitPrice, stopPrice, quantity, goodTillCanceled):
		if limitPrice == None and stopPrice == None:
			entryOrder = strategy.getBroker().createMarketOrder(broker.Order.Action.SELL_SHORT, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.SELL_SHORT, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.SELL_SHORT, instrument, stopPrice, limitPrice, quantity)
		else:
			assert(False)

		Position.__init__(self, strategy, entryOrder, goodTillCanceled)
		strategy.getBroker().placeOrder(entryOrder)