I Am New to Coding and Learning to start small Projects to help me improve and learn-
I wanted to get Different WebSocket feed simultaneously in the same Script- response for both granularity for 300 & 900 at the same time; below is the actual code for a single request
const WebSocket = require('ws');
var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089');
ws.onopen = function(evt) {
ws.send(JSON.stringify(
{ticks_history: "R_25",
subscribe: 1,
adjust_start_time: 1,
count: 1,
end: "latest",
granularity: 300,
start: 1,
style: "candles"}
));
};
ws.onmessage = function(msg) {
var data = JSON.parse(msg.data);
console.log('ticks update: %o', data.tick.quote);
};
Where by I can get different granularity response of same feed at the same time, although I have been able to get this independently but would love to be able to get them all from the same script!
Below is my script
const WebSocket = require('ws');
var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089');
ws.onopen = function(evt) {
ws.send(JSON.stringify(
{ticks_history: "R_25",
subscribe: 1,
adjust_start_time: 1,
count: 1,
end: "latest",
granularity: 900,
start: 1,
style: "candles"},
//here is where i added the additional request for 900 time frame
{ticks_history: "R_25",
subscribe: 1,
adjust_start_time: 1,
count: 1,
end: "latest",
granularity: 300,
start: 1,
style: "candles"}
));
};
ws.onmessage = function(msg) {
var data = JSON.parse(msg.data);
console.log('ticks update: %o', data);
};
from the above script, I only get a data feed from only the second request -900
How do I write this that will allow me to get both data responses same time?