Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)