I AM GETING PRICE WITHOUT DECIMAL i.e. 302930 in place of 3029.30 please help
mycode is
<!DOCTYPE HTML>
console.log("WebSocket is supported by your Browser!"); // Let us open a web socket var ws = new WebSocket("wss://websocket.kite.trade/?api_key=abc&user_id=ZZ1234&public_token=xyz"); ws.binaryType = 'arraybuffer'; ws.onopen = function() { // Web Socket is connected, send data using send() message = {"a": "mode", "v": ["ltp", [53243655]]}; //USING FIREFOX ws.send(JSON.stringify(message)); console.log(message); }; ws.onmessage = function (evt) { var received_msg = evt.data; var buffer1 = received_msg; var buffer2 = buffer1.slice(4,12); var dataview = new DataView(buffer2); var ints = new Int32Array(buffer2.byteLength / 4); for (var i = 0; i < ints.length; i++) { ints[i] = dataview.getInt32(i * 4); document.write(ints[i]); } } ws.onclose = function() { // websocket is closed. console.log("Connection is closed..."); };
All prices are in paise. For currencies, the int32 price values should be divided by 10000 to obtain four decimal plaes. For everything else, the price values should be divided by 100.
i.e. 302930 in place of 3029.30
please help
mycode is
<!DOCTYPE HTML>
console.log("WebSocket is supported by your Browser!");
// Let us open a web socket
var ws = new WebSocket("wss://websocket.kite.trade/?api_key=abc&user_id=ZZ1234&public_token=xyz");
ws.binaryType = 'arraybuffer';
ws.onopen = function()
{
// Web Socket is connected, send data using send()
message = {"a": "mode", "v": ["ltp", [53243655]]};
//USING FIREFOX
ws.send(JSON.stringify(message));
console.log(message);
};
ws.onmessage = function (evt)
{
var received_msg = evt.data;
var buffer1 = received_msg;
var buffer2 = buffer1.slice(4,12);
var dataview = new DataView(buffer2);
var ints = new Int32Array(buffer2.byteLength / 4);
for (var i = 0; i < ints.length; i++) {
ints[i] = dataview.getInt32(i * 4);
document.write(ints[i]);
}
}
ws.onclose = function()
{
// websocket is closed.
console.log("Connection is closed...");
};