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.
- package/README.md +30 -30
- package/conf/settings.ini +17 -20
- package/enums/actionType.js +10 -10
- package/enums/assetType.js +25 -25
- package/enums/chartExchangeType.js +16 -16
- package/enums/chartType.js +13 -13
- package/enums/eodIntervalType.js +11 -11
- package/enums/exchangeType.js +15 -15
- package/enums/intradayIntervalType.js +14 -14
- package/enums/marketCapType.js +12 -12
- package/enums/orderType.js +21 -21
- package/enums/productType.js +24 -24
- package/enums/segementsType.js +13 -13
- package/enums/segmentType.js +10 -10
- package/enums/streamingConstants.js +13 -13
- package/enums/termsType.js +12 -12
- package/enums/validity.js +22 -22
- package/index.js +3 -3
- package/package.json +25 -25
- package/src/apiConnect.js +2682 -2559
- package/src/apiUtils.js +221 -221
- package/src/chart.js +404 -404
- package/src/config.js +347 -342
- package/src/feed/depthFeed.js +136 -136
- package/src/feed/feed.js +170 -170
- package/src/feed/liveNewsFeed.js +112 -112
- package/src/feed/miniQuoteFeed.js +122 -121
- package/src/feed/ordersFeed.js +125 -124
- package/src/feed/quotesFeed.js +123 -122
- package/src/http.js +260 -197
- package/src/iniparser.js +45 -45
- package/src/liveNews.js +362 -362
- package/src/logger.js +16 -16
- package/src/order.js +48 -48
- package/src/quote.js +75 -75
- package/src/report.js +49 -49
- package/src/researchCalls.js +175 -175
- package/src/watchlist.js +378 -378
- package/validations/apiConnectValidator.js +701 -698
- package/validations/chartValidator.js +125 -125
- package/validations/feedStreamerValidator.js +162 -162
- package/validations/liveNewsValidator.js +60 -60
- package/validations/quoteValidator.js +19 -19
- package/validations/reportValidator.js +35 -35
- package/validations/researchCallsValidator.js +86 -86
- package/validations/watchlistValidator.js +60 -60
package/src/researchCalls.js
CHANGED
|
@@ -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;
|