DheerajAgarwal / rgdax

Wrapper for Coinbase pro (erstwhile GDAX) Cryptocurrency exchange
Other
33 stars 16 forks source link

Websocket? #8

Open Guceri opened 5 years ago

Guceri commented 5 years ago

Actually was able to get this to work. Just run the first section (up until ws$connect) and then run the WS$send seperately. To stop, type ws$close()

rm(list-ls())

library(websocket) library(jsonlite)

================================================

ETHUSD TRADE DATA

================================================

ws <- WebSocket$new("wss://ws-feed.pro.coinbase.com",autoConnect = FALSE)

ws$onOpen(function(event){ cat("Connection opened...\n") })

ws$onMessage(function(event){ print(fromJSON(event$data)) })

ws$onClose(function(event){ cat("Client disconnected...\n") })

ws$onError(function(event){ cat("Client failed to connect: ", event$message, "\n") })

ws$connect()

ws$send( '{ "type": "subscribe", "product_ids": [ "ETH-USD", "ETH-EUR" ], "channels": [ "level2", "heartbeat", { "name": "ticker", "product_ids": [ "ETH-BTC", "ETH-GBP" ] } ] }' )

DheerajAgarwal commented 5 years ago

Thanks. Getting around this after a while. Let me check this out and if need be, I can work on a detailed enhancement.