Python SDK for Broker REST And Websocket API
Project description
Welcome to Broker-Python
An official Python implementation of the lastest Open API for Broker.
Install
pip install broker-trade-client
or download from github
Note: pip install may be fail. We are working on fix this. if so, just download from github
Usage
REST API
Init broker client:
b = BrokerClient(entry_point='', api_key='', secret='')
Init broker options client:
b = BrokerOptionClient(entry_point='', api_key='', secret='')
Init broker contract client:
b = BrokerContractClient(entry_point='', api_key='', secret='')
Request with proxies:
proxies = {
"http": "http://ip:port",
"https": "http://ip:port",
}
b = BrokerClient(entry_point='', api_key='', secret='', proxies=proxies)
Web Socket
Init
Init broker websocket client:
client = BrokerWss(entry_point='', rest_entry_point='', api_key='', secret='')
Subscribe
Subscribe trades:
client.subscribe_to_trades(symbol='BTCUSDT', callback=handler)
Subscribe Kline/Candlestick:
client.subscribe_to_kline(symbol='BTCUSDT', interval='5m', callback=handler)
Subscribe market tickers:
client.subscribe_to_realtimes(symbol='BTCUSDT,ETHUSDT', callback=handler)
Subscribe book depth tickers:
client.subscribe_to_depth(symbol='BTCUSDT', callback=handler)
Subscribe user data:
client.user_data_stream(callback=handler)
Start
Start websocket thread
client.start()
API List
Public API
ping
b.ping()
time
b.time()
broker info
b.broker_info()
depth
b.depth('BTCUSDT')
trades
b.trades('BTCUSDT')
klines
b.klines('BTCUSDT')
ticker 24hr
b.ticker_24hr('BTCUSDT')
Private API
new order
b.order_new(symbol='BTCUSDT', side='BUY', type='LIMIT', quantity='0.01', price='1000', timeInForce='GTC')
get order
b.order_get(order_id='')
cancel order
b.order_cancel(order_id='')
open orders
b.open_orders()
history orders
b.history_orders()
account
b.account()
my trades
b.my_trades()
deposit orders
b.deposit_orders()
Examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for broker-trade-client-2.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37fc4dfabe11ea2332ef7eec238e32e9cb97ef27c1c66000b08a2191cae8256c |
|
MD5 | 6b206fb870d063874b3c7ead6eff7979 |
|
BLAKE2b-256 | 572789b7944f5359946b4506a4b4de7b51c9e198d58912c91f0269ef1f651c11 |
Close
Hashes for broker_trade_client-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40f3740fc2fbe11053c3920645ceae5fde370b1d69e930289ce48f20e99ecad2 |
|
MD5 | 28b8429ad3d2ae6b476712039d0a124a |
|
BLAKE2b-256 | 4e093bdc5e2fa3781df48202784ae5e1bd386dbcab9c77c7f2ce1d0fee069e6f |