Navbar
简体中文
shell

Introduction

API Introduction

Welcome to use Hoo API! You can use this API get market information, trading and managing your account.

The code will display on the right side of this document. Currently we only provide "shell" code examples.

Welcome all professional maker strategies and organizations for long term market making program.

Public API

Verification free for below portals:

API Introduction Trading area
GET /open/v1/tickers/market All trading pairs Spot
GET /open/v1/depth/market Depth Spot
GET /open/v1/trade/market Each filled orders Spot
GET /open/v1/kline/market Market K line data Spot
GET /open/innovate/v1/tickers/market All trading pairs Innovate
GET /open/innovate/v1/depth/market Depth Innovate
GET /open/innovate/v1/trade/market Each filled orders Innovate
GET /open/innovate/v1/kline/market Market K line data Innovate

Verified API

Eligible to access portals:

API Introduction Trading area
GET /open/v1/tickers All trading pairs Spot
GET /open/v1/balance Balance Spot
GET /open/v1/timestamp Server time stamp Spot
GET /open/v1/kline Market K line data Spot
GET /open/v1/depth Market depth data Spot
GET /open/v1/tickers/trade Get last 5 trade orders Spot
POST /open/v1/orders/place Place new order Spot
POST /open/v1/orders/cancel Cancel order Spot
POST /open/v1/orders/batcancel Cancel all active orders Spot
GET /open/v1/orders/last-maker Active orders Spot
GET /open/v1/orders Order history Spot
GET /open/v1/orders/detail Get order details Spot
GET /open/innovate/v1/tickers All trading pairs Innovate
GET /open/innovate/v1/balance Balance Innovate
GET /open/innovate/v1/timestamp Server time stamp Innovate
GET /open/innovate/v1/kline Market K line data Innovate
GET /open/innovate/v1/depth Market depth data Innovate
GET /open/innovate/v1/tickers/trade Get last 5 trade orders Innovate
POST /open/innovate/v1/orders/place Place new order Innovate
POST /open/innovate/v1/orders/cancel Cancel order Innovate
POST /open/innovate/v1/orders/batcancel Cancel all active orders Innovate
GET /open/innovate/v1/orders/last Active orders Innovate
GET /open/innovate/v1/orders Order history Innovate
GET /open/innovate/v1/orders/detail Get order details Innovate

Connection Guide

Restful Host:

https://api.hoolgd.com

Websocket Host:

Spot wss://api.hoolgd.com/ws

Innovate wss://api.hoolgd.com/wsi

Verification Notice

  1. All portals need to conduct verification. Parameters are "client_id","ts","nonce","sign". "client_id" is the api key. "client_key" is the secret key. Please be careful.
  2. Ts is the current time stamp. Query with more than 5 seconds time difference will be rejected. "nonce" is a random code that should not be the same with last time query.
  3. Signature method: link "client_id","ts","nonce" in correct order, use hmac-sha256 to sign. e.g. the unsigned code: client_id=abc&nonce=xyz&ts=1571293029
  4. Signature: sign = hmac.New(client_key, sign_str, sha256)
  5. Content-Type: application/x-www-form-urlencoded
  6. Post portal,please put parameter inside query
  7. API key has up to 5 white list IP addresses

WebSocket Guide

  1. Need verification before subscription
  2. Verification method: {"op":"apilogin","sign":"","client_id":"","nonce":"","ts": int type}, e.g: {"op":"apilogin","sign":"abc123","client_id":"abc123","nonce":"1","ts": 1576207749}
  3. Client need to timely upload arbitrary code to check. Server will check status every 30 seconds. Links will be closed if no information received. {"op":"sub", "topic":"hb"}

Subscription Topic

{"op":"sub", "topic": ""}

K Line Data

Request parameters

{"op":"sub", "topic": "kline:1Min:EOS-USDT"}
Parameter Description
kline:1Min:EOS-USDT EOS-USDT 1 minute K line

Responds:

{
    "symbol":"EOS-USDT",
    "ticks":[
        {
            "close":"2.62",
            "high":"3.11",
            "low":"2.62",
            "open":"3.01",
            "timestamp":1572851100,
            "volume":"17.55"
        }
    ],
    "timestamp":1572851160917,
    "topic":"kline:1Min:EOS-USDT",
    "type":"60000"
}

Data refresh string list

Field name Data Type Description
symbol string Pair
ticks object K line Data
close string Local close price
high string Local highest price
low string Local lowest price
open string Local open price
timestamp integer Time Stamp ms
volume string Volume

Each filled orders

Request parameters

{"op":"sub", "topic": "trade:LTC-USDT"}
Parameter Description
trade:LTC-USDT LTC-USDT Each filled orders

Responds:

{
    "amount":"7.473",
    "price":"2.82",
    "side":1,
    "symbol":"EOS-USDT",
    "timestamp":1572851197910,
    "topic":"trade:EOS-USDT",
    "volume":"2.65"
}

Data refresh string list

Field name Data Type Description
amount string Volume
price string Price
side integer Direction,1 buy,-1 sell
symbol string Pair
timestamp integer Time Stamp ms
volume string Volume

Depth change

Request parameters

{"op":"sub", "topic": "depth:0:LTC-USDT"}
Parameter Description
depth:0:LTC-USDT Depth

Responds:

{
    "bids": [
        {'price': '2.923', 'quantity': '12'}
    ], 
    "asks": [
        {'price': '3.05', 'quantity': '3.48'}
    ],
    "symbol":"EOS-USDT",
    "timestamp":1572851208935,
    "topic":"depth:0:EOS-USDT"
}

Data refresh string list

Field name Data Type Description
bids object Current all buy orders[{price, quantity}]
asks object Current all sell orders[{price, quantity}]

Market information change

Request parameters

{"op":"sub", "topic": "quotes"}
Parameter Description
quotes Market Information

Responds:

{
    "amount":"52080.1255",
    "change":"0.00949367",
    "price":"3.19",
    "symbol":"EOS-USDT",
    "timestamp":1572851216950,
    "topic":"quotes",
    "volume":"17965.65"
}

Data refresh string list

Field name Data Type Description
amount string Amount
change string Change
price string Current price
symbol string Pair
timestamp integer Time Stamp ms
volume string Volume

Account balance change

Request parameters

{"op":"sub", "topic": "accounts"}
Parameter Description
accounts Account balance change

Responds:

{
    "available":"4194.3466678",
    "freeze":"71.609185",
    "symbol":"USDT",
    "topic":"accounts",
    "total":"4265.9558528"
}

Data refresh string list

Field name Data Type Description
available string Available balance
freeze string Locked balance
symbol string Coin
total string Total balance

Order Change

Request parameters

{"op":"sub", "topic": "orders:BTC-USDT"}
Parameter Description
orders:BTC-USDT Order Change

Responds:

// Place new order
{
    "left":"1",
    "order_id":"11574948935833473",
    "order_type":1,
    "price":"80000",
    "quantity":"1",
    "side":-1,
    "status":2,
    "symbol":"BTC-USDT",
    "timestamp":1574949805841,
    "topic":"orders:BTC-USDT",
    "trade_no":"499081745280826070655",
    "match_qty":"0",
    "match_price":"0"
}

// Cancel order
{
    "left":"0",
    "order_id":"11574948935833473",
    "order_type":1,
    "price":"80000",
    "quantity":"1",
    "side":-1,
    "status":6,
    "symbol":"BTC-USDT",
    "timestamp":1574949805841,
    "topic":"orders:BTC-USDT",
    "trade_no":"499081745280826070655",
    "match_qty":"0",
    "match_price":"0"
}

Response Content

Field name Data Type Description
left string Remaining number
order_id string Order id
order_type int Order Type,1 Limit,3 Market
price string Price
quantity string Amount
side int Direction,1 buy,-1 sell
status int Status 2 Outstanding,3 Partial filled,4 all filled,5 cancel after partial filled,6 all cancel
symbol string Pair
timestamp int Time to fill ms
trade_no string Trade serial number
match_qty string Filled quantity
match_price string Average transaction price

Basic information

All trading pairs

This portal will respond all pairs hoo support

Spot

"https://api.hoolgd.com/open/v1/tickers"

Innovate

"https://api.hoolgd.com/open/innovate/v1/tickers"

HTTP query

Spot - GET /open/v1/tickers

Innovate - GET /open/innovate/v1/tickers

Request parameters

This portal not receive any parameter

Responds:

{  
    'code': 0, 
    'data': [
            {'amount': '1.586',
            'change': '-0.235462',
            'high': '3.05',
            'low': '3.05',
            'price': '0',
            'symbol': 'EOS-USDT',
            'amt_num': 4,
            'qty_num': 2,
            'volume': '0.52'
            }, 
        ]
}

Response Content

Field name Data Type Description
amount string 24h amount
change string 24h change
high string 24h high
low string 24h low
price string Current price
symbol string Pair
amt_num integer Price precision
qty_num integer Amount precision
volume string 24h volume

Account balance

Spot

"https://api.hoolgd.com/open/v1/balance"

Innovate

"https://api.hoolgd.com/open/innovate/v1/balance"

HTTP query

Spot - GET /open/v1/balance

Innovate - GET /open/innovate/v1/balance

Request parameters

None

Responds:

{
    'code': 0, 
    'data': [
        {
            'amount': '4317.6696678', 
            'symbol': "USDT", 
            'freeze': '71.609185'
        },
    ]
}

Response Content

Field name Data Type Description
amount string Available balance
symbol string Coin
freeze string Locked balance

Server time stamp

Spot

"https://api.hoolgd.com/open/v1/timestamp"

Innovate

"https://api.hoolgd.com/open/innovate/v1/timestamp"

HTTP query

Spot - GET /open/v1/timestamp

Innovate - GET /open/innovate/v1/timestamp

Request parameters

This portal not receive any parameter

Responds:

{
    "code": 0,
    "msg": "ok",
    "data": "12354534",
}

Response Content

Field name Data Type Description
data string time stamp

Market Information

Market K line

Spot

"https://api.hoolgd.com/open/v1/kline"

Innovate

"https://api.hoolgd.com/open/innovate/v1/kline"

HTTP query

Spot - GET /open/v1/kline

Innovate - GET /open/innovate/v1/kline

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: BTC-USDT
type string yes Type e.g: 1Min, 5Min, 15Min, 30Min

Responds:

{
    'code': 0, 
    'data': [
        {
            'amount': '0',
            'close': '3.05',    
            'high': '3.05', 
            'low': '3.05', 
            'open': '3.05', 
            'time': 1571812440, 
            'volume': '0'
        }
    ]
}

Response Content

Field name Data Type Description
amount string Volume
close string Local close price
high string Local highest price
low string Local lowest price
open string Local open price
time integer Time
volume string Volume

Market depth

Spot

"https://api.hoolgd.com/open/v1/depth"

Innovate

"https://api.hoolgd.com/open/Innovate/v1/depth"

HTTP query

Spot - GET /open/v1/depth

Innovate - GET /open/innovate/v1/depth

Request parameters

Field name Data Type Required Description
symbol string yes Pair

Responds:

{
    'code': 0, 
    'data': {
        'bids': [
            {'price': '2.923', 'quantity': '12'}, 
            {'price': '2.823', 'quantity': '12'}, 
            {'price': '2.813', 'quantity': '14'}
        ], 
        'asks': [
            {'price': '3.05', 'quantity': '3.48'}, 
            {'price': '3.31', 'quantity': '15'}, 
            {'price': '3.923', 'quantity': '15'}
            ]
        }, 
    'msg': 'ok'
}

Response Content

Field name Data Type Description
bids object Current all buy orders[{price, quantity}]
asks object Current all sell orders[{price, quantity}]

Get last 5 trade orders

Spot

"https://api.hoolgd.com/open/v1/tickers/trade"

Innovate

"https://api.hoolgd.com/open/innovate/v1/tickers/trade"

HTTP query

Spot - GET /open/v1/tickers/trade

Innovate - GET /open/innovate/v1/tickers/trade

Request parameters

Field name Data Type Required Description
symbol string yes Pair

Responds:

{
    'code': 0, 
    'data': [{
        'amount': '0.918',
        'price': '2.04',
        'side': -1,
        'time': 1574942822160,
        'volume': '0.45'
        }]
}

Response Content

Field name Data Type Description
amount string Volume
price string Price
side integer Direction,1 buy,-1 sell
time integer Time
volume string Volume

Market Data

Place new order

Spot

"https://api.hoolgd.com/open/v1/orders/place"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders/place"

HTTP query

Spot - POST /open/v1/orders/place

Innovate - POST /open/innovate/v1/orders/place

Request parameters(form-data parameters)

Field name Data Type Required Description
symbol string yes Pair
price string yes price
quantity string yes quantity
side int yes Direction,1 buy,-1 sell

Responds:

{
    "code": 0,
    "msg": "ok",
    "data": {
        "order_id": "xxx",
        "trade_no": "xxx",
    },
}

Response Content

Field name Data Type Description
order_id string Order placing number
trade_no string Trade serial number

Cancel order

Spot

"https://api.hoolgd.com/open/v1/orders/cancel"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders/cancel"

HTTP query

Spot - POST /open/v1/orders/cancel

Innovate - POST /open/innovate/v1/orders/cancel

Request parameters

Field name Data Type Required Description
symbol string yes Pair
order_id string yes Order placing number
trade_no string yes Trade serial number

Responds:

{
    "code": 0,
    "msg": "ok",
}

Response Content

Field name Data Type Description

This portal not receive any parameter

Cancel all active orders

Spot

"https://api.hoolgd.com/open/v1/orders/batcancel"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders/batcancel"

HTTP query

Spot - POST /open/v1/orders/batcancel

Innovate - POST /open/innovate/v1/orders/batcancel

Request parameters

Field name Data Type Required Description
symbol string yes Pair

Responds:

{
    "code": 0,
    "msg": "ok",
}

Response Content

Field name Data Type Description

This portal not receive any parameter

Active orders

Spot

"https://api.hoolgd.com/open/v1/orders/last-maker"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders/last"

HTTP query

Spot - GET /open/v1/orders/last-maker

Innovate - GET /open/innovate/v1/orders/last

Request parameters

Field name Data Type Required Description
symbol string yes Pair

Responds:

{
    'code': 0, 
    'data': [
        {
            'ticker': 'BTC-USDT',
            'order_id': '11574744030837944',
            'trade_no': '499016576021202015341',
            'price': '7900',
            'quantity': '1',
            'match_amt': '0',
            'match_qty': '0',
            'match_price': '',
            'side': -1,
            'order_type': 1,
            'create_at': 1574744151836
        }, 
    ], 
}

Response Content

Field name Data Type Description
ticker string Pair
order_id string Order ID
trade_no string Trade serial number
price string price
quantity string Amount
match_amt string Filled amount
match_qty string Filled quantity
match_price string Average price
side int Direction,1 buy,-1 sell
order_type int order_type, 1 Limit,3 Market
create_at int Create time

Order history

Spot

"https://api.hoolgd.com/open/v1/orders"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders"

HTTP query

Spot - GET /open/v1/orders

Innovate - GET /open/innovate/v1/orders

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: EOS-USDT
pagenum int no Page
pagesize int no Page size, default 20, min 10, max 50
side int no Direction,1 buy,-1 sell,0 all
start int no Starting time, time stamp
end int no Closing time, time stamp

Responds:

{
    'code': 0, 
    'msg': 'ok',
    'data': {
        'count': 4, 
        'orders': [
            {
                'order_id': '11574744030837944',
                'trade_no': '499016576021202015341',
                'ticker': 'BTC-USDT',
                'price': '7900',
                'quantity': '1',
                'match_amt': '0',
                'match_qty': '0',
                'match_price': '',
                'side': -1,
                'order_type': 1,
                'status': 6,
                'create_at': 1574744151836
            }, 
        ]
    }, 
}

Response Content

Field name Data Type Description
order_id string Order id
trade_no string Trade serial number
ticker string Pair
price string Price
quantity string Quantity
match_amt string Filled amount
match_qty string Filled quantity
match_price string Average price
side int Direction,1 buy,-1 sell
order_type int order_type, 1 Limit,3 Market
status int Status 2 Outstanding,3 Partial filled,4 all filled,5 cancel after partial filled,6 all cancel
create_at int Created Time

Get order details

Spot

"https://api.hoolgd.com/open/v1/orders/detail"

Innovate

"https://api.hoolgd.com/open/innovate/v1/orders/detail"

HTTP query

Spot - GET /open/v1/orders/detail

Innovate - GET /open/innovate/v1/orders/detail

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: EOS-USDT
order_id string yes Order id

Responds:

{
    'code': 0, 
    'data': {
        'order_id': '11574751725833010',
        'trade_no': '499073202290421221116', 
        'ticker': 'BTC-USDT', 
        'price': '70000', 
        'quantity': '0.0001', 
        'match_amt': '7', 
        'match_qty': '0.0001',
        'match_price': '70000',  
        'fee': '0.0112',
        'side': -1, 
        'order_type': 1,
        'status': 4,
        'create_at': 1574922846832,
        'trades': [{
            'amount': '7', 
            'price': '70000', 
            'quantity': '0.0001',
            'fee': '0.0112',  
            'time': 1574922846833
            }]
    }
}

Response Content

Field name Data Type Description
order_id string Order id
trade_no string Trade serial number
ticker string Pair
price string Price
quantity string Amount
match_amt string Filled amount
match_qty string Filled quantity
match_price string Average price
fee string fee
side int Direction,1 buy,-1 sell
order_type int order_type, 1 Limit,3 Market
status int Status 2 Outstanding,3 Partial filled,4 all filled,5 cancel after partial filled,6 all cancel
create_at int Order creation time
trades object Filled order data[{
amount string Amount of every filled order
price string Price of every filled order
quantity string quantity of every filled order
fee string Fee of every filled order
time int Time of every filled order}]

Public API

All trading pairs

Spot

"https://api.hoolgd.com/open/v1/tickers/market"

Innovate

"https://api.hoolgd.com/open/innovate/v1/tickers/market"

HTTP query

Spot - GET /open/v1/tickers/market

Innovate - GET /open/innovate/v1/tickers/market

Request parameters

Field name Data Type Required Description

Responds:

{  
    'code': 0, 
    'data': [
            {'amount': '1.586',
            'change': '-0.235462',
            'high': '3.05',
            'low': '3.05',
            'price': '0',
            'symbol': 'EOS-USDT',
            'amt_num': 4,
            'qty_num': 2,
            'volume': '0.52'
            }, 
        ]
}

Response Content

Field name Data Type Description
amount string 24h volume
change string 24h change
high string 24h high
low string 24h low
price string Current price
symbol string Pair
amt_num integer Price precision
qty_num integer Amount precision
volume string 24h volume

Depth

Spot

"https://api.hoolgd.com/open/v1/depth/market"

Innovate

"https://api.hoolgd.com/open/innovate/v1/depth/market"

HTTP query

Spot - GET /open/v1/depth/market

Innovate - GET /open/innovate/v1/depth/market

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: BTC-USDT

Responds:

{
    'code': 0, 
    'data': {
        'bids': [
            {'price': '2.923', 'quantity': '12'}, 
            {'price': '2.823', 'quantity': '12'}, 
            {'price': '2.813', 'quantity': '14'}
        ], 
        'asks': [
            {'price': '3.05', 'quantity': '3.48'}, 
            {'price': '3.31', 'quantity': '15'}, 
            {'price': '3.923', 'quantity': '15'}
            ]
        }, 
    'msg': 'ok'
}

Response Content

Field name Data Type Description
bids object Current all buy orders[{price, quantity}]
asks object Current all sell orders[{price, quantity}]

Each filled orders

Spot

"https://api.hoolgd.com/open/v1/trade/market"

Innovate

"https://api.hoolgd.com/open/innovate/v1/trade/market"

HTTP query

Spot - GET /open/v1/trade/market

Innovate - GET /open/innovate/v1/trade/market

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: BTC-USDT

Responds:

{
    'code': 0, 
    'data': [{
        'amount': '0.918',
        'price': '2.04',
        'side': -1,
        'time': 1574942822160,
        'volume': '0.45'
        }]
}

Response Content

Field name Data Type Description
amount string Volume
price string Price
side integer Direction,1 buy,-1 sell
time integer Time
volume string Volume

Market K line

Spot

"https://api.hoolgd.com/open/v1/kline/market"

Innovate

"https://api.hoolgd.com/open/innovate/v1/kline/market"

HTTP query

Spot - GET /open/v1/kline/market

Innovate - GET /open/innovate/v1/kline/market

Request parameters

Field name Data Type Required Description
symbol string yes Pair e.g: BTC-USDT
type string yes Type e.g: 1Min, 5Min, 15Min, 30Min

Responds:

{
    'code': 0, 
    'data': [
        {
            'amount': '0',
            'close': '3.05',    
            'high': '3.05', 
            'low': '3.05', 
            'open': '3.05', 
            'time': 1571812440, 
            'volume': '0'
        }
    ]
}

Response Content

Field name Data Type Description
amount string Volume
close string Local close price
high string Local highest price
low string Local lowest price
open string Local open price
time integer Time
volume string Volume

API Example

Python:

# -*- coding:utf-8 -*-

import requests
import time
import hmac
import hashlib
import ujson
import random


host = "https://api.hoolgd.com"
client_id = ""
client_key = ""

def gen_sign(client_id, client_key):
    ts = int(time.time())
    nonce = "abcdefg"
    obj = {"ts": ts, "nonce": nonce, "sign": "", "client_id": client_id}
    s = "client_id=%s&nonce=%s&ts=%s" % (client_id, nonce, ts) 
    v = hmac.new(client_key.encode(), s.encode(), digestmod=hashlib.sha256)
    obj["sign"] = v.hexdigest()
    return obj 

print("> Active orders")
# Spot
path = "/open/v1/orders/last-maker"
# Innovate
# path = "/open/innovate/v1/orders/last"
obj = gen_sign(client_id, client_key)
obj.update({"symbol": "ETH-USDT"})
res = requests.get(host + path, params=obj)
print(ujson.loads(res.content))

print("> Get order details")
# Spot
path = "/open/v1/orders/detail"
# Innovate
# path = "/open/innovate/v1/orders/detail"
obj = gen_sign(client_id, client_key)
obj.update({"order_id": "11574751725833010", "symbol": "BTC-USDT"})
res = requests.get(host + path, params=obj)
print(ujson.loads(res.content))

print("> Market K line")
# Spot
path = "/open/v1/kline"
# Innovate
path = "/open/innovate/v1/kline"
obj = gen_sign(client_id, client_key)
obj.update({"symbol": "EOS-USDT", "type": "1Min"})
res = requests.get(host + path, params=obj)
print(ujson.loads(res.content))

print("> Account balance")
# Spot
path = "/open/v1/balance"
# Innovate
# path = "/open/innovate/v1/balance"
obj = gen_sign(client_id, client_key)
res = requests.get(host + path, params=obj)
print(ujson.loads(res.content))

print("> Get last 5 trade orders")
# Spot
path = "/open/v1/tickers/trade"
# Innovate
# path = "/open/innovate/v1/tickers/trade"
obj = gen_sign(client_id, client_key)
obj.update({"symbol": "EOS-USDT"})
res = requests.get(host + path, params=obj)
print(ujson.loads(res.content))

print("> Place new order")
# Spot
path = "/open/v1/orders/place"
# Innovate
# path = "/open/innovate/v1/orders/place"
obj = gen_sign(client_id, client_key)
obj.update({"symbol": "BTC-USDT", "price": "8850.21", "quantity": "0.1", "side": "1"})
res = requests.post(host + path, data=obj)
print(ujson.loads(res.content))

Websocket Example

Python:

# -*- coding:utf-8 -*-

import time
import hmac
import hashlib
import websockets
import json
import asyncio
import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

# Spot
host = "wss://api.hoolgd.com/ws"
# Innovate
# host = "wss://api.hoolgd.com/wsi"
client_id = ""
client_key = ""


def login():
    ts = int(time.time())
    nonce = "abcdefg"
    obj = {"ts": ts, "nonce": nonce, "sign": "", "client_id": client_id, "op": "apilogin"}
    s = "client_id=%s&nonce=%s&ts=%s" % (client_id, nonce, ts)
    v = hmac.new(client_key.encode(), s.encode(), digestmod=hashlib.sha256)
    obj["sign"] = v.hexdigest()
    return obj

async def sub_topic(ws):
    sub = "depth:0:EOS-USDT"
    await ws.send(json.dumps({"op": "sub", "topic": sub}))


async def startup():
    print("start to connect %s..." % host)
    ws = await websockets.connect(host)

    obj = login()
    await ws.send(json.dumps(obj))
    await sub_topic(ws)

    while 1:
        try:
            data = await ws.recv()
            print(data)
        except websockets.exceptions.ConnectionClosed as e:
            print("connect closed...", e)
            return
        except:
            pass


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(startup())

HooSwap

HooSwapExample