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.
- package/README.md +30 -30
- package/conf/settings.ini +19 -19
- package/enums/actionType.js +10 -10
- package/enums/assetType.js +25 -25
- package/enums/chartExchangeType.js +15 -15
- package/enums/chartType.js +13 -13
- package/enums/eodIntervalType.js +11 -11
- package/enums/exchangeType.js +14 -14
- 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/streamingConstants.js +14 -11
- 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 +2397 -2430
- package/src/apiUtils.js +221 -129
- package/src/chart.js +258 -258
- package/src/config.js +321 -326
- package/src/feed/depthFeed.js +137 -0
- package/src/feed/feed.js +162 -139
- package/src/feed/liveNewsFeed.js +112 -112
- package/src/feed/miniQuoteFeed.js +121 -0
- package/src/feed/ordersFeed.js +124 -124
- package/src/feed/quotesFeed.js +226 -121
- package/src/http.js +197 -197
- package/src/iniparser.js +42 -42
- package/src/liveNews.js +362 -362
- package/src/logger.js +16 -16
- package/src/order.js +48 -48
- package/src/quote.js +75 -0
- package/src/researchCalls.js +175 -175
- package/src/watchlist.js +378 -378
- package/validations/apiConnectValidator.js +521 -508
- package/validations/chartValidator.js +85 -85
- package/validations/feedStreamerValidator.js +162 -68
- package/validations/liveNewsValidator.js +60 -60
- package/validations/quoteValidator.js +19 -0
- package/validations/researchCallsValidator.js +86 -86
- 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;
|
package/src/quote.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const log4js = require("./logger.js");
|
|
2
|
+
const {
|
|
3
|
+
validateMarketDepth,
|
|
4
|
+
} = require("../validations/quoteValidator");
|
|
5
|
+
|
|
6
|
+
class Quote {
|
|
7
|
+
constructor(http, config, constants) {
|
|
8
|
+
this.__http = http;
|
|
9
|
+
this.__config = config;
|
|
10
|
+
this.__constants = constants;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Modifying the response
|
|
14
|
+
*/
|
|
15
|
+
modifyResponse = async (response) => {
|
|
16
|
+
try {
|
|
17
|
+
const modifiedResponse = {};
|
|
18
|
+
let msgID = "";
|
|
19
|
+
let srvTm = "";
|
|
20
|
+
if (Object.keys(response).length !== 0) {
|
|
21
|
+
msgID = response["msgID"];
|
|
22
|
+
srvTm = response["srvTm"];
|
|
23
|
+
const data = response.data;
|
|
24
|
+
const mkd = data.mkd;
|
|
25
|
+
modifiedResponse["data"] = mkd;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
modifiedResponse["msgID"] = msgID;
|
|
29
|
+
modifiedResponse["srvTm"] = srvTm;
|
|
30
|
+
log4js.debug("modifiedResponse :" + JSON.stringify(modifiedResponse));
|
|
31
|
+
return modifiedResponse;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return Promise.reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {string} symbol
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
getMarketDepthAPI = async (symbol) => {
|
|
43
|
+
let result = {};
|
|
44
|
+
try {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validate market depth params
|
|
48
|
+
*/
|
|
49
|
+
const validateResponse = validateMarketDepth(
|
|
50
|
+
symbol,
|
|
51
|
+
);
|
|
52
|
+
if (validateResponse.error) {
|
|
53
|
+
log4js.debug(
|
|
54
|
+
"market depth validation error - " + validateResponse.error.details
|
|
55
|
+
);
|
|
56
|
+
return Promise.reject(validateResponse.error.details);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const url = this.__config.MarketDepthURL(symbol);
|
|
60
|
+
log4js.debug("market depth URL -" + url);
|
|
61
|
+
const response = await this.__http.GetMethod(url, false);
|
|
62
|
+
|
|
63
|
+
if (result.length !== 0) {
|
|
64
|
+
result = this.modifyResponse(response);
|
|
65
|
+
} else {
|
|
66
|
+
result = response;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
log4js.debug("Market depth error - " + error);
|
|
71
|
+
return Promise.reject(error);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
module.exports = Quote;
|
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;
|