Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket? #8

Open
Guceri opened this issue Mar 8, 2019 · 2 comments
Open

Websocket? #8

Guceri opened this issue Mar 8, 2019 · 2 comments

Comments

@Guceri
Copy link

Guceri commented Mar 8, 2019

No description provided.

@Guceri
Copy link
Author

Guceri commented Mar 8, 2019

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants