Skip to content

pytrading-code/jex-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

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.

Crypto market is very volatile, please use this sdk at your own risk.

%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)

Spot API (The 3 clients have similiar interface, use spot as example below)

General API

Get server time

server_time = await spot_client.get_server_time()
server_time

I 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'])

Market API

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)

Get recent trades

await spot_client.get_recent_trades(symbol = 'btcusdt', limit = 5)

Get recent klines

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')

Spot latest price

await spot_client.get_symbol_ticker(symbol='btcusdt')

Trade API

Spot Create Order

await spot_client.create_order(symbol='btcusdt', side='BUY', type = 'LIMIT', quantity = 0.0001, price = 4000)

Get open orders

await spot_client.get_open_orders(symbol='btcusdt')

Get order status

# The orderId should be the return orderId when you create order
await spot_client.get_order(symbol='btcusdt', orderId=45504774)

Cancel order

await spot_client.cancel_order(symbol='btcusdt', orderId=45504774)

Swap(Futures) && Option

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)

Option and Swap have postion interface, which spot doesn't.

option postion swap positon

await swap_client.get_position()
await option_client.get_position()

About

A python sdk of JEX exchange's official API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages