-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_ws_contract.py
More file actions
35 lines (24 loc) · 887 Bytes
/
example_ws_contract.py
File metadata and controls
35 lines (24 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
from bitget.consts import CONTRACT_WS_URL
from bitget.ws.bitget_ws_client import BitgetWsClient, SubscribeReq
def handle(message):
print("handle:" + message)
def handel_error(message):
print("handle_error:" + message)
def handel_btcusd(message):
print("handel_btcusd:" + message)
if __name__ == '__main__':
api_key = ""
secret_key = ""
passphrase = ""
symbol = 'btcusd'
client = BitgetWsClient(CONTRACT_WS_URL, need_login=True) \
.api_key(api_key) \
.api_secret_key(secret_key) \
.passphrase(passphrase) \
.error_listener(handel_error) \
.build()
channles = [SubscribeReq("mc", "ticker", "BTCUSD"), SubscribeReq("SP", "candle1W", "BTCUSDT")]
client.subscribe(channles,handle)
channles = [SubscribeReq("mc", "ticker", "ETHUSD")]
client.subscribe(channles, handel_btcusd)