Your First Forex and Crypto WebSocket with R

library(websocket)
ws <- WebSocket$new("wss://marketdata.tradermade.com/feedadv")
ws$onOpen(function(event){ ws$send("{"userKey":"userKey", "symbol":"GBPUSD,EURUSD"}") }
ws$onMessage(function(event) { cat( " Symbol ", d, " ") }
library(websocket) { ws <- WebSocket$new("wss://marketdata.tradermade.com/feedadv") ws$onMessage(function(event) { d <- event$data cat(" Message ", d, " ") }) ws$onOpen(function(event) { ws$send("{"userKey":"userKey", "symbol":"GBPUSD,EURUSD"}") }) }
Message Connected Message {"symbol":"EURUSD","ts":"1651070094743","bid":1.05339,"ask":1.05341,"mid":1.0534} Message {"symbol":"EURGBP","ts":"1651070094760","bid":0.84075,"ask":0.84079,"mid":0.84077} Message {"symbol":"GBPUSD","ts":"1651070094765","bid":1.25288,"ask":1.25292,"mid":1.2529} Message {"symbol":"EURUSD","ts":"1651070094768","bid":1.0534,"ask":1.05341,"mid":1.053405} Message {"symbol":"EURUSD","ts":"1651070094771","bid":1.0534,"ask":1.05342,"mid":1.05341} Message {"symbol":"GBPUSD","ts":"1651070094814","bid":1.25289,"ask":1.25292,"mid":1.252905} Message {"symbol":"GBPUSD","ts":"1651070094815","bid":1.25289,"ask":1.25293,"mid":1.25291} Message {"symbol":"EURGBP","ts":"1651070094971","bid":0.84076,"ask":0.84078,"mid":0.84077}
library(jsonlite)
d <- event$data if (d != "Connected"){ }
json = fromJSON(d) cat(" Symbol ", json$symbol, json$ts, json$bid, json$ask, json$mid)
library(websocket) library(jsonlite) { ws <- WebSocket$new("wss://marketdata.tradermade.com/feedadv") ws$onMessage(function(event) { d <- event$data if (d != "Connected"){ json = fromJSON(d) cat(" Symbol ", json$symbol, json$ts, json$bid, json$ask, json$mid) } }) ws$onOpen(function(event) { ws$send("{"userKey":"userKey", "symbol":"GBPUSD,EURUSD"}") }) }

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store