This is Huobi Python SDK v3, you can import to your project and use this SDK to query all market data, trading and manage your account. The SDK supports RESTful API invoking, and subscribing the market, account and order update from the WebSocket connection.
If you already use SDK v1 or v2, it is strongly suggested migrate to v3 as we refactor the implementation to make it simpler and easy to maintain. The SDK v3 is completely consistent with the API documentation of the new HTX open platform. Compared to SDK versions v1 and v2, due to changes in parameters of many interfaces, in order to match the latest interface parameter situation, v3 version has made adjustments to parameters of more than 80 interfaces to ensure that requests can be correctly initiated and accurate response data can be obtained. Meanwhile, the v3 version has added over 130 new interfaces available for use, greatly expanding the number of available interfaces. We will stop the maintenance of v2 in the near future.
Realtime Orderbook、kline、market trade details are subscribed by websocket for strategies callback.Huobi Swap,Huobi Future and Huobi Option have been integrated.
APIs of Huobi Swap, Huobi Future and Huobi Option have been integrated such as trade api、batch trade api、cancel api,etc.
Assets are subscribed by websocket for strategies callback.Huobi Swap, Huobi Future and Huobi Option have been integrated.
Positions are subscribed by websocket for strategies callback.Huobi Swap, Huobi Future and Huobi Option have been integrated.
Orders are subscribed by websocket for strategies callback.Huobi Swap, Huobi Future and Huobi Option have been integrated.
Logs can log to files corresponding to different levels such as "DEBUG","INFO","WARN", "ERROR".
Common trade interface and cancel interface,etc.
websocket automatic reconnection mechanism, heartbeat mechanism,etc.
DingDing message Alarm,etc.
Support asynchronous interface of Mongodb database.
...
python:python 3.5.3 above
- git clone https://github.com/hbdmapi/huobi_contract_Python.git
- cd huobi_contract_Python
- cd examples
- cd huobi_swap
- edit "config.json"
-
"access_key": "api access_key"
-
"secret_key": "api secret_key"
-
you may also have to change the host and wss address.
-
save and quit.
-
- bash run.sh
- Happy Trading
Demo strategy only implements a simple sell short and close short strategy.
NOTE: The demo strategy needs to be modified to run in production。
ProjectName
|----- docs
| |----- README.md
|----- scripts
| |----- run.sh
|----- config.json
|----- main.py
|----- strategy
| |----- strategy1.py
| |----- strategy2.py
| |----- ...
|----- .gitignore
|----- README.md
Strategy config file config.json:
- ACCOUNTS
list
your huobi account name; - strategy
string
your strategy name; - symbol
string
the trade code,such as BTC-USD - MARKETS
list
the market config.
Config Tutorials: config tutorials
python main.py config.json
Pls post your suggestions and bugs in issues
Ingyu Koh(Former IBM scientist, Professor at Korea Advanced Institute of Science and Technology, Ph.D in theoretical physics): "I am very impressed how smartly you organized codes. I really appreciate for your precise answers to develop successful system. Once your precise guidance clears obstacle, real progresses are made."