import requests
import json
import time
import pandas as pd
import pytz
from datetime import datetime
from polygon import WebSocketClient, STOCKS_CLUSTER
# retrieve alpaca keys
%run alpaca_keys.py
def my_custom_process_message(message):
print("this is my custom message processing", message)
my_client = WebSocketClient(STOCKS_CLUSTER, KEY_ID, my_custom_process_message)
my_client.run_async()
Close connection after 5 seconds
my_client.subscribe("T.MSFT", "T.AAPL")
time.sleep(5)
my_client.close_connection()