def createSimpleLimitOrder(self): order = LimitOrder() orderLeg = OrderLeg() orderLeg.instrumentType = TradeMonsterConstants.INSTRUMENTS.EQUITY orderLeg.symbol = 'SPY' orderLeg.orderSide = OrderLeg.side.BUY order.price = 0.01 order.quantity = 1 order.orderLegs = [orderLeg] order.instrumentType = TradeMonsterConstants.INSTRUMENTS.EQUITY order.timeInForce = LimitOrder.timeInForceEnum.DAY order.marketSession = LimitOrder.marketSessionEnum.REG return order
def testSpreadOrder(self): ''' Test a simple buy spread (debit) :return: ''' self.orderService.sendCancelAllOrders(self.accounts[ACCOUNT_NUMBER].accountNumber) #cancel everything first just in case order = LimitOrder() shortLeg = OrderLeg() longLeg = OrderLeg() shortLeg.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION shortLeg.symbol = 'SPYX1517C300000' shortLeg.orderSide = OrderLeg.side.SELL shortLeg.quantityRatio = 1 longLeg.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION longLeg.symbol = 'SPYX1517C310000' longLeg.orderSide = OrderLeg.side.BUY longLeg.quantityRatio = 1 order.price = 0.01 order.quantity = 1 order.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION order.timeInForce = LimitOrder.timeInForceEnum.DAY order.marketSession = LimitOrder.marketSessionEnum.REG order.orderLegs = [] order.orderLegs.append(shortLeg) order.orderLegs.append(longLeg) order.spreadName = TradeMonsterConstants.OrderRequests.ORDER_SPREAD_TYPES.PUT_VERTICAL #send a live order with a silly price result = self.orderService.sendOrderAndGetParsedResponse(self.accounts[ACCOUNT_NUMBER], order) status = result.status print 'Status of order is {0}'.format(status) self.assertTrue(status in OrderStatus.status.__dict__.keys())
def testSpreadOrder(self): ''' Test a simple buy spread (debit) :return: ''' self.orderService.sendCancelAllOrders( self.accounts[ACCOUNT_NUMBER].accountNumber ) #cancel everything first just in case order = LimitOrder() shortLeg = OrderLeg() longLeg = OrderLeg() shortLeg.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION shortLeg.symbol = 'SPYX1517C300000' shortLeg.orderSide = OrderLeg.side.SELL shortLeg.quantityRatio = 1 longLeg.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION longLeg.symbol = 'SPYX1517C310000' longLeg.orderSide = OrderLeg.side.BUY longLeg.quantityRatio = 1 order.price = 0.01 order.quantity = 1 order.instrumentType = TradeMonsterConstants.INSTRUMENTS.OPTION order.timeInForce = LimitOrder.timeInForceEnum.DAY order.marketSession = LimitOrder.marketSessionEnum.REG order.orderLegs = [] order.orderLegs.append(shortLeg) order.orderLegs.append(longLeg) order.spreadName = TradeMonsterConstants.OrderRequests.ORDER_SPREAD_TYPES.PUT_VERTICAL #send a live order with a silly price result = self.orderService.sendOrderAndGetParsedResponse( self.accounts[ACCOUNT_NUMBER], order) status = result.status print 'Status of order is {0}'.format(status) self.assertTrue(status in OrderStatus.status.__dict__.keys())