forked from massive-com/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindices.py
More file actions
34 lines (26 loc) · 1.08 KB
/
indices.py
File metadata and controls
34 lines (26 loc) · 1.08 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
from polygon import WebSocketClient
from polygon.websocket.models import WebSocketMessage, Market
from typing import List
client = WebSocketClient(market=Market.Indices)
# Aggregates (per minute)
# client.subscribe("AM.*") # all aggregates
client.subscribe("AM.I:SPX") # Standard & Poor's 500
client.subscribe("AM.I:DJI") # Dow Jones Industrial Average
client.subscribe("AM.I:NDX") # Nasdaq-100
client.subscribe("AM.I:VIX") # Volatility Index
# Aggregates (per second)
# client.subscribe("A.*") # all aggregates
# client.subscribe("A.I:SPX") # Standard & Poor's 500
# client.subscribe("A.I:DJI") # Dow Jones Industrial Average
# client.subscribe("A.I:NDX") # Nasdaq-100
# client.subscribe("A.I:VIX") # Volatility Index
# Single index
# client.subscribe("V.*") # all tickers
# client.subscribe("V.I:SPX") # Standard & Poor's 500
# client.subscribe("V.I:DJI") # Dow Jones Industrial Average
# client.subscribe("V.I:NDX") # Nasdaq-100
# client.subscribe("V.I:VIX") # Volatility Index
def handle_msg(msgs: List[WebSocketMessage]):
for m in msgs:
print(m)
client.run(handle_msg)