api_connect_nodejs 2.0.13 → 2.0.14

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 (46) hide show
  1. package/README.md +30 -30
  2. package/conf/settings.ini +17 -20
  3. package/enums/actionType.js +10 -10
  4. package/enums/assetType.js +25 -25
  5. package/enums/chartExchangeType.js +16 -16
  6. package/enums/chartType.js +13 -13
  7. package/enums/eodIntervalType.js +11 -11
  8. package/enums/exchangeType.js +15 -15
  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/segmentType.js +10 -10
  15. package/enums/streamingConstants.js +13 -13
  16. package/enums/termsType.js +12 -12
  17. package/enums/validity.js +22 -22
  18. package/index.js +3 -3
  19. package/package.json +25 -25
  20. package/src/apiConnect.js +2682 -2559
  21. package/src/apiUtils.js +221 -221
  22. package/src/chart.js +404 -404
  23. package/src/config.js +347 -342
  24. package/src/feed/depthFeed.js +136 -136
  25. package/src/feed/feed.js +170 -170
  26. package/src/feed/liveNewsFeed.js +112 -112
  27. package/src/feed/miniQuoteFeed.js +122 -121
  28. package/src/feed/ordersFeed.js +125 -124
  29. package/src/feed/quotesFeed.js +123 -122
  30. package/src/http.js +260 -197
  31. package/src/iniparser.js +45 -45
  32. package/src/liveNews.js +362 -362
  33. package/src/logger.js +16 -16
  34. package/src/order.js +48 -48
  35. package/src/quote.js +75 -75
  36. package/src/report.js +49 -49
  37. package/src/researchCalls.js +175 -175
  38. package/src/watchlist.js +378 -378
  39. package/validations/apiConnectValidator.js +701 -698
  40. package/validations/chartValidator.js +125 -125
  41. package/validations/feedStreamerValidator.js +162 -162
  42. package/validations/liveNewsValidator.js +60 -60
  43. package/validations/quoteValidator.js +19 -19
  44. package/validations/reportValidator.js +35 -35
  45. package/validations/researchCallsValidator.js +86 -86
  46. package/validations/watchlistValidator.js +60 -60
@@ -1,112 +1,112 @@
1
- const log4js = require("../logger");
2
- const configData = require("../iniparser");
3
- const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
- const {
5
- validateStreamerCallback,
6
- } = require("../../validations/feedStreamerValidator");
7
-
8
- class LiveNewsFeed {
9
- /**
10
- * Streamer
11
- * LiveNewsFeed Class for subsribe or unsubsribe News
12
- */
13
- constructor(feed) {
14
- this.feed = feed;
15
- }
16
-
17
- /**
18
- * LiveNews Feed RequestBody Schema
19
- * @function liveNewsRequestBody
20
- * @returns object
21
- */
22
- requestBody = () => {
23
- return {
24
- request: {
25
- streaming_type: "news",
26
- formFactor: configData.formFactor,
27
- appID: configData.ApiIdKey,
28
- response_format: "json",
29
- request_type: "",
30
- },
31
- echo: {},
32
- };
33
- };
34
-
35
- /**
36
- * Create LiveNews Request Body
37
- * Returns liveNewsRequestBody
38
- * @function createLivenewsRequest
39
- * @param {boolean} subsribe - true for subsribe and false for unsubsribe
40
- * @returns object
41
- */
42
- createLivenewsRequest = (subscribe = false) => {
43
- let body = {};
44
- try {
45
- body = this.requestBody();
46
- if (subscribe) {
47
- body.request.request_type = "subscribe";
48
- } else {
49
- body.request.request_type = "unsubscribe";
50
- }
51
- } catch (error) {
52
- log4js.debug("createLivenewsRequest error - " + error);
53
- } finally {
54
- return body;
55
- }
56
- };
57
-
58
- /**
59
- * Subsribe LiveNews
60
- * 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.
61
- * @async
62
- * @function subscribeLiveNewsFeed
63
- * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
64
- * @returns
65
- */
66
- subscribeLiveNewsFeed = async (callback) => {
67
- try {
68
- /** Validation Start */
69
- const validateResponse = validateStreamerCallback(callback);
70
-
71
- if (validateResponse.error) {
72
- log4js.debug(
73
- "subscribeLiveNewsFeed validation error - " +
74
- validateResponse.error.details
75
- );
76
- return Promise.reject(validateResponse.error.details);
77
- }
78
- /** Validation End */
79
-
80
- /** Get LiveNews Request */
81
- const liveNewsRequest = this.createLivenewsRequest(true);
82
- /** Call connect method of Feed Class */
83
- this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
84
- } catch (error) {
85
- log4js.debug("subscribeLiveNewsFeed error - " + error);
86
- console.log(error);
87
- }
88
- };
89
-
90
- /**
91
- * Unsubsribe LiveNews Feed
92
- * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
93
- * @async
94
- * @function unsubscribeLiveNewsFeed
95
- * @param {Object[]} - Array of unsubsribe Symbols
96
- * @returns
97
- */
98
- unsubscribeLiveNewsFeed = async () => {
99
- try {
100
- /** Get LiveNews Request */
101
- const liveNewsRequest = this.createLivenewsRequest();
102
-
103
- /** Unsubscribe liveNews */
104
- this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
105
- } catch (error) {
106
- log4js.debug("unsubscribeLiveNews error - " + error);
107
- console.log(error);
108
- }
109
- };
110
- }
111
-
112
- module.exports = LiveNewsFeed;
1
+ const log4js = require("../logger");
2
+ const configData = require("../iniparser");
3
+ const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
+ const {
5
+ validateStreamerCallback,
6
+ } = require("../../validations/feedStreamerValidator");
7
+
8
+ class LiveNewsFeed {
9
+ /**
10
+ * Streamer
11
+ * LiveNewsFeed Class for subsribe or unsubsribe News
12
+ */
13
+ constructor(feed) {
14
+ this.feed = feed;
15
+ }
16
+
17
+ /**
18
+ * LiveNews Feed RequestBody Schema
19
+ * @function liveNewsRequestBody
20
+ * @returns object
21
+ */
22
+ requestBody = () => {
23
+ return {
24
+ request: {
25
+ streaming_type: "news",
26
+ formFactor: configData.formFactor,
27
+ appID: configData.ApiIdKey,
28
+ response_format: "json",
29
+ request_type: "",
30
+ },
31
+ echo: {},
32
+ };
33
+ };
34
+
35
+ /**
36
+ * Create LiveNews Request Body
37
+ * Returns liveNewsRequestBody
38
+ * @function createLivenewsRequest
39
+ * @param {boolean} subsribe - true for subsribe and false for unsubsribe
40
+ * @returns object
41
+ */
42
+ createLivenewsRequest = (subscribe = false) => {
43
+ let body = {};
44
+ try {
45
+ body = this.requestBody();
46
+ if (subscribe) {
47
+ body.request.request_type = "subscribe";
48
+ } else {
49
+ body.request.request_type = "unsubscribe";
50
+ }
51
+ } catch (error) {
52
+ log4js.debug("createLivenewsRequest error - " + error);
53
+ } finally {
54
+ return body;
55
+ }
56
+ };
57
+
58
+ /**
59
+ * Subsribe LiveNews
60
+ * 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.
61
+ * @async
62
+ * @function subscribeLiveNewsFeed
63
+ * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
64
+ * @returns
65
+ */
66
+ subscribeLiveNewsFeed = async (callback) => {
67
+ try {
68
+ /** Validation Start */
69
+ const validateResponse = validateStreamerCallback(callback);
70
+
71
+ if (validateResponse.error) {
72
+ log4js.debug(
73
+ "subscribeLiveNewsFeed validation error - " +
74
+ validateResponse.error.details
75
+ );
76
+ return Promise.reject(validateResponse.error.details);
77
+ }
78
+ /** Validation End */
79
+
80
+ /** Get LiveNews Request */
81
+ const liveNewsRequest = this.createLivenewsRequest(true);
82
+ /** Call connect method of Feed Class */
83
+ this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
84
+ } catch (error) {
85
+ log4js.debug("subscribeLiveNewsFeed error - " + error);
86
+ console.log(error);
87
+ }
88
+ };
89
+
90
+ /**
91
+ * Unsubsribe LiveNews Feed
92
+ * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
93
+ * @async
94
+ * @function unsubscribeLiveNewsFeed
95
+ * @param {Object[]} - Array of unsubsribe Symbols
96
+ * @returns
97
+ */
98
+ unsubscribeLiveNewsFeed = async () => {
99
+ try {
100
+ /** Get LiveNews Request */
101
+ const liveNewsRequest = this.createLivenewsRequest();
102
+
103
+ /** Unsubscribe liveNews */
104
+ this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
105
+ } catch (error) {
106
+ log4js.debug("unsubscribeLiveNews error - " + error);
107
+ console.log(error);
108
+ }
109
+ };
110
+ }
111
+
112
+ module.exports = LiveNewsFeed;
@@ -1,121 +1,122 @@
1
- const log4js = require("../logger");
2
- const configData = require("../iniparser");
3
- const { MINI_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
- const {
5
- validateSubscribeMiniQuoteFeed,
6
- validateUnsubscribeMiniQuoteFeed,
7
- } = require("../../validations/feedStreamerValidator");
8
-
9
- class MiniQuoteFeed {
10
- /**
11
- * Streamer
12
- * MiniQuoteFeed Class for subsribe or unsubsribe MiniQuote
13
- */
14
- constructor(feed) {
15
- this.feed = feed;
16
- }
17
-
18
- /**
19
- * QutoesFeed RequestBody Structure
20
- * Return MiniQuoteFeed RequestBody Structure
21
- * @function miniQuoteFeedRequestBody
22
- * @returns object
23
- */
24
- requestBody = () => {
25
- return {
26
- request: {
27
- streaming_type: "miniquote",
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 MiniQuoteFeed RequestBody
43
- * Return MiniQuoteFeed RequestBody
44
- * @function createMiniQuoteFeedRequest
45
- * @param {Object[]} symbols - Array of subsribe Symbols
46
- * @param {boolean} order - true for subsribe and false for unsubsribe
47
- * @returns object
48
- */
49
- createMiniQuoteFeedRequest = (symbols, miniQuote = 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 (miniQuote) {
58
- body.request.request_type = "subscribe";
59
- } else {
60
- body.request.request_type = "unsubscribe";
61
- }
62
- } catch (error) {
63
- log4js.debug("createMiniQuoteFeedRequest 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 subscribeMiniQuoteFeed
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
- subscribeMiniQuoteFeed = async (symbols, callback) => {
78
- try {
79
- /** Validation Start */
80
- const validateResponse = validateSubscribeMiniQuoteFeed(callback, symbols);
81
-
82
- if (validateResponse.error) {
83
- log4js.debug(
84
- "subscribeMiniQuoteFeed validation error - " +
85
- validateResponse.error.details
86
- );
87
- return Promise.reject(validateResponse.error.details);
88
- }
89
- /** Validation End */
90
-
91
- /** Create Streaming MiniQuote Request */
92
- let miniQuoteRequest = this.createMiniQuoteFeedRequest(symbols, true);
93
- /** Call connect method of Feed Class */
94
- this.feed.subsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest, callback);
95
- } catch (error) {
96
- log4js.debug("subscribeMiniQuoteFeed 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 unsubscribeMiniQuoteFeed
105
- * @returns
106
- */
107
- unsubscribeMiniQuoteFeed = async () => {
108
- try {
109
- /** Get Streaming MiniQuote Request */
110
- const miniQuoteRequest = this.createMiniQuoteFeedRequest([]);
111
-
112
- /** Unsubsribe symbols */
113
- this.feed.unsubsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest);
114
- } catch (error) {
115
- log4js.debug("unsubscribeMiniQuoteFeed error - " + error);
116
- console.log(error);
117
- }
118
- };
119
- }
120
-
121
- module.exports = MiniQuoteFeed;
1
+ const log4js = require("../logger");
2
+ const configData = require("../iniparser");
3
+ const { MINI_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
4
+ const {
5
+ validateSubscribeMiniQuoteFeed,
6
+ validateUnsubscribeMiniQuoteFeed,
7
+ } = require("../../validations/feedStreamerValidator");
8
+
9
+ class MiniQuoteFeed {
10
+ /**
11
+ * Streamer
12
+ * MiniQuoteFeed Class for subsribe or unsubsribe MiniQuote
13
+ */
14
+ constructor(feed, constantsObj) {
15
+ this.feed = feed;
16
+ this.constants = constantsObj;
17
+ }
18
+
19
+ /**
20
+ * QutoesFeed RequestBody Structure
21
+ * Return MiniQuoteFeed RequestBody Structure
22
+ * @function miniQuoteFeedRequestBody
23
+ * @returns object
24
+ */
25
+ requestBody = () => {
26
+ return {
27
+ request: {
28
+ streaming_type: "miniquote",
29
+ data: {
30
+ "accType": this.constants.Data.data.lgnData.accTyp,//"EQ",
31
+ symbols: [],
32
+ },
33
+ formFactor: configData.formFactor,
34
+ appID: configData.ApiIdKey,
35
+ response_format: "json",
36
+ request_type: "",
37
+ },
38
+ echo: {},
39
+ };
40
+ };
41
+
42
+ /**
43
+ * Create MiniQuoteFeed RequestBody
44
+ * Return MiniQuoteFeed RequestBody
45
+ * @function createMiniQuoteFeedRequest
46
+ * @param {Object[]} symbols - Array of subsribe Symbols
47
+ * @param {boolean} order - true for subsribe and false for unsubsribe
48
+ * @returns object
49
+ */
50
+ createMiniQuoteFeedRequest = (symbols, miniQuote = false) => {
51
+ let body = {};
52
+ try {
53
+ body = this.requestBody();
54
+ const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
55
+
56
+ body.request.data.symbols = symset;
57
+
58
+ if (miniQuote) {
59
+ body.request.request_type = "subscribe";
60
+ } else {
61
+ body.request.request_type = "unsubscribe";
62
+ }
63
+ } catch (error) {
64
+ log4js.debug("createMiniQuoteFeedRequest error - " + error);
65
+ } finally {
66
+ return body;
67
+ }
68
+ };
69
+
70
+ /**
71
+ * 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.
72
+ * @async
73
+ * @function subscribeMiniQuoteFeed
74
+ * @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
75
+ * @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
76
+ * @returns
77
+ */
78
+ subscribeMiniQuoteFeed = async (symbols, callback) => {
79
+ try {
80
+ /** Validation Start */
81
+ const validateResponse = validateSubscribeMiniQuoteFeed(callback, symbols);
82
+
83
+ if (validateResponse.error) {
84
+ log4js.debug(
85
+ "subscribeMiniQuoteFeed validation error - " +
86
+ validateResponse.error.details
87
+ );
88
+ return Promise.reject(validateResponse.error.details);
89
+ }
90
+ /** Validation End */
91
+
92
+ /** Create Streaming MiniQuote Request */
93
+ let miniQuoteRequest = this.createMiniQuoteFeedRequest(symbols, true);
94
+ /** Call connect method of Feed Class */
95
+ this.feed.subsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest, callback);
96
+ } catch (error) {
97
+ log4js.debug("subscribeMiniQuoteFeed error - " + error);
98
+ console.log(error);
99
+ }
100
+ };
101
+
102
+ /**
103
+ * This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
104
+ * @async
105
+ * @function unsubscribeMiniQuoteFeed
106
+ * @returns
107
+ */
108
+ unsubscribeMiniQuoteFeed = async () => {
109
+ try {
110
+ /** Get Streaming MiniQuote Request */
111
+ const miniQuoteRequest = this.createMiniQuoteFeedRequest([]);
112
+
113
+ /** Unsubsribe symbols */
114
+ this.feed.unsubsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest);
115
+ } catch (error) {
116
+ log4js.debug("unsubscribeMiniQuoteFeed error - " + error);
117
+ console.log(error);
118
+ }
119
+ };
120
+ }
121
+
122
+ module.exports = MiniQuoteFeed;