C# SKD
Funded Live account
Hello, I have been trying to get Live multiple ticker price updates but run into problems. At first I was using GetLastTradeAsync but this limits me to only 1 ticker symbol per api call. I recently tried using GetBarSetAsync which I can get multiple tickers but seems the data is inaccurate, looks like data is stale for minutes and doesn’t update frequent enough. I found that with polygon’s websocket we can stream for multiple ticker symbols. I used the MeanReversionBrokerage example to connect to polygon websocket. It connects, authenticates fine but it never receives any price data and then just closes connection.
Example Code
restClient = new RestClient(API_KEY, API_SECRET, API_URL, apiVersion: 2);
// Connect to Polygon’s websocket and listen for price updates.
polygonSockClient = new PolygonSockClient(API_KEY);
polygonSockClient.ConnectAndAuthenticateAsync().Wait();
Console.WriteLine(“Polygon client opened.”);
polygonSockClient.SecondAggReceived += async (agg) =>
{
Console.WriteLine(agg.Close);
// Decide whether to buy or sell and submit orders.
await HandleSecondAgg(agg);
};
polygonSockClient.SubscribeSecondAgg(symbol);.`