huobi_api for python
Project description
火币API的Python版
- websocket封装成HBWebsocket类,用
run开启连接线程 - restful api基本参照火币网的demo封装HBRestAPI
- 没有test和debug,估计含有巨量的BUG,慎用!
Installation
pip install huobitrade
Usage
WebSocket API
from huobitrade.service import HBWebsocket
hb = HBWebsocket() # 可以填入url参数,默认是https://api.huobi.br.com
hb.run() # 开启websocket进程
Restful API
- restapi需要先用
setKey设置密钥 - 默认交易和行情url都是[https://api.huobi.br.com](调试用),实盘要设置url用
from huobitrade import setUrl
from huobitrade.service import HBRestAPI
from huobitrade import setKey
setKey('your acess_key', 'you secret_key')
api = HBRestAPI()
print(api.get_timestamp())
Message Handler
from huobitrade.handler import baseHandler
class MyHandler(baseHandler):
def __init__(self, *args, **kwargs):
baseHandler.__init__(self, name='just Thread name')
def handle(self, msg): # 实现handle来处理websocket推送的msg
print(msg)
handler = MyHandler()
hb.register_handler(handler, 'market.ethbtc.kline.1min') # 通过register来把handler注册到相应的topic
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
huobitrade-0.1.1.tar.gz
(8.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huobitrade-0.1.1.tar.gz.
File metadata
- Download URL: huobitrade-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9ed6f99e400e45cdcd5923f8f951fee708c89fa2291fe43ccf783fb3ce8b14
|
|
| MD5 |
1386d549738b51b9aeea8bfc78d68243
|
|
| BLAKE2b-256 |
bfd25f7bf1f772bfaf03252f53edd8db2696a71180c2027f3e135d00c68ea0a4
|
File details
Details for the file huobitrade-0.1.1-py3-none-any.whl.
File metadata
- Download URL: huobitrade-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32607d9bac6405ec1bc3db9f8eda1dca814334b235714d713074e6e5f005442b
|
|
| MD5 |
2c0b071725d170fc4b696a0514d42690
|
|
| BLAKE2b-256 |
887c14be4f7bc7c1a553b6e156f00521f63932edf1018bb09cabf0d34d93bf29
|