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/chart.js
CHANGED
|
@@ -1,258 +1,258 @@
|
|
|
1
|
-
const log4js = require("./logger.js");
|
|
2
|
-
const { futureAssetType } = require("../enums/assetType");
|
|
3
|
-
const {
|
|
4
|
-
validateChartIntraday,
|
|
5
|
-
validateChartEOD,
|
|
6
|
-
} = require("../validations/chartValidator");
|
|
7
|
-
|
|
8
|
-
class Chart {
|
|
9
|
-
constructor(http, config, constants) {
|
|
10
|
-
this.__http = http;
|
|
11
|
-
this.__config = config;
|
|
12
|
-
this.__constants = constants;
|
|
13
|
-
}
|
|
14
|
-
checkResponseHaveArrayOrNot = (pltPnts) => {
|
|
15
|
-
if (
|
|
16
|
-
Array.isArray(pltPnts.ltt) &&
|
|
17
|
-
Array.isArray(pltPnts.open) &&
|
|
18
|
-
Array.isArray(pltPnts.high) &&
|
|
19
|
-
Array.isArray(pltPnts.low) &&
|
|
20
|
-
Array.isArray(pltPnts.close) &&
|
|
21
|
-
Array.isArray(pltPnts.vol)
|
|
22
|
-
) {
|
|
23
|
-
return true;
|
|
24
|
-
} else {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Modifying the response
|
|
30
|
-
*/
|
|
31
|
-
modifyResponse = async (response) => {
|
|
32
|
-
try {
|
|
33
|
-
const modifyResponse = {};
|
|
34
|
-
let msgID = "";
|
|
35
|
-
let srvTm = "";
|
|
36
|
-
let nextTillDate = "";
|
|
37
|
-
const charts = [];
|
|
38
|
-
if (Object.keys(response).length !== 0) {
|
|
39
|
-
msgID = response["msgID"];
|
|
40
|
-
srvTm = response["srvTm"];
|
|
41
|
-
const data = response.data;
|
|
42
|
-
const pltPnts = data.pltPnts;
|
|
43
|
-
if (
|
|
44
|
-
Object.keys(data).length !== 0 &&
|
|
45
|
-
Object.keys(pltPnts).length !== 0
|
|
46
|
-
) {
|
|
47
|
-
const isArray = await this.checkResponseHaveArrayOrNot(pltPnts);
|
|
48
|
-
if (isArray && pltPnts.ltt.length > 0) {
|
|
49
|
-
modifyResponse["nextTillDate"] = pltPnts.ltt[0];
|
|
50
|
-
for (let i = 0; i < pltPnts.ltt.length; i++) {
|
|
51
|
-
const dataArray = [];
|
|
52
|
-
dataArray[0] = pltPnts.ltt[i];
|
|
53
|
-
dataArray[1] = pltPnts.open[i];
|
|
54
|
-
dataArray[2] = pltPnts.high[i];
|
|
55
|
-
dataArray[3] = pltPnts.low[i];
|
|
56
|
-
dataArray[4] = pltPnts.close[i];
|
|
57
|
-
dataArray[5] = pltPnts.vol[i];
|
|
58
|
-
charts.push(dataArray);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
modifyResponse["data"] = charts;
|
|
65
|
-
modifyResponse["msgID"] = msgID;
|
|
66
|
-
modifyResponse["srvTm"] = srvTm;
|
|
67
|
-
log4js.debug("modifyResponse :" + JSON.stringify(modifyResponse));
|
|
68
|
-
return modifyResponse;
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return Promise.reject(e);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
convertToBoolean = async (value) => {
|
|
75
|
-
if (value === "TRUE" || value === "true") {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
if (value === "FALSE" || value === "false") {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//Chart RequestBody
|
|
84
|
-
chartRequestBody = () => {
|
|
85
|
-
return {
|
|
86
|
-
conti: false, // By default set as false
|
|
87
|
-
chTyp: "Interval", // By default set as Interval
|
|
88
|
-
ltt: null, // By default set as null
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
|
|
95
|
-
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
96
|
-
* @param {string} symbol
|
|
97
|
-
* @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
98
|
-
* @param {string} tillDate
|
|
99
|
-
* @param {boolean} includeContinuousFuture
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
getIntradayChartAPI = async (
|
|
103
|
-
interval,
|
|
104
|
-
assetType,
|
|
105
|
-
symbol,
|
|
106
|
-
exchangeType,
|
|
107
|
-
tillDate,
|
|
108
|
-
includeContinuousFuture
|
|
109
|
-
) => {
|
|
110
|
-
let result = {};
|
|
111
|
-
try {
|
|
112
|
-
//Convert into boolean
|
|
113
|
-
includeContinuousFuture = await this.convertToBoolean(
|
|
114
|
-
includeContinuousFuture
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
//Convert null string into null object
|
|
118
|
-
if (tillDate.toLowerCase() === "null") {
|
|
119
|
-
tillDate = null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Validate intraday chart params
|
|
124
|
-
*/
|
|
125
|
-
const validateResponse = validateChartIntraday(
|
|
126
|
-
interval,
|
|
127
|
-
assetType,
|
|
128
|
-
symbol,
|
|
129
|
-
exchangeType,
|
|
130
|
-
tillDate,
|
|
131
|
-
includeContinuousFuture
|
|
132
|
-
);
|
|
133
|
-
if (validateResponse.error) {
|
|
134
|
-
log4js.debug(
|
|
135
|
-
"intraday validation error - " + validateResponse.error.details
|
|
136
|
-
);
|
|
137
|
-
return Promise.reject(validateResponse.error.details);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
//Request Body
|
|
141
|
-
let requestBodyData = this.chartRequestBody();
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* If AssetType Amongst FUTIDX, FUTSTK,FUTCUR,FUTCOM then we take user input(includeContinuousFuture) otherwise set false
|
|
145
|
-
*/
|
|
146
|
-
if (!Object.values(futureAssetType).includes(assetType)) {
|
|
147
|
-
includeContinuousFuture = false;
|
|
148
|
-
} else {
|
|
149
|
-
requestBodyData.conti = includeContinuousFuture;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
requestBodyData.ltt = tillDate;
|
|
153
|
-
|
|
154
|
-
const url = this.__config.ChartURL(
|
|
155
|
-
interval,
|
|
156
|
-
exchangeType,
|
|
157
|
-
assetType,
|
|
158
|
-
symbol
|
|
159
|
-
);
|
|
160
|
-
log4js.debug("intraday URL -" + url);
|
|
161
|
-
|
|
162
|
-
const response = await this.__http.PostMethod(url, requestBodyData);
|
|
163
|
-
if (result.length !== 0) {
|
|
164
|
-
result = this.modifyResponse(response);
|
|
165
|
-
} else {
|
|
166
|
-
result = response;
|
|
167
|
-
}
|
|
168
|
-
return result;
|
|
169
|
-
} catch (error) {
|
|
170
|
-
log4js.debug("intraday error - " + error);
|
|
171
|
-
return Promise.reject(error);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* @param {"D1" | "W1" | "MN1"} interval
|
|
178
|
-
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
179
|
-
* @param {string} symbol
|
|
180
|
-
* @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
181
|
-
* @param {string} tillDate yyyy-MM-dd
|
|
182
|
-
* @param {boolean} includeContinuousFuture
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
getEODChartAPI = async (
|
|
186
|
-
interval,
|
|
187
|
-
assetType,
|
|
188
|
-
symbol,
|
|
189
|
-
exchangeType,
|
|
190
|
-
tillDate,
|
|
191
|
-
includeContinuousFuture
|
|
192
|
-
) => {
|
|
193
|
-
let result = {};
|
|
194
|
-
try {
|
|
195
|
-
//Convert into boolean
|
|
196
|
-
includeContinuousFuture = await this.convertToBoolean(
|
|
197
|
-
includeContinuousFuture
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
//Convert null string into null object
|
|
201
|
-
if (tillDate.toLowerCase() === "null") {
|
|
202
|
-
tillDate = null;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Validate eod chart params
|
|
206
|
-
*/
|
|
207
|
-
const validateResponse = validateChartEOD(
|
|
208
|
-
interval,
|
|
209
|
-
assetType,
|
|
210
|
-
symbol,
|
|
211
|
-
exchangeType,
|
|
212
|
-
tillDate,
|
|
213
|
-
includeContinuousFuture
|
|
214
|
-
);
|
|
215
|
-
if (validateResponse.error) {
|
|
216
|
-
log4js.debug(
|
|
217
|
-
"EOD chart validation error - " + validateResponse.error.details
|
|
218
|
-
);
|
|
219
|
-
return Promise.reject(validateResponse.error.details);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
//Request Body
|
|
223
|
-
const requestBodyData = this.chartRequestBody();
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* If AssetType Amongst FUTIDX, FUTSTK,FUTCUR,FUTCOM then we take user input(includeContinuousFuture) otherwise set false
|
|
227
|
-
*/
|
|
228
|
-
if (!Object.values(futureAssetType).includes(assetType)) {
|
|
229
|
-
includeContinuousFuture = false;
|
|
230
|
-
} else {
|
|
231
|
-
requestBodyData.conti = includeContinuousFuture;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
requestBodyData.ltt = tillDate;
|
|
235
|
-
|
|
236
|
-
const url = this.__config.ChartURL(
|
|
237
|
-
interval,
|
|
238
|
-
exchangeType,
|
|
239
|
-
assetType,
|
|
240
|
-
symbol
|
|
241
|
-
);
|
|
242
|
-
log4js.debug("EOD URL -" + url);
|
|
243
|
-
|
|
244
|
-
const response = await this.__http.PostMethod(url, requestBodyData);
|
|
245
|
-
if (result.length !== 0) {
|
|
246
|
-
result = this.modifyResponse(response);
|
|
247
|
-
} else {
|
|
248
|
-
result = response;
|
|
249
|
-
}
|
|
250
|
-
log4js.debug("EOD Result :" + JSON.stringify(result));
|
|
251
|
-
return result;
|
|
252
|
-
} catch (error) {
|
|
253
|
-
log4js.debug("EOD error - " + error);
|
|
254
|
-
return Promise.reject(error);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
module.exports = Chart;
|
|
1
|
+
const log4js = require("./logger.js");
|
|
2
|
+
const { futureAssetType } = require("../enums/assetType");
|
|
3
|
+
const {
|
|
4
|
+
validateChartIntraday,
|
|
5
|
+
validateChartEOD,
|
|
6
|
+
} = require("../validations/chartValidator");
|
|
7
|
+
|
|
8
|
+
class Chart {
|
|
9
|
+
constructor(http, config, constants) {
|
|
10
|
+
this.__http = http;
|
|
11
|
+
this.__config = config;
|
|
12
|
+
this.__constants = constants;
|
|
13
|
+
}
|
|
14
|
+
checkResponseHaveArrayOrNot = (pltPnts) => {
|
|
15
|
+
if (
|
|
16
|
+
Array.isArray(pltPnts.ltt) &&
|
|
17
|
+
Array.isArray(pltPnts.open) &&
|
|
18
|
+
Array.isArray(pltPnts.high) &&
|
|
19
|
+
Array.isArray(pltPnts.low) &&
|
|
20
|
+
Array.isArray(pltPnts.close) &&
|
|
21
|
+
Array.isArray(pltPnts.vol)
|
|
22
|
+
) {
|
|
23
|
+
return true;
|
|
24
|
+
} else {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Modifying the response
|
|
30
|
+
*/
|
|
31
|
+
modifyResponse = async (response) => {
|
|
32
|
+
try {
|
|
33
|
+
const modifyResponse = {};
|
|
34
|
+
let msgID = "";
|
|
35
|
+
let srvTm = "";
|
|
36
|
+
let nextTillDate = "";
|
|
37
|
+
const charts = [];
|
|
38
|
+
if (Object.keys(response).length !== 0) {
|
|
39
|
+
msgID = response["msgID"];
|
|
40
|
+
srvTm = response["srvTm"];
|
|
41
|
+
const data = response.data;
|
|
42
|
+
const pltPnts = data.pltPnts;
|
|
43
|
+
if (
|
|
44
|
+
Object.keys(data).length !== 0 &&
|
|
45
|
+
Object.keys(pltPnts).length !== 0
|
|
46
|
+
) {
|
|
47
|
+
const isArray = await this.checkResponseHaveArrayOrNot(pltPnts);
|
|
48
|
+
if (isArray && pltPnts.ltt.length > 0) {
|
|
49
|
+
modifyResponse["nextTillDate"] = pltPnts.ltt[0];
|
|
50
|
+
for (let i = 0; i < pltPnts.ltt.length; i++) {
|
|
51
|
+
const dataArray = [];
|
|
52
|
+
dataArray[0] = pltPnts.ltt[i];
|
|
53
|
+
dataArray[1] = pltPnts.open[i];
|
|
54
|
+
dataArray[2] = pltPnts.high[i];
|
|
55
|
+
dataArray[3] = pltPnts.low[i];
|
|
56
|
+
dataArray[4] = pltPnts.close[i];
|
|
57
|
+
dataArray[5] = pltPnts.vol[i];
|
|
58
|
+
charts.push(dataArray);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
modifyResponse["data"] = charts;
|
|
65
|
+
modifyResponse["msgID"] = msgID;
|
|
66
|
+
modifyResponse["srvTm"] = srvTm;
|
|
67
|
+
log4js.debug("modifyResponse :" + JSON.stringify(modifyResponse));
|
|
68
|
+
return modifyResponse;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return Promise.reject(e);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
convertToBoolean = async (value) => {
|
|
75
|
+
if (value === "TRUE" || value === "true") {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (value === "FALSE" || value === "false") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//Chart RequestBody
|
|
84
|
+
chartRequestBody = () => {
|
|
85
|
+
return {
|
|
86
|
+
conti: false, // By default set as false
|
|
87
|
+
chTyp: "Interval", // By default set as Interval
|
|
88
|
+
ltt: null, // By default set as null
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
|
|
95
|
+
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
96
|
+
* @param {string} symbol
|
|
97
|
+
* @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
98
|
+
* @param {string} tillDate
|
|
99
|
+
* @param {boolean} includeContinuousFuture
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
getIntradayChartAPI = async (
|
|
103
|
+
interval,
|
|
104
|
+
assetType,
|
|
105
|
+
symbol,
|
|
106
|
+
exchangeType,
|
|
107
|
+
tillDate,
|
|
108
|
+
includeContinuousFuture
|
|
109
|
+
) => {
|
|
110
|
+
let result = {};
|
|
111
|
+
try {
|
|
112
|
+
//Convert into boolean
|
|
113
|
+
includeContinuousFuture = await this.convertToBoolean(
|
|
114
|
+
includeContinuousFuture
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
//Convert null string into null object
|
|
118
|
+
if (tillDate.toLowerCase() === "null") {
|
|
119
|
+
tillDate = null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Validate intraday chart params
|
|
124
|
+
*/
|
|
125
|
+
const validateResponse = validateChartIntraday(
|
|
126
|
+
interval,
|
|
127
|
+
assetType,
|
|
128
|
+
symbol,
|
|
129
|
+
exchangeType,
|
|
130
|
+
tillDate,
|
|
131
|
+
includeContinuousFuture
|
|
132
|
+
);
|
|
133
|
+
if (validateResponse.error) {
|
|
134
|
+
log4js.debug(
|
|
135
|
+
"intraday validation error - " + validateResponse.error.details
|
|
136
|
+
);
|
|
137
|
+
return Promise.reject(validateResponse.error.details);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//Request Body
|
|
141
|
+
let requestBodyData = this.chartRequestBody();
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* If AssetType Amongst FUTIDX, FUTSTK,FUTCUR,FUTCOM then we take user input(includeContinuousFuture) otherwise set false
|
|
145
|
+
*/
|
|
146
|
+
if (!Object.values(futureAssetType).includes(assetType)) {
|
|
147
|
+
includeContinuousFuture = false;
|
|
148
|
+
} else {
|
|
149
|
+
requestBodyData.conti = includeContinuousFuture;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
requestBodyData.ltt = tillDate;
|
|
153
|
+
|
|
154
|
+
const url = this.__config.ChartURL(
|
|
155
|
+
interval,
|
|
156
|
+
exchangeType,
|
|
157
|
+
assetType,
|
|
158
|
+
symbol
|
|
159
|
+
);
|
|
160
|
+
log4js.debug("intraday URL -" + url);
|
|
161
|
+
|
|
162
|
+
const response = await this.__http.PostMethod(url, requestBodyData);
|
|
163
|
+
if (result.length !== 0) {
|
|
164
|
+
result = this.modifyResponse(response);
|
|
165
|
+
} else {
|
|
166
|
+
result = response;
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
} catch (error) {
|
|
170
|
+
log4js.debug("intraday error - " + error);
|
|
171
|
+
return Promise.reject(error);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @param {"D1" | "W1" | "MN1"} interval
|
|
178
|
+
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
179
|
+
* @param {string} symbol
|
|
180
|
+
* @param {"NSE" | "BSE" | "NFO" | "NFO" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
181
|
+
* @param {string} tillDate yyyy-MM-dd
|
|
182
|
+
* @param {boolean} includeContinuousFuture
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
getEODChartAPI = async (
|
|
186
|
+
interval,
|
|
187
|
+
assetType,
|
|
188
|
+
symbol,
|
|
189
|
+
exchangeType,
|
|
190
|
+
tillDate,
|
|
191
|
+
includeContinuousFuture
|
|
192
|
+
) => {
|
|
193
|
+
let result = {};
|
|
194
|
+
try {
|
|
195
|
+
//Convert into boolean
|
|
196
|
+
includeContinuousFuture = await this.convertToBoolean(
|
|
197
|
+
includeContinuousFuture
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
//Convert null string into null object
|
|
201
|
+
if (tillDate.toLowerCase() === "null") {
|
|
202
|
+
tillDate = null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Validate eod chart params
|
|
206
|
+
*/
|
|
207
|
+
const validateResponse = validateChartEOD(
|
|
208
|
+
interval,
|
|
209
|
+
assetType,
|
|
210
|
+
symbol,
|
|
211
|
+
exchangeType,
|
|
212
|
+
tillDate,
|
|
213
|
+
includeContinuousFuture
|
|
214
|
+
);
|
|
215
|
+
if (validateResponse.error) {
|
|
216
|
+
log4js.debug(
|
|
217
|
+
"EOD chart validation error - " + validateResponse.error.details
|
|
218
|
+
);
|
|
219
|
+
return Promise.reject(validateResponse.error.details);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
//Request Body
|
|
223
|
+
const requestBodyData = this.chartRequestBody();
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* If AssetType Amongst FUTIDX, FUTSTK,FUTCUR,FUTCOM then we take user input(includeContinuousFuture) otherwise set false
|
|
227
|
+
*/
|
|
228
|
+
if (!Object.values(futureAssetType).includes(assetType)) {
|
|
229
|
+
includeContinuousFuture = false;
|
|
230
|
+
} else {
|
|
231
|
+
requestBodyData.conti = includeContinuousFuture;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
requestBodyData.ltt = tillDate;
|
|
235
|
+
|
|
236
|
+
const url = this.__config.ChartURL(
|
|
237
|
+
interval,
|
|
238
|
+
exchangeType,
|
|
239
|
+
assetType,
|
|
240
|
+
symbol
|
|
241
|
+
);
|
|
242
|
+
log4js.debug("EOD URL -" + url);
|
|
243
|
+
|
|
244
|
+
const response = await this.__http.PostMethod(url, requestBodyData);
|
|
245
|
+
if (result.length !== 0) {
|
|
246
|
+
result = this.modifyResponse(response);
|
|
247
|
+
} else {
|
|
248
|
+
result = response;
|
|
249
|
+
}
|
|
250
|
+
log4js.debug("EOD Result :" + JSON.stringify(result));
|
|
251
|
+
return result;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
log4js.debug("EOD error - " + error);
|
|
254
|
+
return Promise.reject(error);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
module.exports = Chart;
|