forked from GoChartingAdmin/client-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygon.py
More file actions
32 lines (18 loc) · 686 Bytes
/
polygon.py
File metadata and controls
32 lines (18 loc) · 686 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
# Be sure to pip install polygon-api-client
import time
from polygon import WebSocketClient, STOCKS_CLUSTER
def my_custom_process_message(message):
print("this is my custom message processing", message)
def my_custom_error_handler(ws, error):
print("this is my custom error handler", error)
def my_custom_close_handler(ws):
print("this is my custom close handler")
def main():
key = 'your api key'
my_client = WebSocketClient(STOCKS_CLUSTER, key, my_custom_process_message)
my_client.run_async()
my_client.subscribe("T.MSFT", "T.AAPL", "T.AMD", "T.NVDA")
time.sleep(1)
my_client.close_connection()
if __name__ == "__main__":
main()