api_connect_nodejs 2.0.11 → 2.0.13

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.
package/conf/settings.ini CHANGED
@@ -10,7 +10,7 @@ BasePathReport = https://nc.nuvamawealth.com/app-report/equity/
10
10
  EquityContractURL = https://nc.nuvamawealth.com/app/toccontracts/instruments.zip
11
11
  MFContractURL = https://nc.nuvamawealth.com/app/toccontracts/mfInstruments.zip
12
12
 
13
- ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOjAsImZmIjoiVyIsImJkIjoid2ViLXBjIiwibmJmIjoxNzAzODUxOTQyLCJzcmMiOiJlbXRtdyIsImF2IjoiMi4wLjExIiwiYXBwaWQiOiI2NDE2ODVkOTExNjc0OTgyZDFjMGI5YzQzMmMxYWIyYiIsImlzcyI6ImVtdCIsImV4cCI6MTcwMzg3NDYwMCwiaWF0IjoxNzAzODUyMjQyfQ.m4RBAPmJc0RF1c1aR45kpVM7xPegx_F01F3nX-Bmiag
13
+ ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOjAsImZmIjoiVyIsImJkIjoid2ViLXBjIiwibmJmIjoxNzE5NTU5MTcyLCJzcmMiOiJlbXRtdyIsImF2IjoiMi4wLjEzIiwiYXBwaWQiOiIyNGI0OTUyNmUwNjRjOWQwOTU3NmUyYjk1ZDg0M2M3NSIsImlzcyI6ImVtdCIsImV4cCI6MTcxOTU5OTQwMCwiaWF0IjoxNzE5NTU5NDcyfQ.cwtG6ceohsEmbpQNiqrS8IjV4lmA0KM8RvLuy1eDX4E
14
14
  TlsVersion = 1.2
15
15
  LogLevel = All
16
16
 
@@ -6,6 +6,7 @@ const chartExchangeType = Object.freeze({
6
6
  NSE: "NSE",
7
7
  BSE: "BSE",
8
8
  NFO: "NFO",
9
+ BFO: "BFO",
9
10
  CDS: "CDS",
10
11
  MCX: "MCX",
11
12
  NCDEX: "NCDEX",
@@ -6,6 +6,7 @@ const exchangeType = Object.freeze({
6
6
  NSE: "NSE",
7
7
  BSE: "BSE",
8
8
  NFO: "NFO",
9
+ BFO: "BFO",
9
10
  CDS: "CDS",
10
11
  MCX: "MCX",
11
12
  NCDEX: "NCDEX",
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  const streamingConstants = Object.freeze({
6
- QUOTE_SREAM_REQ_CODE: 1,
7
6
  ORDER_STREAM_REQ_CODE: 2,
8
7
  LIVENEWS_STREAM_REQ_CODE: 3,
9
8
  DEPTH_SREAM_REQ_CODE: 4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api_connect_nodejs",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "Command to run :",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@joi/date": "^2.1.0",
11
- "chai": "^4.3.6",
11
+ "chai": "^4.3.6",
12
12
  "csv-parser": "^3.0.0",
13
13
  "csv-writer": "^1.6.0",
14
14
  "fast-csv": "^4.3.6",
package/src/apiConnect.js CHANGED
@@ -80,13 +80,13 @@ class APIConnect {
80
80
  const checkDone = (res) => {
81
81
  count = count - 1;
82
82
  if (count == 0) {
83
- resolve(res);
83
+ resolve(res);
84
84
  }
85
85
  };
86
86
  const readFilePromise = new Promise((resolve, reject) => {
87
87
  fs.readFile(this.fileName, "utf8", (err, data) => {
88
88
  if (err) {
89
- //var promises=[]
89
+ //var promises=[]
90
90
  // if file doesn't exist, then generate it
91
91
  // these two functions will fill the __constants and generate ${fileName}
92
92
  // promises.push(this.__GenerateVendorSession(this.apiKey, this.password, this.reqId));
@@ -104,7 +104,7 @@ class APIConnect {
104
104
  })
105
105
  .catch((err) => reject(err));
106
106
  } else {
107
- const j = JSON.parse(data);
107
+ const j = JSON.parse(data);
108
108
  this.__constants.VendorSession = j.vt;
109
109
  this.__constants.JSession = j.auth;
110
110
  this.__constants.eqAccId = j.eqaccid;
@@ -127,15 +127,15 @@ class APIConnect {
127
127
  // Check if ${fileName} exists
128
128
  readFilePromise
129
129
  .then((res) => {
130
- count++;
130
+ count++;
131
131
  this.__CheckUpdate().then(checkDone).catch(reject);
132
132
  this.excsAndprdDpNm = this.__constants.getProductsAndExchange(
133
133
  this.__constants.prds
134
134
  );
135
- this.__Instruments()
135
+ this.__Instruments()
136
136
  .then(async (res) => {
137
137
  //console.log("instrument then");
138
- checkDone(res);
138
+ checkDone(res);
139
139
  })
140
140
  .catch((err) => reject(err));
141
141
  })
@@ -497,7 +497,7 @@ class APIConnect {
497
497
  * @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
498
498
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
499
499
  * @param {string} symbol
500
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
500
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
501
501
  * @param {string} tillDate yyyy-MM-dd
502
502
  * @param {boolean} includeContinuousFuture
503
503
  * @returns
@@ -530,7 +530,7 @@ class APIConnect {
530
530
  * @param {"D1" | "W1" | "MN1"} interval
531
531
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
532
532
  * @param {string} symbol
533
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
533
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
534
534
  * @param {string} tillDate yyyy-MM-dd
535
535
  * @param {boolean} includeContinuousFuture
536
536
  * @returns
@@ -562,7 +562,7 @@ class APIConnect {
562
562
  *
563
563
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
564
564
  * @param {string} symbol
565
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
565
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
566
566
  * @param {string} fromDate yyyy-MM-dd
567
567
  * @param {string} toDate yyyy-MM-dd
568
568
  * @param {boolean} includeContinuousFuture
package/src/chart.js CHANGED
@@ -154,7 +154,7 @@ class Chart {
154
154
  * @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
155
155
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
156
156
  * @param {string} symbol
157
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
157
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
158
158
  * @param {string} tillDate
159
159
  * @param {boolean} includeContinuousFuture
160
160
  * @returns
@@ -237,7 +237,7 @@ class Chart {
237
237
  * @param {"D1" | "W1" | "MN1"} interval
238
238
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
239
239
  * @param {string} symbol
240
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
240
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
241
241
  * @param {string} tillDate yyyy-MM-dd
242
242
  * @param {boolean} includeContinuousFuture
243
243
  * @returns
@@ -320,7 +320,7 @@ class Chart {
320
320
  * @param {"D1" | "W1" | "MN1"} interval
321
321
  * @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
322
322
  * @param {string} symbol
323
- * @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
323
+ * @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
324
324
  * @param {string} fromDate yyyy-MM-dd
325
325
  * @param {string} toDate yyyy-MM-dd
326
326
  * @param {boolean} includeContinuousFuture
package/src/feed/feed.js CHANGED
@@ -15,6 +15,7 @@ class Feed {
15
15
  constructor() {
16
16
  this.sock = new net.Socket();
17
17
  this.status = false;
18
+ const heartBeatTimer = 0;
18
19
  this.init();
19
20
  this.requestsList = {};
20
21
  }
@@ -29,54 +30,9 @@ class Feed {
29
30
  try {
30
31
  this.sock.connect(port, hostName, () => {
31
32
  this.clearIntervalConnect();
32
- console.log("connected to server!");
33
33
  log4js.debug("connected to server!");
34
34
  });
35
- } catch (error) {
36
- console.log("connect error is " + error);
37
- log4js.debug("connect error is " + error);
38
- this.reconnect();
39
- }
40
- };
41
-
42
- clearIntervalConnect = () => {
43
- if (false === this.status) return;
44
- clearInterval(this.status);
45
- this.status = false;
46
- };
47
-
48
- reconnect = () => {
49
- console.log("reconnecting...");
50
- log4js.debug("reconnecting...");
51
-
52
- if (this.status) return;
53
- this.status = setInterval(() => {
54
- this.sock.removeAllListeners();
55
- this.connect();
56
- }, 3000);
57
- };
58
-
59
- subsribe = (streamingConstants, request, callBack) => {
60
- const requestObj = {
61
- request: request,
62
- callback: callBack,
63
- };
64
- this.requestsList[streamingConstants] = requestObj;
65
- this.readWriteStreamData(requestObj);
66
- };
67
-
68
- unsubsribe = (streamingConstants, request) => {
69
- const requestObj = {
70
- request: request,
71
- callback: this.requestsList[streamingConstants].callback,
72
- };
73
- this.readWriteStreamData(requestObj);
74
- delete this.requestsList[streamingConstants];
75
- };
76
35
 
77
- readWriteStreamData = (requestObj) => {
78
- try {
79
- this.sock.write(JSON.stringify(requestObj.request) + "\n");
80
36
  this.sock.on("data", (data) => {
81
37
  try {
82
38
  let result = data.toString();
@@ -91,14 +47,6 @@ class Feed {
91
47
  "callback"
92
48
  ];
93
49
  callbackMethod(null, result, null);
94
- } else if (
95
- streamingType.toLowerCase() == "quote3".toLowerCase()
96
- ) {
97
- let callbackMethod =
98
- this.requestsList[streamingConstants.QUOTE_SREAM_REQ_CODE][
99
- "callback"
100
- ];
101
- callbackMethod(null, result, null);
102
50
  } else if (
103
51
  streamingType.toLowerCase() == "quote".toLowerCase()
104
52
  ) {
@@ -139,13 +87,12 @@ class Feed {
139
87
  });
140
88
 
141
89
  this.sock.on("end", (val) => {
142
- console.log("Connection ended ");
143
90
  this.reconnect();
144
91
  });
145
92
 
146
93
  this.sock.on("error", (err) => {
147
94
  log4js.debug("connection error " + err);
148
- requestObj.callback(err, null, null);
95
+ // requestObj.callback(err, null, null);
149
96
  this.reconnect();
150
97
  });
151
98
 
@@ -153,9 +100,70 @@ class Feed {
153
100
  log4js.debug("connection closed " + val);
154
101
  this.reconnect();
155
102
  });
103
+
104
+ } catch (error) {
105
+ log4js.debug("connect error is " + error);
106
+ this.reconnect();
107
+ }
108
+ };
109
+
110
+ clearIntervalConnect = () => {
111
+ if (false === this.status) return;
112
+ clearInterval(this.status);
113
+ this.status = false;
114
+ };
115
+
116
+ reconnect = () => {
117
+ log4js.debug("reconnecting...");
118
+
119
+ if (this.status) return;
120
+ this.status = setInterval(() => {
121
+ this.sock.removeAllListeners();
122
+ this.connect();
123
+ }, 3000);
124
+ };
125
+
126
+ subsribe = (streamingConstants, request, callBack, heartBeatFeed = false) => {
127
+ const requestObj = {
128
+ request: request,
129
+ callback: callBack,
130
+ };
131
+ this.requestsList[streamingConstants] = requestObj;
132
+ this.readWriteStreamData(requestObj, heartBeatFeed);
133
+ this.checkAndStartHeartBeat()
134
+ };
135
+
136
+ unsubsribe = (streamingConstants, request, heartBeatFeed = false) => {
137
+ const requestObj = {
138
+ request: request,
139
+ callback: this.requestsList[streamingConstants].callback,
140
+ };
141
+ this.readWriteStreamData(requestObj, heartBeatFeed);
142
+ delete this.requestsList[streamingConstants];
143
+ };
144
+
145
+ readWriteStreamData = (requestObj, heartBeatFeed= false) => {
146
+
147
+ try {
148
+ if(heartBeatFeed) {
149
+ this.sock.write("{}" + "\n");
150
+ } else {
151
+ this.sock.write(JSON.stringify(requestObj.request) + "\n");
152
+ }
153
+
156
154
  } catch (error) {
157
155
  console.log({ error });
158
156
  }
157
+ }
158
+
159
+ checkAndStartHeartBeat = () => {
160
+
161
+ if(this.heartBeatTimer) {
162
+ // Clearing the interval timer
163
+ clearInterval(this.heartBeatTimer);
164
+ }
165
+
166
+ this.heartBeatTimer = setInterval(this.readWriteStreamData, 90000, undefined, true);
159
167
  };
160
168
  }
161
169
 
@@ -1,9 +1,7 @@
1
1
  const log4js = require("../logger");
2
2
  const configData = require("../iniparser");
3
- const { QUOTE_SREAM_REQ_CODE, REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
3
+ const { REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
4
  const {
5
- validateSubscribeQuotesFeed,
6
- validateUnsubscribeQuotesFeed,
7
5
  validateSubscribeReducedQuotesFeed,
8
6
  validateUnsubscribeReducedQuotesFeed,
9
7
  } = require("../../validations/feedStreamerValidator");
@@ -17,108 +15,6 @@ class QuotesFeed {
17
15
  this.feed = feed;
18
16
  }
19
17
 
20
- /**
21
- * QutoesFeed RequestBody Structure
22
- * Return QuotesFeed RequestBody Structure
23
- * @function quotesFeedRequestBody
24
- * @returns object
25
- */
26
- requestBody = () => {
27
- return {
28
- request: {
29
- streaming_type: "quote3",
30
- data: {
31
- "accType": "EQ",
32
- symbols: [],
33
- },
34
- formFactor: configData.formFactor,
35
- appID: configData.ApiIdKey,
36
- response_format: "json",
37
- request_type: "",
38
- },
39
- echo: {},
40
- };
41
- };
42
-
43
- /**
44
- * Create QuotesFeed RequestBody
45
- * Return QuotesFeed RequestBody
46
- * @function createQuotesFeedRequest
47
- * @param {Object[]} symbols - Array of subsribe Symbols
48
- * @param {boolean} order - true for subsribe and false for unsubsribe
49
- * @returns object
50
- */
51
- createQuotesFeedRequest = (symbols, quote = false) => {
52
- let body = {};
53
- try {
54
- body = this.requestBody();
55
- const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
56
-
57
- body.request.data.symbols = symset;
58
-
59
- if (quote) {
60
- body.request.request_type = "subscribe";
61
- } else {
62
- body.request.request_type = "unsubscribe";
63
- }
64
- } catch (error) {
65
- log4js.debug("createQuotesFeedRequest error - " + error);
66
- } finally {
67
- return body;
68
- }
69
- };
70
-
71
- /**
72
- * To subscribe to the streamer, Create the single instance of this mentioning `callback` method. After successsful subscription, `callback` method will be called whenever packet is available at the streamer.
73
- * @async
74
- * @function subscribeQuotesFeed
75
- * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
76
- * @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
77
- * @returns
78
- */
79
- subscribeQuotesFeed = async (symbols, callback) => {
80
- try {
81
- /** Validation Start */
82
- const validateResponse = validateSubscribeQuotesFeed(callback, symbols);
83
-
84
- if (validateResponse.error) {
85
- log4js.debug(
86
- "subscribeQuotesFeed validation error - " +
87
- validateResponse.error.details
88
- );
89
- return Promise.reject(validateResponse.error.details);
90
- }
91
- /** Validation End */
92
-
93
- /** Create Streaming Quote Request */
94
- let quoteRequest = this.createQuotesFeedRequest(symbols, true);
95
- /** Call connect method of Feed Class */
96
- this.feed.subsribe(QUOTE_SREAM_REQ_CODE, quoteRequest, callback);
97
- } catch (error) {
98
- log4js.debug("subscribeQuotesFeed error - " + error);
99
- console.log(error);
100
- }
101
- };
102
-
103
- /**
104
- * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
105
- * @async
106
- * @function unsubscribeQuotesFeed
107
- * @returns
108
- */
109
- unsubscribeQuotesFeed = async () => {
110
- try {
111
- /** Get Streaming Quote Request */
112
- const quoteRequest = this.createQuotesFeedRequest([]);
113
-
114
- /** Unsubsribe symbols */
115
- this.feed.unsubsribe(QUOTE_SREAM_REQ_CODE, quoteRequest);
116
- } catch (error) {
117
- log4js.debug("unsubscribeQuotesFeed error - " + error);
118
- console.log(error);
119
- }
120
- };
121
-
122
18
  //Reduced Quote
123
19
 
124
20
  /**
package/src/http.js CHANGED
@@ -30,12 +30,12 @@ class __Http {
30
30
  }
31
31
 
32
32
  GetMethod(url, sendSource = true) {
33
- let headers = this.createHeaders(sendSource);
34
- const options = { hostname: this.__baseurl, path: url, headers: headers };
33
+ let headers = this.createHeaders(sendSource);
34
+ const options = { hostname: this.__baseurl, path: url, headers: headers };
35
35
 
36
36
  return new Promise((resolve, reject) => {
37
37
  const req = https.get(options, (res) => {
38
- let body = [];
38
+ let body = [];
39
39
  res.on("data", (d) => {
40
40
  body.push(d);
41
41
  });
Binary file
@@ -1,213 +0,0 @@
1
- const assert = require("chai").assert;
2
- var { APIConnect } = require("../../../src/apiConnect");
3
- var testConfig = require("../config");
4
-
5
- const credentials = testConfig.equity;
6
-
7
- edelconnectObj = async() => {
8
- const edelObj = new APIConnect(
9
- credentials.apiKey,
10
- credentials.password,
11
- credentials.reqId,
12
- credentials.downloadContract
13
- );
14
- const res = await edelObj.Init();
15
- return edelObj;
16
- }
17
-
18
- /**
19
- * Command to run Test Cases "npm run testCustomPeriodChart"
20
- */
21
-
22
- describe("CustomPeriod chartTest", async function () {
23
-
24
- describe("testCustomPeriodIfExchangeTypeIsNull", async function () {
25
- let result;
26
- before(async () => {
27
- const edelObj = await edelconnectObj();
28
-
29
- try {
30
- result = await edelObj.getCustomPeriodChart(
31
- "EQUITY", //assetType
32
- "11423_NSE", //symbol
33
- null, //exchangeType
34
- "2023-10-06", //fromDate
35
- "2023-11-06", //toDate
36
- false //includeContinuousFuture
37
- );
38
- } catch(error) {
39
- result = error;
40
- }
41
- });
42
-
43
- it('"exc" must be one of [NSE, BSE, NFO, CDS, MCX, NCDEX, INDEX]', async function () {
44
- assert.equal(
45
- result[0].message,
46
- '"exc" must be one of [NSE, BSE, NFO, CDS, MCX, NCDEX, INDEX]'
47
- );
48
- });
49
-
50
- it('"exc" must be a string', async function () {
51
- assert.equal(result[1].message, '"exc" must be a string');
52
- });
53
- });
54
-
55
- describe("testCustomPeriodIfAssetTypeIsNull", async function () {
56
- let result;
57
- before(async () => {
58
- const edelObj = await edelconnectObj();
59
-
60
- try {
61
- result = await edelObj.getCustomPeriodChart(
62
- null, //assetType
63
- "11423_NSE", //symbol
64
- "NSE", //exchangeType
65
- "2023-10-06", //fromDate
66
- "2023-11-06", //toDate
67
- false //includeContinuousFuture
68
- );
69
- } catch(error) {
70
- result = error;
71
- }
72
- });
73
-
74
- it('"assetType" must be one of [FUTSTK, FUTIDX, FUTCUR, FUTCOM, OPTIDX, OPTSTK, OPTCUR, OPTFUT, EQUITY, INDEX]', async function () {
75
- assert.equal(
76
- result[0].message,
77
- '"aType" must be one of [FUTSTK, FUTIDX, FUTCUR, FUTCOM, OPTIDX, OPTSTK, OPTCUR, OPTFUT, EQUITY, INDEX]'
78
- );
79
- });
80
-
81
- it('"assetType" must be a string', async function () {
82
- assert.equal(result[1].message, '"aType" must be a string');
83
- });
84
- });
85
-
86
- describe("testCustomPeriodIfFromDateIsNull", async function () {
87
- let result;
88
- before(async () => {
89
- const edelObj = await edelconnectObj();
90
- try {
91
- result = await edelObj.getEODChart(
92
- "EQUITY", //assetType
93
- "11423_NSE", //symbol
94
- "NSE", //exchangeType
95
- null, //fromDate
96
- "2023-11-06", //toDate
97
- false //includeContinuousFuture
98
- );
99
- } catch (error) {
100
- result = error;
101
- }
102
- });
103
-
104
- it("testCustomPeriodIfFromDateIsNull", async function () {
105
- assert.equal(
106
- result[0].message,
107
- '"From date" should not be null'
108
- );
109
- });
110
-
111
- it('"From date" must be a string', async function () {
112
- assert.equal(result[1].message, '"From date" must be a string');
113
- });
114
- });
115
-
116
- describe("testCustomPeriodIfToDateIsNull", async function () {
117
- let result;
118
- before(async () => {
119
- const edelObj = await edelconnectObj();
120
- try {
121
- result = await edelObj.getEODChart(
122
- "EQUITY", //assetType
123
- "11423_NSE", //symbol
124
- "NSE", //exchangeType
125
- "2023-11-06", //fromDate
126
- null, //toDate
127
- false //includeContinuousFuture
128
- );
129
- } catch (error) {
130
- result = error;
131
- }
132
- });
133
-
134
- it("testCustomPeriodIfToDateIsNull", async function () {
135
- assert.equal(
136
- result[0].message,
137
- '"To date" should not be null'
138
- );
139
- });
140
-
141
- it('"To date" must be a string', async function () {
142
- assert.equal(result[1].message, '"To date" must be a string');
143
- });
144
- });
145
-
146
- describe("testCustomPeriodIfSymbolIsNull", async function () {
147
- let result;
148
- before(async () => {
149
- const edelObj = await edelconnectObj();
150
- try {
151
- result = await edelObj.getEODChart(
152
- "EQUITY", //assetType
153
- null, //symbol
154
- "NSE", //exchangeType
155
- "2023-10-06", //fromDate
156
- "2023-11-06", //toDate
157
- false //includeContinuousFuture
158
- );
159
- } catch (error) {
160
- result = error;
161
- }
162
- });
163
-
164
- it('"symbol" must be a string', async function () {
165
- assert.equal(result[0].message, '"symbol" must be a string');
166
- });
167
- });
168
-
169
- describe("IfallInputParamsHaveCorrectParams", async function () {
170
- try {
171
- const requestBodyObj = {
172
- assetType: "EQUITY",
173
- symbol: "11423_NSE",
174
- exchangeType: "NSE",
175
- fromDate:"2023-10-06", //fromDate
176
- toDate:"2023-11-06", //toDate
177
- includeContinuousFuture: false,
178
- };
179
- let response = {};
180
-
181
- before(async () => {
182
- const edelObj = await edelconnectObj();
183
- try {
184
- const result = await edelObj.getEODChart(
185
- requestBodyObj.assetType,
186
- requestBodyObj.symbol,
187
- requestBodyObj.exchangeType,
188
- requestBodyObj.fromDate,
189
- requestBodyObj.toDate,
190
- requestBodyObj.includeContinuousFuture
191
- );
192
- response = result;
193
- } catch (error) {
194
- console.log("error is ", error);
195
- }
196
- });
197
-
198
- it("Response is not empty", async function () {
199
- assert.isNotEmpty(response);
200
- });
201
-
202
- it("Response have msgID", async function () {
203
- assert.isNotEmpty(response.msgID);
204
- });
205
-
206
- it("Response have srvTm", async function () {
207
- assert.isNotNull(response.srvTm);
208
- });
209
- } catch (error) {
210
- console.log("error is ", error);
211
- }
212
- });
213
- });