async def run_test():

            market = 'okex'

            lib = BitsgapClient(public_key, private_key)

            result = lib.orders_open(market)

            logging.debug(result)

            self.assertIn('status', result)
            self.assertTrue(result['status'] == 'ok')
            self.assertIn('time', result)

            if 'message' in result:
                self.assertTrue(result['message'] == 'Data not found') # no open orders
            else:
                self.assertIn('data', result)
                data = result['data']
                self.assertTrue(len(data) > 0)
                # check fields
                self.assertIn('id', data[0])
                self.assertIn('price', data[0])
                self.assertIn('amount', data[0])
                self.assertIn('pair', data[0])
                self.assertIn('amount_init', data[0])
                self.assertIn('state', data[0])
                self.assertIn('type', data[0])
                self.assertIn('side', data[0])
                self.assertIn('uts', data[0])

            await asyncio.sleep(1)
示例#2
0
        async def run_test():

            market = 'okex'

            lib = BitsgapClient(public_key, private_key)

            # get open orders
            result = lib.orders_open(market)

            logging.debug(result)

            self.assertIsNotNone(result)

            self.assertTrue(result['status'] == 'ok')
            self.assertIn('data', result)

            data = result['data']

            self.assertIsNotNone(data)
            self.assertTrue(len(data) > 0)
            self.assertIn('id', data[0])

            id = data[0]['id']
            self.assertIsNotNone(id)

            old_price = data[0]['price']
            self.assertIsNotNone(old_price)
            new_price = float(old_price) * 0.999

            result_move = lib.orders_move(market, id, str(new_price))

            logging.debug(result_move)

            self.assertIn('status', result_move)
            self.assertTrue(result_move['status'] == 'ok')
            self.assertIn('data', result_move)
            self.assertIn('time', result_move)

            data = result_move['data']

            self.assertIsNotNone(data)

            self.assertIn('id', data)
            self.assertIn('price', data)
            self.assertIn('amount_init', data)
            self.assertIn('pair', data)
            self.assertIn('state', data)
            self.assertIn('type', data)
            self.assertIn('side', data)
            self.assertIn('uts', data)
            self.assertIn('amount', data)

            await asyncio.sleep(1)
示例#3
0
        async def run_test():

            market = 'okex'

            lib = BitsgapClient(public_key, private_key)

            # get open orders
            result = lib.orders_open(market)

            logging.debug(result)

            self.assertIsNotNone(result)

            self.assertTrue(result['status'] == 'ok')
            self.assertIn('data', result)

            data = result['data']

            self.assertIsNotNone(data)
            self.assertTrue(len(data) > 0)
            self.assertIn('id', data[0])

            id = data[0]['id']

            self.assertIsNotNone(id)

            result_cancel = lib.orders_cancel(market, id)

            logging.debug(result_cancel)

            self.assertIn('status', result_cancel)
            self.assertTrue(result_cancel['status'] == 'ok')
            self.assertIn('data', result_cancel)
            self.assertIn('time', result_cancel)

            data = result_cancel['data']

            self.assertIsNotNone(data)

            self.assertIn('id', data)
            self.assertIn('price', data)
            self.assertIn('amount_init', data)
            self.assertIn('pair', data)
            self.assertIn('state', data)
            self.assertIn('type', data)
            self.assertIn('side', data)
            self.assertIn('uts', data)
            self.assertIn('amount', data)

            await asyncio.sleep(1)
        async def run_test():

            market = 'invalid_market'

            lib = BitsgapClient(public_key, private_key)

            result = lib.orders_open(market)

            logging.debug(result)

            self.assertIn('status', result)
            self.assertTrue(result['status'] == 'error')
            self.assertIn('message', result)
            self.assertIn('time', result)

            await asyncio.sleep(1)