jex-python-sdk is a python async client of Binance Jex exchange, it provides a REST client according to jex api doc based on aiohttp.
%load_ext autoreload
%autoreload 2
from client import spotClient, swapClient, optionClient, utils
# fill your api_key and api_secret
api_key = ""
api_secret = ""
spot_client = await spotClient.create(api_key=api_key, api_secret=api_secret)
swap_client = await swapClient.create(api_key=api_key, api_secret=api_secret)
option_client = await optionClient.create(api_key=api_key, api_secret=api_secret)server_time = await spot_client.get_server_time()
server_timeI provide some time transformation method in utils, you can change timestamp to a readable time or datetime.
utils.timestamp_to_strtime(server_time['serverTime'])utils.timestamp_to_datetime(server_time['serverTime'])Get the current trading rules and symbol information
[Get spot orderbook](https://jexapi.github.io/api-doc/spot.html#depth-information-for-spot
await spot_client.get_order_book(symbol = 'btcusdt', limit = 5)await spot_client.get_recent_trades(symbol = 'btcusdt', limit = 5)await spot_client.get_recent_klines('btcusdt', '1m', limit = 5)Get historical klines
await spot_client.get_historical_klines('btcusdt', '5m', startTime = '2020-03-23 22:00:00', endTime = '2020-03-23 22:30:00')24 hour rolling window price change statistics. Careful when accessing this with no symbol.
await spot_client.get_ticker(symbol='btcusdt')await spot_client.get_symbol_ticker(symbol='btcusdt')await spot_client.create_order(symbol='btcusdt', side='BUY', type = 'LIMIT', quantity = 0.0001, price = 4000)await spot_client.get_open_orders(symbol='btcusdt')# The orderId should be the return orderId when you create order
await spot_client.get_order(symbol='btcusdt', orderId=45504774)await spot_client.cancel_order(symbol='btcusdt', orderId=45504774)Most of their interfaces are the same with spot, I just show how to get order books here.
await swap_client.get_order_book(symbol = 'BTCUSDT', limit = 5)await option_client.get_order_book(symbol = 'BTC0422CALL', limit = 5)await swap_client.get_position()await option_client.get_position()