async def symbols(): symbols = [] rest = HTTPClient(testnet=True) markets = await rest.get_markets() for market in markets: symbol = f"{market['base_asset_symbol']}_{market['quote_asset_symbol']}" symbols.append(symbol) yield symbols await rest.close()
async def test_ratelimiter(): """ Make 10 `time` requests concurrently and ensure they are not rate-limited """ client = HTTPClient(testnet=True, rate_limit=True) futures = [] for _ in range(10): futures.append(asyncio.ensure_future(client.get_time())) results = await asyncio.gather(*futures) print(results) assert results for result in results: print(result) if 'message' in result: assert result['message'] != 'API rate limit exceeded' assert 'block_time' in result await client.close()
async def chain(): chain = HTTPClient(testnet=True) yield chain await chain.close()
async def client(): client = HTTPClient(testnet=True) yield client await client.close()
async def test_del_without_close_warning(): client = HTTPClient(testnet=True) await client.get_time() with pytest.warns(UserWarning): del (client)
async def http_examples(): client = HTTPClient(testnet=True) server_time = await client.get_time() node_info = await client.get_node_info() validators = await client.get_validators() peers = await client.get_peers() account_info = await client.get_account_info(address) sequence_info = await client.get_account_sequence(address) transaction = await client.get_transaction(hash) token_list = await client.get_token_list() markets = await client.get_markets(limit=500, offset=0) fees = await client.get_fees() depth = await client.get_depth(symbol, limit=100) klines = await client.get_klines(symbol, interval, limit=300, start=None, end=None) closed_orders = await client.get_closed_orders( address, end=None, limit=None, offset=None, side=None, start=None, status=None, symbol=None, total=None, ) open_orders = await client.get_open_orders(self, address, limit=None, offset=None, symbol=None, total=None) order = await client.get_order(id) ticker = await client.get_ticker(symbol) trades = await client.get_trades( address=None, buyerOrderId=None, height=None, limit=None, offset=None, quoteAsset=None, sellerOrderId=None, side=None, start=None, end=None, total=None, symbol=None, ) block_fee = await client.block_exchange_fee(address=None, end=None, limit=None, offset=None, start=None, total=None) transactions = await client.get_transactions( address, height=None, end=None, limit=None, offset=None, side=None, start=None, tx_asset=None, tx_type=None, ) """ POST REQUEST""" broadcast_info = await client.broadcast(data)