🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

bhex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bhex

Python SDK for Broker REST And Websocket API

2.0.14
PyPI
Maintainers
1

Welcome to Broker-Python

An official Python implementation of the lastest Open API for Broker.

Install

pip install bhex

or 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

  • examples.py
  • option-examples.py
  • contract-examples.py
  • ws-examples.py

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts