alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
143 stars 13 forks source link

authentication failed when using polygon webSocket #68

Closed herbertchow214 closed 5 years ago

herbertchow214 commented 5 years ago

Using REST with my key id worked, curl https://api.polygon.io/v1/last_quote/stocks/AAPL?key_id=XXX worked {"status":"success","symbol":"AAPL","last":{"askprice":189.22,"asksize":1,"askexchange":19,"bidprice":189.21,"bidsize":2,"bidexchange":19,"timestamp":1557862846384}}

however using webSocket end authentication msg {"action":"auth","params":"XXX"} to wss://socket.polygon.io/stocks, I received authentication error {"ev":"status","status":"error","message":"authentication failed"}]

ttt733 commented 5 years ago

For Polygon streaming, at the moment you will need to use NATS, as Alpaca keys are not authenticated properly on their websocket cluster. The NATS cluster is unfortunately undocumented, but you can see examples of how to connect in our SDKs - for example, here: https://github.com/alpacahq/alpaca-trade-api-python/blob/master/alpaca_trade_api/polygon/stream.py

bdowling commented 5 years ago

For anyone finding this old issue through a search, the websocket interface for Polygon is now supported, and you can use one of our many SDKs to access it.

Note that if you are attempting to access it directly, the URI for our customers using Alpaca KEY_ID is wss://alpaca.socket.polygon.io/stocks

jeffwlandry commented 4 years ago

Using c# api library. I am using wss://alpaca.socket.polygon.io/stocks from environment. Worked fine earlier this week. This afternoon I get the authentication failed message. polygonStream = alpacaEnvironment.GetPolygonStreamingClient(accountID); polygonStream.OnError += polygonSocketError; polygonStream.SocketOpened += polygonSocketOpened; polygonStream.SocketClosed += polygonSocketClosed; polygonStream.Connected += polygonSocketConnected; AuthStatus auth = await polygonStream.ConnectAndAuthenticateAsync(cancellationTokenStreamSocketError); all the other sockets open.

Any suggestions appreciated.

Jeff