Open flippakitten opened 4 years ago
It is maintained, last activity was 4 days ago and we accept PRs!
FYI, I use Alpaca/Polygon streams with https://rubygems.org/gems/faye-websocket, but it would be great to use an abstraction on top of it.
Lol, not sure how I missed the last activity but thanks for replying. I was looking at a few gems and yours is definetely the cleanest and most extendable, nice work.
I'll be using faye as I use it elsewhere and I'll defintely be creating a PR later this week.
(I can't actually use the streams at the moment as I am not in the US but I am hoping by adding another feature to your GEM, more people from round the world will ask for access)
I've never used Faye before, but I wanted to integrate this into the app I'm building. I've got the handshake and auth working on both Alpaca & Polygon, as well as the subscribing. But no matter what I do, it never sends the market data. It just says I'm subscribed to a ticker and then nothing afterwards. What am I missing?
module AlpacaListen
def self.run
EM.run {
ws = Faye::WebSocket::Client.new('wss://alpaca.socket.polygon.io/stocks')
ws.on :message do |event|
response = JSON.parse(event.data)
res = case response[0]['status']
when 'connected'
ws.send("{\"action\":\"auth\",\"params\":\"PASSWORD\"}")
when 'auth_success'
ws.send("{\"action\":\"subscribe\",\"params\":\"T.MSFT,T.AAPL,T.AMD,T.NVDA\"}")
when 'success'
puts response[0]['message']
else
p response
end
end
ws.on :error do |event|
p [:error, event.data]
end
ws.on :close do |event|
p [:close, event.code, event.reason]
ws = nil
end
}
end
end
Hello,
Just a quick check in to see if this gem is maintained?
If so, I would like to add streaming support and want to check if it's something you woud like. I was thinking along the lines of:
Alpaca::Trade::WebSocket::Client.new
Let me know.