fyers-web-sdk-v3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ export const Config = {
2
+ "API":"https://api.fyers.in/api/v2",
3
+ "SYNC_API":"https://api-t1.fyers.in/api/v3",
4
+ "data_Api": "https://api.fyers.in/data-rest/v2",
5
+ "data_Api1": "https://api-t1.fyers.in/data",
6
+ "HSM_SOCKET": "wss://socket.fyers.in/hsm/v1-5/prod",
7
+ "Order_SOCKET": "wss://socket.fyers.in/trade/v3",
8
+ "get_profile" : "/profile",
9
+ "tradebook" : "/tradebook",
10
+ "positions" : "/positions",
11
+ "holdings" : "/holdings",
12
+ "convertPosition" : "/positions",
13
+ "funds" : "/funds",
14
+ "gtt":"/gtt",
15
+ "orders" : "/orders",
16
+ "orders_sync" : "/orders/sync",
17
+ "orderStatus" : "/order-status",
18
+ "marketStatus" : "/marketStatus",
19
+ "auth" : "/generate-authcode",
20
+ "generateAccessToken" : "/validate-authcode",
21
+ "exitPositions" : "/positions",
22
+ "multi_orders" : "/multi-order/sync",
23
+ "history" : "/history",
24
+ "quotes" : "/quotes",
25
+ "market_depth" : "/depth"
26
+ }
@@ -0,0 +1,37 @@
1
+ export class ErrorHandler {
2
+ #genricErrorStructure = {s: 'error', code: 500, message: 'Genric Error'}
3
+
4
+
5
+ constructor(errorObject) {
6
+ this.errorObject = errorObject
7
+ }
8
+
9
+ getError() {
10
+ if (this.errorObject && this.errorObject.response && this.errorObject.response.data) {
11
+ return this.errorObject.response.data;
12
+ } else if (this.errorObject && (this.errorObject.code === 'ENOTFOUND')) {
13
+ return this.setError(this.errorObject.errno, this.errorObject.code)
14
+ }else if(this.errorObject.code){
15
+ return this.setError(null, this.errorObject.code)
16
+ } else if(this.errorObject){
17
+ return this.setError(null, this.errorObject)
18
+ } {
19
+ return this.#genricErrorStructure
20
+ }
21
+ }
22
+
23
+
24
+ setError(code, message) {
25
+ if(code){
26
+ this.#genricErrorStructure.code = code
27
+ }
28
+ if(message){
29
+ this.#genricErrorStructure.message = message
30
+ }
31
+
32
+ return this.#genricErrorStructure
33
+ }
34
+
35
+ }
36
+
37
+ // module.exports = ErrorHandler;
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ import { FyersApi } from "./apiService/apiService.js"
4
+ import {FyersOrderSocket} from "./ordersocket/fyersSocket.js"
5
+ import {DataSocket} from"./HSM/datasocket.min.js"
6
+
7
+ export {FyersApi as fyersModel, DataSocket as fyersDataSocket, FyersOrderSocket as fyersOrderSocket}
package/logger/log.js ADDED
@@ -0,0 +1,62 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ class Logger {
5
+ constructor(logDirectory = process.cwd(),logflag=true) {
6
+ const currentDate = new Date().toISOString().slice(0, 10);
7
+ this.logFileName = `${currentDate}.log`;
8
+ this.logFilePath = path.join(logDirectory, this.logFileName);
9
+ this.logflag=logflag
10
+ }
11
+
12
+ log(level, message, data, functionName) {
13
+ if (!this.logflag){
14
+ return
15
+ }
16
+ const logEntry = {
17
+ level,
18
+ datetime: new Date().toISOString(),
19
+ message,
20
+ data,
21
+ functionName,
22
+ };
23
+
24
+ const logString = JSON.stringify(logEntry) + '\n';
25
+
26
+ fs.appendFile(this.logFilePath, logString, (err) => {
27
+ if (err) {
28
+ console.error('Failed to write to log file:', err);
29
+ }
30
+ });
31
+ }
32
+
33
+ debug(message, data, functionName) {
34
+ this.log('debug', message, data, functionName);
35
+ }
36
+
37
+ info(message, data, functionName) {
38
+ this.log('info', message, data, functionName);
39
+ }
40
+
41
+ warn(message, data, functionName) {
42
+ this.log('warn', message, data, functionName);
43
+ }
44
+
45
+ error(message, data, functionName) {
46
+ this.log('error', message, data, functionName);
47
+ }
48
+ }
49
+
50
+ // Usage example
51
+ // const logger = new Logger(undefined); // Log file will be created in the current working directory with the name "YYYY-MM-DD.log"
52
+ // logger.debug('Debug message', { example: 'data' }, 'myFunction');
53
+ // logger.info('Info message', null, 'myFunction');
54
+ // logger.warn('Warning message', { example: 'data' }, 'myFunction');
55
+ // logger.error('Error message', { example: 'data' }, 'myFunction');
56
+
57
+ // const customLogDirectory = '/home/nihar/fyers_project/node SDK/logger';
58
+ // const customLogger = new Logger(customLogDirectory);
59
+ // customLogger.debug('Custom debug message', null, 'myFunction');
60
+ // customLogger.info('Custom info message', { example: 'data' }, 'myFunction');
61
+
62
+ module.exports = Logger
package/obfuscate.js ADDED
@@ -0,0 +1,25 @@
1
+ const fs = require('fs');
2
+ const JavaScriptObfuscator = require('javascript-obfuscator');
3
+
4
+ const inputFilePath = './HSM/datasocket.js';
5
+ const outputFilePath = './HSM/datasocket.min.js';
6
+
7
+ const inputFileContent = fs.readFileSync(inputFilePath, 'utf8');
8
+
9
+ const obfuscationResult = JavaScriptObfuscator.obfuscate(inputFileContent, {
10
+ compact: true,
11
+ controlFlowFlattening: true,
12
+ controlFlowFlatteningThreshold: 1,
13
+ numbersToExpressions: true,
14
+ simplify: true,
15
+ shuffleStringArray: true,
16
+ splitStrings: true,
17
+ splitStringsChunkLength: 10,
18
+ stringArray: true,
19
+ stringArrayThreshold: 1,
20
+ transformObjectKeys: true,
21
+ });
22
+
23
+ fs.writeFileSync(outputFilePath, obfuscationResult.getObfuscatedCode(), 'utf8');
24
+
25
+ console.log('Obfuscation completed.');
@@ -0,0 +1,325 @@
1
+ import {Config} from "../config/config.js";
2
+ import {mapper} from "./mapper.js"
3
+ var reconnectiontries = 0
4
+ const ordstatobj={11: 4, 12: 4, 20: 4, 21: 4, 22: 6, 23: 6, 24: 6, 25: 6, 26: 6, 90: 2,
5
+ 91: 1, 92: 5, 93: 5, 94: 5, 51: 6, 52: 6, 53: 6, 54: 6, 55: 6, 61: 6, 62: 6, 63: 6,
6
+ 64: 6, 71: 6, 72: 6, 73: 1}
7
+ function datamapper(a,b){
8
+ const result = {};
9
+
10
+ for (const key of Object.keys(b)) {
11
+ if (a.hasOwnProperty(key)) {
12
+ result[b[key]] = a[key];
13
+ }
14
+ }
15
+
16
+ return result;
17
+ }
18
+ /**
19
+ * Class to access order update websocket.
20
+ * @class
21
+ */
22
+ class FyersOrderSocket {
23
+
24
+ constructor(authorizationKey, logpath = undefined ,loggingFlag=true) {
25
+ this.url = Config.Order_SOCKET;
26
+ this.authorizationKey = authorizationKey;
27
+ this.ws = null;
28
+ this.onErrorCallback = null;
29
+ this.onCloseCallback = null;
30
+ this.onMessageCallback = null;
31
+ this.onOpenCallback = null;
32
+ this.orderscallback = null;
33
+ this.LogPath = logpath;
34
+ // this.Logger = new Logger(this.LogPath,loggingFlag);
35
+ this.positionscallback = null;
36
+ this.tradescallback = null;
37
+ this.isPingEnabled = true;
38
+ this.pingInterval = null;
39
+ this.autoreconnectinterval = null;
40
+ this.orderUpdates = "orders"
41
+ this.tradeUpdates = "trades"
42
+ this.positionUpdates = "positions"
43
+ this.edis="edis"
44
+ this.pricealerts="pricealerts"
45
+ this.isUserClosed=false
46
+ this.autoreconnectflag=false
47
+ this.maxreconnectiontries = 0
48
+ }
49
+
50
+ /**
51
+ * called to connect to the order socket
52
+ */
53
+ connect() {
54
+ const funcname = "connect"
55
+ // const logger = this.Logger
56
+ try {
57
+ // console.debug("initalizing connection to socket", { "accesstoken": this.authorizationKey }, funcname)
58
+ // this.ws = new WebSocket(this.url);
59
+ // var temp=Buffer.from(this.authorizationKey).toString('base64')
60
+ var temp = btoa(this.authorizationKey);
61
+ temp=encodeURIComponent(temp)
62
+ this.ws = new WebSocket(this.url, [temp]);
63
+
64
+ console.log(this.url)
65
+ this.ws.binaryType = 'arraybuffer';
66
+ this.ws.addEventListener('error', (error) => {
67
+ if (this.onErrorCallback) {
68
+ this.onErrorCallback(error);
69
+ }
70
+ else {
71
+ console.log("error occoured", error)
72
+ }
73
+ });
74
+
75
+ this.ws.addEventListener('close', (event) => {
76
+ this.stopPing()
77
+ if (this.onCloseCallback) {
78
+ this.onCloseCallback(event);
79
+ }
80
+ else {
81
+ console.log("ws closed", event)
82
+ if(!this.isUserClosed&&(reconnectiontries<this.maxreconnectiontries)){
83
+ this._autoreconnect()
84
+ }
85
+ }
86
+ });
87
+
88
+ this.ws.addEventListener('message', (message) => {
89
+ const data = message.data;
90
+ if (data === 'pong') {
91
+ return
92
+ }
93
+ else {
94
+ var parseddata = JSON.parse(data)
95
+ if (parseddata.hasOwnProperty("orders")) {
96
+ var orderdata=datamapper(parseddata["orders"],mapper.orders)
97
+ orderdata.status=ordstatobj[orderdata.status]
98
+ orderdata['orderNumStatus']=orderdata.id+':'+orderdata.status
99
+ if (this.orderscallback) {
100
+ this.orderscallback({"s":"ok","orders":orderdata})
101
+ }
102
+ else {
103
+ console.log("Orders_internal", {"s":"ok","orders":orderdata})
104
+ }
105
+ }
106
+ else if (parseddata.hasOwnProperty("positions")) {
107
+ var positiondata=datamapper(parseddata["positions"],mapper.position)
108
+ if (this.positionscallback) {
109
+ this.positionscallback({"s":"ok","positions":positiondata})
110
+ }
111
+ else {
112
+ console.log("positions_internal", {"s":"ok","positions":positiondata})
113
+ }
114
+ }
115
+ else if (parseddata.hasOwnProperty("trades")) {
116
+ var tradebookdata=datamapper(parseddata["trades"],mapper.tradebook)
117
+ if (this.tradescallback) {
118
+ this.tradescallback({"s":"ok","trades":tradebookdata})
119
+ }
120
+ else {
121
+ console.log("trades_internal", {"s":"ok","trades":tradebookdata})
122
+ }
123
+ }
124
+ else {
125
+ if (this.onMessageCallback) {
126
+ this.onMessageCallback(parseddata);
127
+ }
128
+ else {
129
+ console.log("message_internal", parseddata)
130
+ }
131
+ }
132
+
133
+ }
134
+ });
135
+
136
+ this.ws.addEventListener('open', () => {
137
+ reconnectiontries = 0
138
+ if (this.onOpenCallback) {
139
+ this.onOpenCallback();
140
+ }
141
+ else {
142
+ console.log("connected")
143
+ }
144
+
145
+ if (this.isPingEnabled) {
146
+ this.startPing();
147
+ }
148
+ });
149
+ }
150
+ catch (error) {
151
+ console.log(`Error occured ${funcname}: ${error}`)
152
+ console.error("unexpected error on connect function", error, funcname)
153
+ }
154
+ }
155
+
156
+ /**
157
+ * used to define onmessage,onerror,onopen,onclose for websocket.
158
+ * @param {string} onwhat - defines for what the callback function is.
159
+ * @param {Function} callback - the callback function.
160
+ * @throws error message if onwhat is not valid.
161
+ */
162
+ on(onwhat, callback) {
163
+ const funcname = "on"
164
+ // const logger = this.Logger
165
+ try {
166
+ if (onwhat === 'error') {
167
+ this.onErrorCallback = callback;
168
+ }
169
+ else if (onwhat === 'general') {
170
+ this.onMessageCallback = callback;
171
+ }
172
+ else if (onwhat === 'connect') {
173
+ this.onOpenCallback = callback;
174
+ }
175
+ else if (onwhat === 'close') {
176
+ const socketonclose = function (event){
177
+ callback(event)
178
+ if(!this.isUserClosed&&(reconnectiontries<this.maxreconnectiontries)){
179
+ this._autoreconnect()
180
+ }
181
+ }
182
+ this.onCloseCallback = socketonclose;
183
+ }
184
+ else if (onwhat === 'orders') {
185
+ this.orderscallback = callback;
186
+ }
187
+ else if (onwhat === 'trades') {
188
+ this.tradescallback = callback;
189
+ }
190
+ else if (onwhat === 'positions') {
191
+ this.positionscallback = callback;
192
+ }
193
+ else {
194
+ console.log("incorrect value passed", onwhat)
195
+ console.error("wrong onwhat passed", { "onwhat": onwhat }, funcname)
196
+ }
197
+ }
198
+ catch (error) {
199
+ console.error("unexpected error on 'on' function", error, funcname)
200
+ }
201
+ }
202
+
203
+ /**
204
+ * call to check if datasocket is connected
205
+ */
206
+ isConnected() {
207
+ return this.ws && this.ws.readyState === WebSocket.OPEN;
208
+ }
209
+
210
+ /**
211
+ * starts ping messages to ws
212
+ */
213
+ startPing() {
214
+ this.pingInterval = setInterval(() => {
215
+ if (this.isConnected()) {
216
+ this.ws.send("ping");
217
+ }
218
+ }, 1000);
219
+ }
220
+
221
+ /**
222
+ * stops pinging mechanism
223
+ */
224
+ stopPing() {
225
+ clearInterval(this.pingInterval);
226
+ }
227
+
228
+ /**
229
+ * Subscribe to socket.
230
+ * @param {Array|string} towhat - array or string of what you want to subscribe to.
231
+ */
232
+ subscribe(towhat) {
233
+ const funcname = "subscribe"
234
+ // const logger = this.Logger
235
+ try {
236
+ if (this.isConnected()) {
237
+ console.debug("trying to subscribe to", { "towhat": towhat }, funcname)
238
+ if (towhat.constructor === Array) {
239
+ this.ws.send(JSON.stringify({ "T": "SUB_ORD", "SLIST": towhat, "SUB_T": 1 }));
240
+ }
241
+ else {
242
+ this.ws.send(JSON.stringify({ "T": "SUB_ORD", "SLIST": [towhat], "SUB_T": 1 }));
243
+ }
244
+ }
245
+ else {
246
+ console.error("websocket is not connected", { "towhat": towhat }, funcname)
247
+ console.log('Cannot send message. WebSocket is not connected.');
248
+ }
249
+ }
250
+ catch (error) {
251
+
252
+ console.error("unexpected error on subscribe function", error, funcname)
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Unsubscribe to socket.
258
+ * @param {Array|string} towhat - array or string of what you want to unsubscribe to.
259
+ */
260
+ unsubscribe(towhat) {
261
+ const funcname = "unsubscribe"
262
+ // const logger = this.Logger
263
+ try {
264
+ if (this.isConnected()) {
265
+ if (towhat.constructor === Array) {
266
+ console.debug("trying to unsubscribe to", { "towhat": towhat }, funcname)
267
+ this.ws.send(JSON.stringify({ "T": "SUB_ORD", "SLIST": towhat, "SUB_T": -1 }));
268
+ }
269
+ else {
270
+ this.ws.send(JSON.stringify({ "T": "SUB_ORD", "SLIST": [towhat], "SUB_T": -1 }));
271
+ }
272
+ }
273
+ else {
274
+ console.error("websocket is not connected", { "towhat": towhat }, funcname)
275
+ // console.log('Cannot send message. WebSocket is not connected.');
276
+ }
277
+ }
278
+ catch (error) {
279
+ console.error("unexpected error on unsubscribe function", error, funcname)
280
+ }
281
+ }
282
+
283
+ /**
284
+ * call to close the datasocket.
285
+ */
286
+ close() {
287
+ if (this.ws && this.isConnected) {
288
+ clearInterval(this.autoreconnectinterval)
289
+ this.stopPing()
290
+ this.ws.close();
291
+ this.isUserClosed = true
292
+ }
293
+ }
294
+
295
+ /**
296
+ * call to enable autoreconnect functionality of websocket.
297
+ */
298
+ _autoreconnect() {
299
+ if (this.autoreconnectflag){
300
+ var waitSeconds = Math.floor((reconnectiontries+5)/5);
301
+ waitSeconds *= 5;
302
+
303
+ this.autoreconnectinterval = setTimeout(() => {
304
+ if ((!this.isConnected()) && (reconnectiontries < this.maxreconnectiontries)) {
305
+ console.log("trying to reconnect ", reconnectiontries + 1)
306
+ reconnectiontries++
307
+ this.connect()
308
+ } else if (reconnectiontries >= this.maxreconnectiontries) {
309
+ console.log("max autoconnect tries exceeded")
310
+ clearInterval(this.autoreconnectinterval)
311
+ this.stopPing()
312
+ reconnectiontries = 0
313
+ }
314
+ }, (waitSeconds)*1000);
315
+ }
316
+ }
317
+ /**
318
+ * call to enable autoreconnect functionality of websocket.
319
+ */
320
+ autoreconnect(reConnectTriesCount=5){
321
+ this.autoreconnectflag=true
322
+ this.maxreconnectiontries=(reConnectTriesCount>50) ? 50 : reConnectTriesCount
323
+ }
324
+ }
325
+ export {FyersOrderSocket}
@@ -0,0 +1,79 @@
1
+ const ordersMapper = {
2
+ 'client_id': 'clientId',
3
+ 'id': 'id',
4
+ 'id_parent': 'parentId',
5
+ 'id_exchange': 'exchOrdId',
6
+ 'qty': 'qty',
7
+ 'qty_remaining': 'remainingQuantity',
8
+ 'qty_filled': 'filledQty',
9
+ 'price_limit': 'limitPrice',
10
+ 'price_stop': 'stopPrice',
11
+ 'tradedPrice': 'price_traded',
12
+ 'ord_type': 'type',
13
+ 'fy_token': 'fyToken',
14
+ 'exchange': 'exchange',
15
+ 'segment': 'segment',
16
+ 'symbol': 'symbol',
17
+ 'instrument': 'instrument',
18
+ 'oms_msg': 'message',
19
+ 'offline_flag': 'offlineOrder',
20
+ 'time_oms': 'orderDateTime',
21
+ 'validity': 'orderValidity',
22
+ 'product_type': 'productType',
23
+ 'tran_side': 'side',
24
+ 'ord_status': 'status',
25
+ 'ord_source': 'source',
26
+ 'symbol_exch': 'ex_sym',
27
+ 'symbol_desc': 'description',
28
+ 'ordertag': 'orderTag'
29
+ }
30
+
31
+ const positionbookMapper = {
32
+ 'symbol': 'symbol',
33
+ 'id': 'id',
34
+ 'buy_avg': 'buyAvg',
35
+ 'buy_qty': 'buyQty',
36
+ 'buy_val': 'buyVal',
37
+ 'sell_avg': 'sellAvg',
38
+ 'sell_qty': 'sellQty',
39
+ 'sell_val': 'sellVal',
40
+ 'net_avg': 'netAvg',
41
+ 'net_qty': 'netQty',
42
+ 'tran_side': 'side',
43
+ 'qty': 'qty',
44
+ 'product_type': 'productType',
45
+ 'pl_realized': 'realized_profit',
46
+ 'rbirefrate': 'rbiRefRate',
47
+ 'fy_token': 'fyToken',
48
+ 'exchange': 'exchange',
49
+ 'segment': 'segment',
50
+ 'day_buy_qty': 'dayBuyQty',
51
+ 'day_sell_qty': 'daySellQty',
52
+ 'cf_buy_qty': 'cfBuyQty',
53
+ 'cf_sell_qty': 'cfSellQty',
54
+ 'qty_multiplier': 'qtyMulti_com',
55
+ 'pl_total': 'pl',
56
+ 'cross_curr_flag': 'crossCurrency',
57
+ 'pl_unrealized': 'unrealized_profit',
58
+ }
59
+
60
+ const tradebookMapper = {
61
+ 'id_fill': 'tradeNumber',
62
+ 'id': 'orderNumber',
63
+ 'qty_traded': 'tradedQty',
64
+ 'price_traded': 'tradePrice',
65
+ 'traded_val': 'tradeValue',
66
+ 'product_type': 'productType',
67
+ 'client_id': 'clientId',
68
+ 'id_exchange': 'exchangeOrderNo',
69
+ 'ord_type': 'orderType',
70
+ 'tran_side': 'side',
71
+ 'symbol': 'symbol',
72
+ 'fill_time': 'orderDateTime',
73
+ 'fy_token': 'fyToken',
74
+ 'exchange': 'exchange',
75
+ 'segment': 'segment',
76
+ 'ordertag': 'orderTag'
77
+ }
78
+
79
+ export const mapper = { "orders": ordersMapper, "position": positionbookMapper, "tradebook": tradebookMapper }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "fyers-web-sdk-v3",
3
+ "version": "1.0.0",
4
+ "description": "fyers api for web compatibility",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "devDependencies": {
10
+ "javascript-obfuscator": "^4.0.2"
11
+ },
12
+ "author": "",
13
+ "license": "ISC"
14
+ }
package/sample/api.js ADDED
@@ -0,0 +1,46 @@
1
+ var fyersModel= require("../index.js").fyersModel
2
+
3
+ var fyers= new fyersModel()
4
+
5
+ fyers.setAppId("QC7T0H8425-100")
6
+
7
+ fyers.setRedirectUrl("https://www.google.com")
8
+ // generate authcode
9
+ ////////////////////////////
10
+
11
+ // var URL=fyers.generateAuthCode()
12
+
13
+ // console.log(URL)
14
+
15
+ // after getting authcode
16
+
17
+ ////////////////////////////
18
+
19
+ // generate accesstoken
20
+ ////////////////////////////
21
+ // var authcode=""
22
+
23
+ // fyers.generate_access_token({"client_id":fyers.AppID,"secret_key":"4362L6SS2C","auth_code":authcode}).then((response)=>{
24
+ // console.log(response)
25
+ // })
26
+ ////////////////////////////
27
+
28
+ fyers.setAccessToken("")
29
+
30
+ fyers.get_profile().then((response)=>{
31
+ console.log(response)
32
+ }).catch((err)=>{
33
+ console.log(err)
34
+ })
35
+
36
+ fyers.getQuotes(["NSE:SBIN-EQ","NSE:TCS-EQ"]).then((response)=>{
37
+ console.log(response)
38
+ }).catch((err)=>{
39
+ console.log(err)
40
+ })
41
+
42
+ fyers.getMarketDepth({"symbol":["NSE:SBIN-EQ","NSE:TCS-EQ"],"ohlcv_flag":1}).then((response)=>{
43
+ console.log(response)
44
+ }).catch((err)=>{
45
+ console.log(err)
46
+ })
@@ -0,0 +1,25 @@
1
+ import {DataSocket} from "../index.js"
2
+
3
+ var skt= DataSocket.getInstance("")
4
+
5
+ skt.on("connect",function(){skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"],false,1)
6
+ skt.mode(skt.FullMode,1)
7
+ console.log(skt.isConnected())
8
+ // skt.mode(skt.LiteMode,[11,12,13])
9
+ // skt.channelresume(2)
10
+ // skt.unsubscribe(['NSE:IDEA-EQ'],false,1)
11
+ })
12
+
13
+ skt.on("message",function(message){
14
+ console.log({"TEST":message})
15
+ })
16
+
17
+ skt.on("error",function(message){
18
+ console.log("erroris",message)
19
+ })
20
+
21
+ skt.on("close",function(){
22
+ console.log("socket closed")
23
+ })
24
+ skt.connect()
25
+ skt.autoreconnect()
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document</title>
7
+ <button type="submit" class="id">click here for order socket</button>
8
+ <button type="submit" class="data_socket">click here for data socket</button>
9
+ <button type="submit" class="apis">click here for api</button>
10
+ </head>
11
+ <body>
12
+
13
+ </body>
14
+ <script type="module" src = './index.js'></script>
15
+ </html>