Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

broker-trade-client-2.1.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

broker_trade_client-2.1.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file broker-trade-client-2.1.1.tar.gz.

File metadata

  • Download URL: broker-trade-client-2.1.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for broker-trade-client-2.1.1.tar.gz
Algorithm Hash digest
SHA256 b01841ee76b7569a102a7df587274b9c27deeb51f19b744f870c87a7ebf29915
MD5 7c5490a7c125ae409cccd3e24ea61bcc
BLAKE2b-256 4ab7b17639216129404d29cc1aa6fd1c47c4add133969cac0770eb71a8fcfd03

See more details on using hashes here.

File details

Details for the file broker_trade_client-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: broker_trade_client-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for broker_trade_client-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c2f35edac8e33b81de9a1e9af1ace17fa14a03e411a9a9e19a6a608b92c0818
MD5 410816ef7ca84dc9e0854d5902e00c58
BLAKE2b-256 3fc833a7761b4a7ef9c9c82e7155fceb9ba0168e65eb000d8a3ef6d1e3d6e0ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page