No market data from polygon web socket
See original GitHub issueI switched to using the PolygonSockClient
(since the NATS client was deprecated), but no market events are being fired. See sample code below:
using Alpaca.Markets;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AlpacaApiTests
{
class Program
{
static void Main(string[] args)
{
AlpacaClient client = new AlpacaClient();
client.Start().Wait();
Console.WriteLine("done");
}
}
public class AlpacaClient
{
private readonly PolygonSockClient marketDataClient;
private readonly ManualResetEventSlim awaiter;
public AlpacaClient()
{
this.marketDataClient = new PolygonSockClient(
keyId: "<ALPACA_API_KEY_ID>",
isStagingEnvironment: false);
this.awaiter = new ManualResetEventSlim();
}
public async Task Start()
{
var auth = await this.marketDataClient.ConnectAndAuthenticateAsync();
Console.WriteLine(auth);
this.marketDataClient.OnError += MarketDataClient_OnError;
this.marketDataClient.QuoteReceived += MarketDataClient_QuoteReceived;
this.marketDataClient.SubscribeQuote("AAPL");
this.marketDataClient.SecondAggReceived += MarketDataClient_SecondAggReceived;
this.marketDataClient.SubscribeSecondAgg("AAPL");
awaiter.Wait();
}
private void MarketDataClient_OnError(Exception obj)
{
Console.WriteLine(obj);
}
private void MarketDataClient_SecondAggReceived(IStreamAgg obj)
{
Console.WriteLine($"{obj.EndTime}: {obj.Symbol}");
}
private void MarketDataClient_QuoteReceived(IStreamQuote obj)
{
Console.WriteLine($"{obj.Time}: {obj.Symbol}");
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
Issues | Knowledge Base
WebSocket disconnects can occur for a variety of reasons. Usually, a disconnect means the market data isn't being consumed fast enough.
Read more >Not receiving all messages from polygon websocket when ...
I'm using polygon's websocket with my Alpaca API key, from chatting with polygon the best way to get this data is to subscribe...
Read more >Streaming Real-Time Stock Market Data with Polygon.io + ...
... Polygon.io with Python for accessing stock market data, we'll explore how to stream real-time stock market data through a websocket.
Read more >Streaming Real-Time Stock Market Data with Polygon.io + Go
... using Polygon.io with Go for accessing stock market data, we'll explore how to stream real-time stock market data through a websocket.
Read more >Streaming Real-Time Stock Market Data with Polygon.io + ...
... Polygon.io with JavaScript for accessing stock market data, we'll explore how to stream real-time stock market data through a websocket.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m unable to change this behavior in the current SDK version because it would be a breaking change. But I’ll open a separate issue for the next major release. In this case, I’ll have time for investigation of possible procs and cons of this change.
@biyimaks Could you please close this issue if the problem is solved now.