How to use the broker.Order.Action.BUY 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 __init__(self, strategy, instrument, limitPrice, stopPrice, quantity, goodTillCanceled):
		if limitPrice == None and stopPrice == None:
			entryOrder = strategy.getBroker().createMarketOrder(broker.Order.Action.BUY, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.BUY, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.BUY, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.BUY, 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.BUY, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.BUY, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.BUY, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.BUY, 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.BUY, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.BUY, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.BUY, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.BUY, 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.BUY, instrument, quantity, False)
		elif limitPrice != None and stopPrice == None:
			entryOrder = strategy.getBroker().createLimitOrder(broker.Order.Action.BUY, instrument, limitPrice, quantity)
		elif limitPrice == None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopOrder(broker.Order.Action.BUY, instrument, stopPrice, quantity)
		elif limitPrice != None and stopPrice != None:
			entryOrder = strategy.getBroker().createStopLimitOrder(broker.Order.Action.BUY, instrument, stopPrice, limitPrice, quantity)
		else:
			assert(False)

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