api_connect_nodejs 2.0.2 → 2.0.4

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 (39) 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 +11 -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 +2342 -2430
  20. package/src/apiUtils.js +221 -129
  21. package/src/chart.js +258 -258
  22. package/src/config.js +316 -326
  23. package/src/feed/feed.js +139 -139
  24. package/src/feed/liveNewsFeed.js +112 -112
  25. package/src/feed/ordersFeed.js +124 -124
  26. package/src/feed/quotesFeed.js +121 -121
  27. package/src/http.js +197 -197
  28. package/src/iniparser.js +42 -42
  29. package/src/liveNews.js +362 -362
  30. package/src/logger.js +16 -16
  31. package/src/order.js +48 -48
  32. package/src/researchCalls.js +175 -175
  33. package/src/watchlist.js +378 -378
  34. package/validations/apiConnectValidator.js +521 -508
  35. package/validations/chartValidator.js +85 -85
  36. package/validations/feedStreamerValidator.js +68 -68
  37. package/validations/liveNewsValidator.js +60 -60
  38. package/validations/researchCallsValidator.js +86 -86
  39. package/validations/watchlistValidator.js +60 -60
package/src/logger.js CHANGED
@@ -1,16 +1,16 @@
1
- const log4js = require("log4js");
2
- const configData = require("./iniparser.js");
3
-
4
- // Logger configuration
5
- log4js.configure({
6
- appenders: { fileAppender: { type: "file", filename: "./logs/APIConnect.log" } },
7
- categories: {
8
- default: { appenders: ["fileAppender"], level: configData.LogLevel },
9
- },
10
- });
11
-
12
- // Create the logger
13
- const logger = log4js.getLogger();
14
-
15
- // Log a message
16
- module.exports = logger;
1
+ const log4js = require("log4js");
2
+ const configData = require("./iniparser.js");
3
+
4
+ // Logger configuration
5
+ log4js.configure({
6
+ appenders: { fileAppender: { type: "file", filename: "./logs/APIConnect.log" } },
7
+ categories: {
8
+ default: { appenders: ["fileAppender"], level: configData.LogLevel },
9
+ },
10
+ });
11
+
12
+ // Create the logger
13
+ const logger = log4js.getLogger();
14
+
15
+ // Log a message
16
+ module.exports = logger;
package/src/order.js CHANGED
@@ -1,48 +1,48 @@
1
- class Order {
2
- /**
3
- * @param {string} Exchange Exchange of the scrip
4
- * @param {string} TradingSymbol Trading Symbol, to be obtained from Contract Notes
5
- * @param {string} StreamingSymbol ScripCode_exchange
6
- * @param {'BUY' | 'SELL'} Action BUY | SELL
7
- * @param {'CNC' | 'MIS' | 'NRML'} ProductCode CNC | MIS | NRML
8
- * @param {'LIMIT' | 'MARKET'} OrderType LIMIT | MARKET
9
- * @param {'DAY' | 'IOC'} Duration Validity DAY | IOC
10
- * @param {string} Price Limit price of the scrip
11
- * @param {string} TriggerPrice Trigger Price in case of SL/SL-M Order
12
- * @param {number} Quantity Quantity of scrip to be purchansed
13
- * @param {string} DisclosedQuantity Disclosed Quantity for the Order
14
- * @param {string} GTDDate Good Till Date in dd/MM/yyyy format
15
- * @param {string} Remark Remark
16
- */
17
- constructor(
18
- Exchange,
19
- TradingSymbol,
20
- StreamingSymbol,
21
- Action,
22
- ProductCode,
23
- OrderType,
24
- Duration,
25
- Price,
26
- TriggerPrice,
27
- Quantity,
28
- DisclosedQuantity,
29
- GTDDate,
30
- Remark
31
- ) {
32
- this.trdSym = TradingSymbol;
33
- this.exc = Exchange;
34
- this.action = Action;
35
- this.dur = Duration;
36
- this.ordTyp = OrderType;
37
- this.qty = Quantity;
38
- this.dscQty = DisclosedQuantity;
39
- this.sym = StreamingSymbol;
40
- this.price = Price;
41
- this.trgPrc = TriggerPrice;
42
- this.prdCode = ProductCode;
43
- this.GTDDate = GTDDate;
44
- this.rmk = Remark;
45
- }
46
- }
47
-
48
- module.exports = Order;
1
+ class Order {
2
+ /**
3
+ * @param {string} Exchange Exchange of the scrip
4
+ * @param {string} TradingSymbol Trading Symbol, to be obtained from Contract Notes
5
+ * @param {string} StreamingSymbol ScripCode_exchange
6
+ * @param {'BUY' | 'SELL'} Action BUY | SELL
7
+ * @param {'CNC' | 'MIS' | 'NRML'} ProductCode CNC | MIS | NRML
8
+ * @param {'LIMIT' | 'MARKET'} OrderType LIMIT | MARKET
9
+ * @param {'DAY' | 'IOC'} Duration Validity DAY | IOC
10
+ * @param {string} Price Limit price of the scrip
11
+ * @param {string} TriggerPrice Trigger Price in case of SL/SL-M Order
12
+ * @param {number} Quantity Quantity of scrip to be purchansed
13
+ * @param {string} DisclosedQuantity Disclosed Quantity for the Order
14
+ * @param {string} GTDDate Good Till Date in dd/MM/yyyy format
15
+ * @param {string} Remark Remark
16
+ */
17
+ constructor(
18
+ Exchange,
19
+ TradingSymbol,
20
+ StreamingSymbol,
21
+ Action,
22
+ ProductCode,
23
+ OrderType,
24
+ Duration,
25
+ Price,
26
+ TriggerPrice,
27
+ Quantity,
28
+ DisclosedQuantity,
29
+ GTDDate,
30
+ Remark
31
+ ) {
32
+ this.trdSym = TradingSymbol;
33
+ this.exc = Exchange;
34
+ this.action = Action;
35
+ this.dur = Duration;
36
+ this.ordTyp = OrderType;
37
+ this.qty = Quantity;
38
+ this.dscQty = DisclosedQuantity;
39
+ this.sym = StreamingSymbol;
40
+ this.price = Price;
41
+ this.trgPrc = TriggerPrice;
42
+ this.prdCode = ProductCode;
43
+ this.GTDDate = GTDDate;
44
+ this.rmk = Remark;
45
+ }
46
+ }
47
+
48
+ module.exports = Order;
@@ -1,175 +1,175 @@
1
- const log4js = require("./logger.js");
2
- const {
3
- validateActiveResearchCalls,
4
- validateClosedResearchCalls,
5
- } = require("../validations/researchCallsValidator");
6
- class ResearchCalls {
7
- constructor(http, config, constants) {
8
- this.__http = http;
9
- this.__config = config;
10
- this.__constants = constants;
11
- }
12
-
13
- //Return Response
14
- formattedResponse = (res) => {
15
- let response = {};
16
- response["msgID"] = res.msgID;
17
- response["srvTm"] = res.srvTm;
18
- response["data"] = res.data;
19
- if (res.hasOwnProperty("error")) {
20
- response["error"] = res.error;
21
- } else {
22
- response["data"] = res.data;
23
- }
24
- return response;
25
- };
26
-
27
- filterByMarketCap = (response, marketCap) => {
28
- let filterData = {};
29
- try {
30
- if (response.hasOwnProperty("data")) {
31
- const data = response.data;
32
- if (data.hasOwnProperty("lst")) {
33
- const lst = data.lst;
34
- let filterLst = lst.filter((element) => {
35
- if (element.hasOwnProperty("cap") && element.cap === marketCap) {
36
- return element;
37
- }
38
- });
39
- data.lst = filterLst;
40
- }
41
- response.data = data;
42
- filterData = response;
43
- }
44
- } catch (error) {
45
- console.log(error);
46
- }
47
- return filterData;
48
- };
49
-
50
- /**
51
- * Get all active research calls
52
- * @async
53
- * @function getActiveResearchCalls
54
- * @param {EQ | FNO | CUR | COM} segment - Segment can be EQ | FNO | CUR | COM
55
- * @param {LONGTERM | SHORTTERM | MIDTERM} term can be LONGTERM | SHORTTERM | MIDTERM
56
- * @param {Large | Medium | Small} marketCap - MarketCap can be Large | Medium | Small, Only For Segment "ËQ"
57
- * @returns
58
- */
59
- getActiveResearchCalls = async (segment, terms, marketCap = null) => {
60
- let activeResearchCalls = {};
61
- try {
62
- //Convert null string into null object
63
- if(marketCap.toLowerCase() === 'null') {
64
- marketCap = null;
65
- }
66
-
67
- /**
68
- * Validate Active ResearchCalls URL Params
69
- */
70
- const validateParamsResponse = validateActiveResearchCalls(
71
- segment,
72
- terms,
73
- marketCap
74
- );
75
- if (validateParamsResponse.error) {
76
- log4js.debug(
77
- "ActiveResearchCalls Url Params error - " +
78
- validateParamsResponse.error.details
79
- );
80
- return Promise.reject(validateParamsResponse.error.details);
81
- }
82
-
83
- const url = this.__config.activeResearchCallsUrl(segment, terms);
84
-
85
- const response = await this.__http.GetMethod(url);
86
-
87
- /**
88
- * Data Filter will be execute If-
89
- * 1. MarketCap value should not be null or empty string.
90
- */
91
- activeResearchCalls = !this.__constants.isEmptyNullString(marketCap)
92
- ? this.filterByMarketCap(response, marketCap)
93
- : response;
94
- } catch (error) {
95
- log4js.debug("getActiveResearchCalls error - " + error);
96
- }
97
- return this.formattedResponse(activeResearchCalls);
98
- };
99
-
100
- /**
101
- * Get closed research calls
102
- * @async
103
- * @function getCloseResearchCalls
104
- * @param {EQ | FNO | CUR | COM} segment - Segment can be EQ | FNO | CUR | COM
105
- * @param {LONGTERM | SHORTTERM | MIDTERM} terms - Terms can be LONGTERM | SHORTTERM | MIDTERM
106
- * @param {BUY | SELL} action - action can be BUY | SELL
107
- * @param {string} fromDate -Filtering fromDate. In format : YYYY-MM-dd
108
- * @param {string} toDate - Filtering toDate. In format : YYYY-MM-dd
109
- * @param {string} recommendationType - Filtering based on recommendation type
110
- * @param {Large | Medium | Small} marketCap - MarketCap can be Large | Medium | Small, Only For Segment "ËQ"
111
- * @returns
112
- */
113
- getClosedResearchCalls = async (
114
- segment,
115
- term,
116
- action,
117
- fromDate,
118
- toDate,
119
- recommendationType,
120
- marketCap = null
121
- ) => {
122
- let closedResearchCalls = {};
123
- try {
124
- //Convert null string into null object
125
- if(marketCap.toLowerCase() === 'null') {
126
- marketCap = null;
127
- }
128
-
129
- /**
130
- * Validate Closed ResearchCalls URL Params
131
- */
132
- const validateParamsResponse = validateClosedResearchCalls(
133
- segment,
134
- term,
135
- action,
136
- fromDate,
137
- toDate,
138
- recommendationType,
139
- marketCap
140
- );
141
- if (validateParamsResponse.error) {
142
- log4js.debug(
143
- "ClosedResearchCalls Url Params error - " +
144
- validateParamsResponse.error.details
145
- );
146
- return Promise.reject(validateParamsResponse.error.details);
147
- }
148
-
149
- const url = this.__config.closedResearchCallsUrl(
150
- segment,
151
- term,
152
- action,
153
- fromDate,
154
- toDate,
155
- recommendationType,
156
- marketCap
157
- );
158
-
159
- const response = await this.__http.GetMethod(url);
160
-
161
- /**
162
- * Data Filter will be execute If-
163
- * 1. MarketCap value should not be null or empty string.
164
- */
165
- closedResearchCalls = !this.__constants.isEmptyNullString(marketCap)
166
- ? this.filterByMarketCap(response, marketCap)
167
- : response;
168
- } catch (error) {
169
- log4js.debug("getClosedResearchCalls error - " + error);
170
- }
171
- return this.formattedResponse(closedResearchCalls);
172
- };
173
- }
174
-
175
- module.exports = ResearchCalls;
1
+ const log4js = require("./logger.js");
2
+ const {
3
+ validateActiveResearchCalls,
4
+ validateClosedResearchCalls,
5
+ } = require("../validations/researchCallsValidator");
6
+ class ResearchCalls {
7
+ constructor(http, config, constants) {
8
+ this.__http = http;
9
+ this.__config = config;
10
+ this.__constants = constants;
11
+ }
12
+
13
+ //Return Response
14
+ formattedResponse = (res) => {
15
+ let response = {};
16
+ response["msgID"] = res.msgID;
17
+ response["srvTm"] = res.srvTm;
18
+ response["data"] = res.data;
19
+ if (res.hasOwnProperty("error")) {
20
+ response["error"] = res.error;
21
+ } else {
22
+ response["data"] = res.data;
23
+ }
24
+ return response;
25
+ };
26
+
27
+ filterByMarketCap = (response, marketCap) => {
28
+ let filterData = {};
29
+ try {
30
+ if (response.hasOwnProperty("data")) {
31
+ const data = response.data;
32
+ if (data.hasOwnProperty("lst")) {
33
+ const lst = data.lst;
34
+ let filterLst = lst.filter((element) => {
35
+ if (element.hasOwnProperty("cap") && element.cap === marketCap) {
36
+ return element;
37
+ }
38
+ });
39
+ data.lst = filterLst;
40
+ }
41
+ response.data = data;
42
+ filterData = response;
43
+ }
44
+ } catch (error) {
45
+ console.log(error);
46
+ }
47
+ return filterData;
48
+ };
49
+
50
+ /**
51
+ * Get all active research calls
52
+ * @async
53
+ * @function getActiveResearchCalls
54
+ * @param {EQ | FNO | CUR | COM} segment - Segment can be EQ | FNO | CUR | COM
55
+ * @param {LONGTERM | SHORTTERM | MIDTERM} term can be LONGTERM | SHORTTERM | MIDTERM
56
+ * @param {Large | Medium | Small} marketCap - MarketCap can be Large | Medium | Small, Only For Segment "ËQ"
57
+ * @returns
58
+ */
59
+ getActiveResearchCalls = async (segment, terms, marketCap = null) => {
60
+ let activeResearchCalls = {};
61
+ try {
62
+ //Convert null string into null object
63
+ if(marketCap.toLowerCase() === 'null') {
64
+ marketCap = null;
65
+ }
66
+
67
+ /**
68
+ * Validate Active ResearchCalls URL Params
69
+ */
70
+ const validateParamsResponse = validateActiveResearchCalls(
71
+ segment,
72
+ terms,
73
+ marketCap
74
+ );
75
+ if (validateParamsResponse.error) {
76
+ log4js.debug(
77
+ "ActiveResearchCalls Url Params error - " +
78
+ validateParamsResponse.error.details
79
+ );
80
+ return Promise.reject(validateParamsResponse.error.details);
81
+ }
82
+
83
+ const url = this.__config.activeResearchCallsUrl(segment, terms);
84
+
85
+ const response = await this.__http.GetMethod(url);
86
+
87
+ /**
88
+ * Data Filter will be execute If-
89
+ * 1. MarketCap value should not be null or empty string.
90
+ */
91
+ activeResearchCalls = !this.__constants.isEmptyNullString(marketCap)
92
+ ? this.filterByMarketCap(response, marketCap)
93
+ : response;
94
+ } catch (error) {
95
+ log4js.debug("getActiveResearchCalls error - " + error);
96
+ }
97
+ return this.formattedResponse(activeResearchCalls);
98
+ };
99
+
100
+ /**
101
+ * Get closed research calls
102
+ * @async
103
+ * @function getCloseResearchCalls
104
+ * @param {EQ | FNO | CUR | COM} segment - Segment can be EQ | FNO | CUR | COM
105
+ * @param {LONGTERM | SHORTTERM | MIDTERM} terms - Terms can be LONGTERM | SHORTTERM | MIDTERM
106
+ * @param {BUY | SELL} action - action can be BUY | SELL
107
+ * @param {string} fromDate -Filtering fromDate. In format : YYYY-MM-dd
108
+ * @param {string} toDate - Filtering toDate. In format : YYYY-MM-dd
109
+ * @param {string} recommendationType - Filtering based on recommendation type
110
+ * @param {Large | Medium | Small} marketCap - MarketCap can be Large | Medium | Small, Only For Segment "ËQ"
111
+ * @returns
112
+ */
113
+ getClosedResearchCalls = async (
114
+ segment,
115
+ term,
116
+ action,
117
+ fromDate,
118
+ toDate,
119
+ recommendationType,
120
+ marketCap = null
121
+ ) => {
122
+ let closedResearchCalls = {};
123
+ try {
124
+ //Convert null string into null object
125
+ if(marketCap.toLowerCase() === 'null') {
126
+ marketCap = null;
127
+ }
128
+
129
+ /**
130
+ * Validate Closed ResearchCalls URL Params
131
+ */
132
+ const validateParamsResponse = validateClosedResearchCalls(
133
+ segment,
134
+ term,
135
+ action,
136
+ fromDate,
137
+ toDate,
138
+ recommendationType,
139
+ marketCap
140
+ );
141
+ if (validateParamsResponse.error) {
142
+ log4js.debug(
143
+ "ClosedResearchCalls Url Params error - " +
144
+ validateParamsResponse.error.details
145
+ );
146
+ return Promise.reject(validateParamsResponse.error.details);
147
+ }
148
+
149
+ const url = this.__config.closedResearchCallsUrl(
150
+ segment,
151
+ term,
152
+ action,
153
+ fromDate,
154
+ toDate,
155
+ recommendationType,
156
+ marketCap
157
+ );
158
+
159
+ const response = await this.__http.GetMethod(url);
160
+
161
+ /**
162
+ * Data Filter will be execute If-
163
+ * 1. MarketCap value should not be null or empty string.
164
+ */
165
+ closedResearchCalls = !this.__constants.isEmptyNullString(marketCap)
166
+ ? this.filterByMarketCap(response, marketCap)
167
+ : response;
168
+ } catch (error) {
169
+ log4js.debug("getClosedResearchCalls error - " + error);
170
+ }
171
+ return this.formattedResponse(closedResearchCalls);
172
+ };
173
+ }
174
+
175
+ module.exports = ResearchCalls;