File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ from polygon import WebSocketClient
2+ from polygon .websocket .models import WebSocketMessage , Market
3+ from typing import List
4+
5+ client = WebSocketClient (market = Market .Indices )
6+
7+ # aggregates (per minute)
8+ # client.subscribe("AM.*") # all aggregates
9+ client .subscribe ("AM.I:SPX" ) # Standard & Poor's 500
10+ client .subscribe ("AM.I:DJI" ) # Dow Jones Industrial Average
11+ client .subscribe ("AM.I:NDX" ) # Nasdaq-100
12+ client .subscribe ("AM.I:VIX" ) # Volatility Index
13+
14+ # single index
15+ # client.subscribe("V.*") # all tickers
16+ # client.subscribe("V.I:SPX") # Standard & Poor's 500
17+ # client.subscribe("V.I:DJI") # Dow Jones Industrial Average
18+ # client.subscribe("V.I:NDX") # Nasdaq-100
19+ # client.subscribe("V.I:VIX") # Volatility Index
20+
21+
22+ def handle_msg (msgs : List [WebSocketMessage ]):
23+ for m in msgs :
24+ print (m )
25+
26+
27+ client .run (handle_msg )
You can’t perform that action at this time.
0 commit comments