def test_put_MOR_multi_order(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='5')) orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='2')) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 2) for o in resp: self.assertTrue(o.success) orders = n.getOpenOrders() self.assertEqual(len(orders), 2) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_cancel_orders_in_event(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374',side='B', limitPrice='.5',quantity='5') ) orders.append( Order(conId='331374',side='B', limitPrice='.5',quantity='2') ) orders.append( Order(conId='331374',side='S', limitPrice='99',quantity='1') ) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 3) for o in resp: self.assertTrue(o.success) resp = n.cancelOrdersInEvent('30848') time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_cancel_orders_in_event(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='5')) orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='2')) orders.append( Order(conId='331374', side='S', limitPrice='99', quantity='1')) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 3) for o in resp: self.assertTrue(o.success) resp = n.cancelOrdersInEvent('30848') time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_get_open_orders_oids(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='5')) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 1) for o in resp: self.assertTrue(o.success) time.sleep(1) os = n.getOrdersByOrderId([ resp[0].orderId, ]) self.assertEqual(len(os), 1) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_get_open_orders(self): n = Intrade(self.memNum, self.pw) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_put_MOR_single_order(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374',side='B', limitPrice='.5',quantity='5') ) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 1) for o in resp: self.assertTrue(o.success) orders = n.getOpenOrders() self.assertEqual(len(orders), 1) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_put_MOR_invalid_contract(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='33l1374',side='B', limitPrice='.5',quantity='5') ) orders.append( Order(conId='3313074',side='B', limitPrice='.5',quantity='2') ) with self.assertRaises(IntradeResponseError): resp = n.multiOrderRequest(orders, True) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_put_MOR_invalid_contract(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='33l1374', side='B', limitPrice='.5', quantity='5')) orders.append( Order(conId='3313074', side='B', limitPrice='.5', quantity='2')) with self.assertRaises(IntradeResponseError): resp = n.multiOrderRequest(orders, True) r = n.cancelAllOrders() self.assertTrue(r.didCancel) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_cancel_AllInContract(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374',side='B', limitPrice='.5',quantity='5') ) orders.append( Order(conId='331374',side='B', limitPrice='.5',quantity='2') ) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 2) for o in resp: self.assertTrue(o.success) resp = n.cancelAllOrdersInContract('331374') time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)
def test_cancel_ByOrderId(self): n = Intrade(self.memNum, self.pw) orders = [] orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='5')) orders.append( Order(conId='331374', side='B', limitPrice='.5', quantity='2')) resp = n.multiOrderRequest(orders, True) self.assertEqual(len(resp), 2) for o in resp: self.assertTrue(o.success) oids = [o.orderId for o in resp] resp = n.cancelOrdersById(oids) time.sleep(1) orders = n.getOpenOrders() self.assertEqual(len(orders), 0)