forked from massive-com/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto.py
More file actions
43 lines (33 loc) · 1.07 KB
/
Copy pathcrypto.py
File metadata and controls
43 lines (33 loc) · 1.07 KB
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
36
37
38
39
40
41
42
43
from polygon import WebSocketClient
from polygon.websocket.models import WebSocketMessage, Market
from typing import List
client = WebSocketClient(market=Market.Crypto)
# Aggregates (per minute)
client.subscribe("XA.*") # all crypto pair
# client.subscribe("XA.BTC-USD")
# client.subscribe("XA.BTC-EUR")
# client.subscribe("XA.ETH-USD")
# Aggregates (per second)
# client.subscribe("XAS.*") # all crypto pair
# client.subscribe("XAS.BTC-USD")
# client.subscribe("XAS.BTC-EUR")
# client.subscribe("XAS.ETH-USD")
# Trades
# client.subscribe("XT.*") # all crypto pair
# client.subscribe("XT.BTC-USD")
# client.subscribe("XT.BTC-EUR")
# client.subscribe("XT.ETH-USD")
# Quotes
# client.subscribe("XQ.*") # all crypto pair
# client.subscribe("XQ.BTC-USD")
# client.subscribe("XQ.BTC-EUR")
# client.subscribe("XQ.ETH-USD")
# Level 2 Book
# client.subscribe("XL2.*") # all crypto pair
# client.subscribe("XL2.BTC-USD")
# client.subscribe("XL2.BTC-EUR")
# client.subscribe("XL2.ETH-USD")
def handle_msg(msgs: List[WebSocketMessage]):
for m in msgs:
print(m)
client.run(handle_msg)