api_connect_nodejs 2.0.2 → 2.0.5

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.
Files changed (43) hide show
  1. package/README.md +30 -30
  2. package/conf/settings.ini +19 -19
  3. package/enums/actionType.js +10 -10
  4. package/enums/assetType.js +25 -25
  5. package/enums/chartExchangeType.js +15 -15
  6. package/enums/chartType.js +13 -13
  7. package/enums/eodIntervalType.js +11 -11
  8. package/enums/exchangeType.js +14 -14
  9. package/enums/intradayIntervalType.js +14 -14
  10. package/enums/marketCapType.js +12 -12
  11. package/enums/orderType.js +21 -21
  12. package/enums/productType.js +24 -24
  13. package/enums/segementsType.js +13 -13
  14. package/enums/streamingConstants.js +14 -11
  15. package/enums/termsType.js +12 -12
  16. package/enums/validity.js +22 -22
  17. package/index.js +3 -3
  18. package/package.json +25 -25
  19. package/src/apiConnect.js +2397 -2430
  20. package/src/apiUtils.js +221 -129
  21. package/src/chart.js +258 -258
  22. package/src/config.js +321 -326
  23. package/src/feed/depthFeed.js +137 -0
  24. package/src/feed/feed.js +162 -139
  25. package/src/feed/liveNewsFeed.js +112 -112
  26. package/src/feed/miniQuoteFeed.js +121 -0
  27. package/src/feed/ordersFeed.js +124 -124
  28. package/src/feed/quotesFeed.js +226 -121
  29. package/src/http.js +197 -197
  30. package/src/iniparser.js +42 -42
  31. package/src/liveNews.js +362 -362
  32. package/src/logger.js +16 -16
  33. package/src/order.js +48 -48
  34. package/src/quote.js +75 -0
  35. package/src/researchCalls.js +175 -175
  36. package/src/watchlist.js +378 -378
  37. package/validations/apiConnectValidator.js +521 -508
  38. package/validations/chartValidator.js +85 -85
  39. package/validations/feedStreamerValidator.js +162 -68
  40. package/validations/liveNewsValidator.js +60 -60
  41. package/validations/quoteValidator.js +19 -0
  42. package/validations/researchCallsValidator.js +86 -86
  43. package/validations/watchlistValidator.js +60 -60
@@ -1,121 +1,226 @@
1
- const log4js = require("../logger");
2
- const configData = require("../iniparser");
3
- const { QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
- const {
5
- validateSubscribeQuotesFeed,
6
- validateUnsubscribeQuotesFeed,
7
- } = require("../../validations/feedStreamerValidator");
8
-
9
- class QuotesFeed {
10
- /**
11
- * Streamer
12
- * QuotesFeed Class for subsribe or unsubsribe Quotes
13
- */
14
- constructor(feed) {
15
- this.feed = feed;
16
- }
17
-
18
- /**
19
- * QutoesFeed RequestBody Structure
20
- * Return QuotesFeed RequestBody Structure
21
- * @function quotesFeedRequestBody
22
- * @returns object
23
- */
24
- requestBody = () => {
25
- return {
26
- request: {
27
- streaming_type: "quote3",
28
- data: {
29
- "accType": "EQ",
30
- symbols: [],
31
- },
32
- formFactor: configData.formFactor,
33
- appID: configData.ApiIdKey,
34
- response_format: "json",
35
- request_type: "",
36
- },
37
- echo: {},
38
- };
39
- };
40
-
41
- /**
42
- * Create QuotesFeed RequestBody
43
- * Return QuotesFeed RequestBody
44
- * @function createQuotesFeedRequest
45
- * @param {Object[]} symbols - Array of subsribe Symbols
46
- * @param {boolean} order - true for subsribe and false for unsubsribe
47
- * @returns object
48
- */
49
- createQuotesFeedRequest = (symbols, quote = false) => {
50
- let body = {};
51
- try {
52
- body = this.requestBody();
53
- const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
54
-
55
- body.request.data.symbols = symset;
56
-
57
- if (quote) {
58
- body.request.request_type = "subscribe";
59
- } else {
60
- body.request.request_type = "unsubscribe";
61
- }
62
- } catch (error) {
63
- log4js.debug("createQuotesFeedRequest error - " + error);
64
- } finally {
65
- return body;
66
- }
67
- };
68
-
69
- /**
70
- * 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.
71
- * @async
72
- * @function subscribeQuotesFeed
73
- * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
74
- * @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
75
- * @returns
76
- */
77
- subscribeQuotesFeed = async (symbols, callback) => {
78
- try {
79
- /** Validation Start */
80
- const validateResponse = validateSubscribeQuotesFeed(callback, symbols);
81
-
82
- if (validateResponse.error) {
83
- log4js.debug(
84
- "subscribeQuotesFeed validation error - " +
85
- validateResponse.error.details
86
- );
87
- return Promise.reject(validateResponse.error.details);
88
- }
89
- /** Validation End */
90
-
91
- /** Create Streaming Quote Request */
92
- let quoteRequest = this.createQuotesFeedRequest(symbols, true);
93
- /** Call connect method of Feed Class */
94
- this.feed.subsribe(QUOTE_SREAM_REQ_CODE, quoteRequest, callback);
95
- } catch (error) {
96
- log4js.debug("subscribeQuotesFeed error - " + error);
97
- console.log(error);
98
- }
99
- };
100
-
101
- /**
102
- * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
103
- * @async
104
- * @function unsubscribeQuotesFeed
105
- * @returns
106
- */
107
- unsubscribeQuotesFeed = async () => {
108
- try {
109
- /** Get Streaming Quote Request */
110
- const quoteRequest = this.createQuotesFeedRequest([]);
111
-
112
- /** Unsubsribe symbols */
113
- this.feed.unsubsribe(QUOTE_SREAM_REQ_CODE, quoteRequest);
114
- } catch (error) {
115
- log4js.debug("unsubscribeQuotesFeed error - " + error);
116
- console.log(error);
117
- }
118
- };
119
- }
120
-
121
- module.exports = QuotesFeed;
1
+ const log4js = require("../logger");
2
+ const configData = require("../iniparser");
3
+ const { QUOTE_SREAM_REQ_CODE, REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
+ const {
5
+ validateSubscribeQuotesFeed,
6
+ validateUnsubscribeQuotesFeed,
7
+ validateSubscribeReducedQuotesFeed,
8
+ validateUnsubscribeReducedQuotesFeed,
9
+ } = require("../../validations/feedStreamerValidator");
10
+
11
+ class QuotesFeed {
12
+ /**
13
+ * Streamer
14
+ * QuotesFeed Class for subsribe or unsubsribe Quotes
15
+ */
16
+ constructor(feed) {
17
+ this.feed = feed;
18
+ }
19
+
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
+ //Reduced Quote
123
+
124
+ /**
125
+ * Reduced QutoesFeed RequestBody Structure
126
+ * Return Reduced QuotesFeed RequestBody Structure
127
+ * @function reducedQuotesFeedRequestBody
128
+ * @returns object
129
+ */
130
+ reducedQuoteRequestBody = () => {
131
+ return {
132
+ request: {
133
+ streaming_type: "quote",
134
+ data: {
135
+ "accType": "EQ",
136
+ symbols: [],
137
+ },
138
+ formFactor: configData.formFactor,
139
+ appID: configData.ApiIdKey,
140
+ response_format: "json",
141
+ request_type: "",
142
+ },
143
+ echo: {},
144
+ };
145
+ };
146
+ /**
147
+ * Create ReducedQuotesFeed RequestBody
148
+ * Return ReducedQuotesFeed RequestBody
149
+ * @function createReducedQuotesFeedRequest
150
+ * @param {Object[]} symbols - Array of subsribe Symbols
151
+ * @param {boolean} order - true for subsribe and false for unsubsribe
152
+ * @returns object
153
+ */
154
+ createReducedQuotesFeedRequest = (symbols, reducedQuote = false) => {
155
+ let body = {};
156
+ try {
157
+ body = this.reducedQuoteRequestBody();
158
+ const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
159
+
160
+ body.request.data.symbols = symset;
161
+
162
+ if (reducedQuote) {
163
+ body.request.request_type = "subscribe";
164
+ } else {
165
+ body.request.request_type = "unsubscribe";
166
+ }
167
+ } catch (error) {
168
+ log4js.debug("createReducedQuotesFeedRequest error - " + error);
169
+ } finally {
170
+ return body;
171
+ }
172
+ };
173
+
174
+ /**
175
+ * 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.
176
+ * @async
177
+ * @function subscribeReducedQuotesFeed
178
+ * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
179
+ * @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
180
+ * @returns
181
+ */
182
+ subscribeReducedQuotesFeed = async (symbols, callback) => {
183
+ try {
184
+ /** Validation Start */
185
+ const validateResponse = validateSubscribeReducedQuotesFeed(callback, symbols);
186
+
187
+ if (validateResponse.error) {
188
+ log4js.debug(
189
+ "subscribeReducedQuotesFeed validation error - " +
190
+ validateResponse.error.details
191
+ );
192
+ return Promise.reject(validateResponse.error.details);
193
+ }
194
+ /** Validation End */
195
+
196
+ /** Create Streaming Quote Request */
197
+ let reducedQuoteRequest = this.createReducedQuotesFeedRequest(symbols, true);
198
+ /** Call connect method of Feed Class */
199
+ this.feed.subsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest, callback);
200
+ } catch (error) {
201
+ log4js.debug("subscribeReducedQuotesFeed error - " + error);
202
+ console.log(error);
203
+ }
204
+ };
205
+
206
+ /**
207
+ * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
208
+ * @async
209
+ * @function unsubscribeReducedQuotesFeed
210
+ * @returns
211
+ */
212
+ unsubscribeReducedQuotesFeed = async () => {
213
+ try {
214
+ /** Get Streaming Reduced Quote Request */
215
+ const reducedQuoteRequest = this.createReducedQuotesFeedRequest([]);
216
+
217
+ /** Unsubsribe symbols */
218
+ this.feed.unsubsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest);
219
+ } catch (error) {
220
+ log4js.debug("unsubscribeReducedQuotesFeed error - " + error);
221
+ console.log(error);
222
+ }
223
+ };
224
+ }
225
+
226
+ module.exports = QuotesFeed;