api_connect_nodejs 2.0.4 → 2.0.6
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/conf/settings.ini +1 -1
- package/enums/streamingConstants.js +3 -0
- package/package.json +2 -1
- package/src/apiConnect.js +221 -62
- package/src/config.js +13 -4
- package/src/feed/depthFeed.js +137 -0
- package/src/feed/feed.js +29 -6
- package/src/feed/miniQuoteFeed.js +121 -0
- package/src/feed/quotesFeed.js +106 -1
- package/src/quote.js +75 -0
- package/validations/apiConnectValidator.js +58 -0
- package/validations/feedStreamerValidator.js +97 -3
- package/validations/quoteValidator.js +19 -0
package/conf/settings.ini
CHANGED
|
@@ -9,7 +9,7 @@ BasePathContent = https://nc.nuvamawealth.com/edelmw-content/content/
|
|
|
9
9
|
EquityContractURL = https://nc.nuvamawealth.com/app/toccontracts/instruments.zip
|
|
10
10
|
MFContractURL = https://nc.nuvamawealth.com/app/toccontracts/mfInstruments.zip
|
|
11
11
|
|
|
12
|
-
ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
12
|
+
ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOjAsImZmIjoiVyIsImJkIjoid2ViLXBjIiwibmJmIjoxNjk4OTk0MTM1LCJzcmMiOiJlbXRtdyIsImF2IjoiMi4wLjYiLCJhcHBpZCI6IjhjZmE0MGJiYmUxMjQ5MGM2YzhjYzMwOWNlZmViZGQzIiwiaXNzIjoiZW10IiwiZXhwIjoxNjk5MDM2MjAwLCJpYXQiOjE2OTg5OTQ0MzV9.rwTusEQqt0VuYlW1-MSsixJm3RJGQTj2AFt8e_GsY3o
|
|
13
13
|
TlsVersion = 1.2
|
|
14
14
|
LogLevel = All
|
|
15
15
|
|
|
@@ -6,6 +6,9 @@ const streamingConstants = Object.freeze({
|
|
|
6
6
|
QUOTE_SREAM_REQ_CODE: 1,
|
|
7
7
|
ORDER_STREAM_REQ_CODE: 2,
|
|
8
8
|
LIVENEWS_STREAM_REQ_CODE: 3,
|
|
9
|
+
DEPTH_SREAM_REQ_CODE: 4,
|
|
10
|
+
MINI_QUOTE_SREAM_REQ_CODE: 5,
|
|
11
|
+
REDUCED_QUOTE_SREAM_REQ_CODE: 6,
|
|
9
12
|
});
|
|
10
13
|
|
|
11
14
|
module.exports = streamingConstants;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api_connect_nodejs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Command to run :",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@joi/date": "^2.1.0",
|
|
11
|
+
"api_connect_nodejs": "file:api_connect_nodejs-2.0.6.tgz",
|
|
11
12
|
"chai": "^4.3.6",
|
|
12
13
|
"csv-parser": "^3.0.0",
|
|
13
14
|
"csv-writer": "^1.6.0",
|
package/src/apiConnect.js
CHANGED
|
@@ -3,6 +3,7 @@ const readline = require("readline");
|
|
|
3
3
|
const log4js = require("./logger.js");
|
|
4
4
|
const Order = require("./order");
|
|
5
5
|
const Chart = require("./chart");
|
|
6
|
+
const Quote = require("./quote");
|
|
6
7
|
const LiveNews = require("./liveNews");
|
|
7
8
|
const Watchlist = require("./watchlist");
|
|
8
9
|
const ResearchCalls = require("./researchCalls");
|
|
@@ -14,6 +15,8 @@ const Feed = require("./feed/feed");
|
|
|
14
15
|
const QuotesFeed = require("./feed/quotesFeed");
|
|
15
16
|
const OrdersFeed = require("./feed/ordersFeed");
|
|
16
17
|
const LiveNewsFeed = require("./feed/liveNewsFeed");
|
|
18
|
+
const MiniQuoteFeed = require("./feed/miniQuoteFeed");
|
|
19
|
+
const DepthFeed = require("./feed/depthFeed");
|
|
17
20
|
|
|
18
21
|
const {
|
|
19
22
|
validatePlaceTrade,
|
|
@@ -109,6 +112,7 @@ class APIConnect {
|
|
|
109
112
|
this.__constants.AppIdKey = j.appidkey;
|
|
110
113
|
this.__constants.profileId = j.data.data.lgnData.accs.prfId;
|
|
111
114
|
this.__constants.prds = j.data.data.lgnData.prds;
|
|
115
|
+
this.__constants.accs = j.data.data.lgnData.accs;
|
|
112
116
|
this.excsAndprdDpNm = this.__constants.getProductsAndExchange(
|
|
113
117
|
this.__constants.prds
|
|
114
118
|
);
|
|
@@ -197,6 +201,15 @@ class APIConnect {
|
|
|
197
201
|
.PostMethod(url, { lib: "EAC_NODE", vsn: this.version })
|
|
198
202
|
.then((res) => {
|
|
199
203
|
if (res.data.sts) {
|
|
204
|
+
if (res.data.msg === "OPTIONAL") {
|
|
205
|
+
console.log(
|
|
206
|
+
"New version " +
|
|
207
|
+
res.data.vsn +
|
|
208
|
+
" is available. Stay up to date for better experience"
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
} else if (false == res.data.sts) {
|
|
200
213
|
if (res.data.msg === "MANDATORY") {
|
|
201
214
|
console.log(
|
|
202
215
|
"Mandatory Update. New version " +
|
|
@@ -204,15 +217,9 @@ class APIConnect {
|
|
|
204
217
|
". Update to new version to continue."
|
|
205
218
|
);
|
|
206
219
|
process.exit();
|
|
207
|
-
} else if (res.data.msg === "OPTIONAL") {
|
|
208
|
-
console.log(
|
|
209
|
-
"New version " +
|
|
210
|
-
res.data.vsn +
|
|
211
|
-
" is available. Stay up to date for better experience"
|
|
212
|
-
);
|
|
213
220
|
}
|
|
214
221
|
return;
|
|
215
|
-
}
|
|
222
|
+
}else {
|
|
216
223
|
throw res;
|
|
217
224
|
}
|
|
218
225
|
})
|
|
@@ -265,6 +272,36 @@ class APIConnect {
|
|
|
265
272
|
return orderFeedObj;
|
|
266
273
|
};
|
|
267
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Get MiniQuoteStreaming Object
|
|
277
|
+
* @function initMiniQuoteStreaming
|
|
278
|
+
* @returns MiniQuoteStreaming Object, using this object you can call subsribe() and unsubsribe() methods.
|
|
279
|
+
*/
|
|
280
|
+
initMiniQuoteStreaming = () => {
|
|
281
|
+
let miniQuoteFeedObj = {};
|
|
282
|
+
try {
|
|
283
|
+
miniQuoteFeedObj = new MiniQuoteFeed(this.feedObject);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console.log(error);
|
|
286
|
+
}
|
|
287
|
+
return miniQuoteFeedObj;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Get DepthStreaming Object
|
|
292
|
+
* @function initDepthStreaming
|
|
293
|
+
* @returns DepthStreaming Object, using this object you can call subsribe() and unsubsribe() methods.
|
|
294
|
+
*/
|
|
295
|
+
initDepthStreaming = () => {
|
|
296
|
+
let depthFeedObj = {};
|
|
297
|
+
try {
|
|
298
|
+
depthFeedObj = new DepthFeed(this.feedObject, this.__constants);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
console.log(error);
|
|
301
|
+
}
|
|
302
|
+
return depthFeedObj;
|
|
303
|
+
};
|
|
304
|
+
|
|
268
305
|
/**
|
|
269
306
|
* Get Login info
|
|
270
307
|
* @returns Login info
|
|
@@ -1001,17 +1038,20 @@ class APIConnect {
|
|
|
1001
1038
|
rmk: "",
|
|
1002
1039
|
flQty: true,
|
|
1003
1040
|
};
|
|
1004
|
-
|
|
1041
|
+
|
|
1005
1042
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1043
|
+
log4js.debug("PlaceTrade Data :" + JSON.stringify(data));
|
|
1006
1044
|
const url = this.__config.PlaceTradeURL_comm(this.__constants.coAccId);
|
|
1007
1045
|
log4js.debug("PlaceTrade URL -" + url);
|
|
1008
1046
|
var result = this.__http.PostMethod(url, data);
|
|
1009
1047
|
log4js.debug("PlaceTrade Result :" + JSON.stringify(result));
|
|
1010
1048
|
return result;
|
|
1011
1049
|
} else {
|
|
1050
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1012
1051
|
const url = this.__config.PlaceTradeURL(this.__constants.eqAccId);
|
|
1013
1052
|
log4js.debug("PlaceTrade URL -" + url);
|
|
1014
|
-
|
|
1053
|
+
log4js.debug("PlaceTrade Data :" + JSON.stringify(upadatedData));
|
|
1054
|
+
var result = this.__http.PostMethod(url, upadatedData);
|
|
1015
1055
|
log4js.debug("PlaceTrade Result :" + JSON.stringify(result));
|
|
1016
1056
|
return result;
|
|
1017
1057
|
}
|
|
@@ -1121,6 +1161,7 @@ class APIConnect {
|
|
|
1121
1161
|
* @param {string} Disclosed_Quantity Quantity to be disclosed while order placement
|
|
1122
1162
|
* @param {string} TriggerPrice Trigger Price applicable for SL/SL-M Orders
|
|
1123
1163
|
* @param {string} ProductCode CNC | MIS | NRML | MTF
|
|
1164
|
+
* @param {string} CurrentQuantity
|
|
1124
1165
|
* @returns Promise that resolves/rejects to Modify Order api response
|
|
1125
1166
|
*/
|
|
1126
1167
|
ModifyTrade = (
|
|
@@ -1135,7 +1176,8 @@ class APIConnect {
|
|
|
1135
1176
|
Order_ID,
|
|
1136
1177
|
Disclosed_Quantity = "0",
|
|
1137
1178
|
TriggerPrice = "0",
|
|
1138
|
-
ProductCode
|
|
1179
|
+
ProductCode,
|
|
1180
|
+
CurrentQuantity = "0"
|
|
1139
1181
|
) => {
|
|
1140
1182
|
log4js.info("Inside ModifyTrade method");
|
|
1141
1183
|
const paramsObj = {
|
|
@@ -1151,6 +1193,7 @@ class APIConnect {
|
|
|
1151
1193
|
dscQty: Disclosed_Quantity,
|
|
1152
1194
|
trgPrc: TriggerPrice,
|
|
1153
1195
|
prdCode: ProductCode,
|
|
1196
|
+
curQty: CurrentQuantity,
|
|
1154
1197
|
};
|
|
1155
1198
|
const validateResponse = validateModifyTrade(
|
|
1156
1199
|
paramsObj,
|
|
@@ -1181,17 +1224,20 @@ class APIConnect {
|
|
|
1181
1224
|
valid: false,
|
|
1182
1225
|
};
|
|
1183
1226
|
|
|
1184
|
-
log4js.debug("ModifyTrade Data :" + JSON.stringify(data));
|
|
1185
1227
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1186
1228
|
const url = this.__config.ModifyTradeURL_comm(this.__constants.coAccId);
|
|
1187
1229
|
log4js.debug("ModifyTrade URLS -" + url);
|
|
1230
|
+
log4js.debug("ModifyTrade Data :" + JSON.stringify(data));
|
|
1188
1231
|
var result = this.__http.PutMethod(url, data);
|
|
1189
1232
|
log4js.debug("ModifyTrade Result :" + JSON.stringify(result));
|
|
1190
1233
|
return result;
|
|
1191
1234
|
} else {
|
|
1235
|
+
data.curQty = CurrentQuantity;
|
|
1236
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1192
1237
|
const url = this.__config.ModifyTradeURL(this.__constants.eqAccId);
|
|
1193
1238
|
log4js.debug("ModifyTrade URLS -" + url);
|
|
1194
|
-
|
|
1239
|
+
log4js.debug("ModifyTrade Data :" + JSON.stringify(upadatedData));
|
|
1240
|
+
var result = this.__http.PutMethod(url, upadatedData);
|
|
1195
1241
|
log4js.debug("ModifyTrade Result :" + JSON.stringify(result));
|
|
1196
1242
|
return result;
|
|
1197
1243
|
}
|
|
@@ -1202,9 +1248,20 @@ class APIConnect {
|
|
|
1202
1248
|
* @param {string} Exchange Exchange
|
|
1203
1249
|
* @param {string'} Order_Type LIMIT | MARKET | STOP_LIMIT | STOP_MARKET
|
|
1204
1250
|
* @param {string} ProductCode CNC | MIS | NRML | MTF
|
|
1251
|
+
* @param {string} CurrentQuantity
|
|
1205
1252
|
* @returns Promise that resolves/rejects to Cancel Trade api response
|
|
1206
1253
|
*/
|
|
1207
|
-
CancelTrade = (
|
|
1254
|
+
CancelTrade = (
|
|
1255
|
+
OrderId,
|
|
1256
|
+
Exchange,
|
|
1257
|
+
Order_Type,
|
|
1258
|
+
ProductCode,
|
|
1259
|
+
CurrentQuantity = "0",
|
|
1260
|
+
FillQuantity = "0",
|
|
1261
|
+
Trading_Symbol,
|
|
1262
|
+
Action,
|
|
1263
|
+
Streaming_Symbol,
|
|
1264
|
+
) => {
|
|
1208
1265
|
log4js.info("Inside CancelTrade method");
|
|
1209
1266
|
const data = {
|
|
1210
1267
|
nstOID: OrderId,
|
|
@@ -1212,27 +1269,49 @@ class APIConnect {
|
|
|
1212
1269
|
prdCode: this.__constants.getValidProductCode(this.fileName, Exchange, ProductCode),
|
|
1213
1270
|
ordTyp: Order_Type,
|
|
1214
1271
|
};
|
|
1215
|
-
|
|
1216
|
-
data,
|
|
1217
|
-
this.excsAndprdDpNm
|
|
1218
|
-
);
|
|
1219
|
-
if (validateResponse.error) {
|
|
1220
|
-
log4js.debug(
|
|
1221
|
-
"CancelTrade validation error -" + validateResponse.error.details
|
|
1222
|
-
);
|
|
1223
|
-
return Promise.reject(validateResponse.error.details);
|
|
1224
|
-
}
|
|
1225
|
-
log4js.debug("CancelTrade Data :" + JSON.stringify(data));
|
|
1272
|
+
|
|
1226
1273
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1274
|
+
const validateResponse = validateCancelPlaceTrade(
|
|
1275
|
+
data,
|
|
1276
|
+
this.excsAndprdDpNm
|
|
1277
|
+
);
|
|
1278
|
+
if (validateResponse.error) {
|
|
1279
|
+
log4js.debug(
|
|
1280
|
+
"CancelTrade validation error -" + validateResponse.error.details
|
|
1281
|
+
);
|
|
1282
|
+
return Promise.reject(validateResponse.error.details);
|
|
1283
|
+
}
|
|
1284
|
+
log4js.debug("CancelTrade Data :" + JSON.stringify(data));
|
|
1285
|
+
|
|
1227
1286
|
const url = this.__config.CancelTradeURL_comm(this.__constants.coAccId);
|
|
1228
1287
|
log4js.debug("CancelTrade URLS -" + url);
|
|
1229
1288
|
var result = this.__http.PutMethod(url, data);
|
|
1230
1289
|
log4js.debug("CancelTrade Result :" + JSON.stringify(result));
|
|
1231
1290
|
return result;
|
|
1232
1291
|
} else {
|
|
1292
|
+
|
|
1293
|
+
data.curQty = CurrentQuantity;
|
|
1294
|
+
data.flQty = FillQuantity;
|
|
1295
|
+
data.trdSym = Trading_Symbol;
|
|
1296
|
+
data.action = Action;
|
|
1297
|
+
data.sym = Streaming_Symbol;
|
|
1298
|
+
|
|
1299
|
+
const validateResponse = validateCancelPlaceTradeV1(
|
|
1300
|
+
data,
|
|
1301
|
+
this.excsAndprdDpNm
|
|
1302
|
+
);
|
|
1303
|
+
if (validateResponse.error) {
|
|
1304
|
+
log4js.debug(
|
|
1305
|
+
"CancelTrade validation error -" + validateResponse.error.details
|
|
1306
|
+
);
|
|
1307
|
+
return Promise.reject(validateResponse.error.details);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1233
1311
|
const url = this.__config.CancelTradeURL(this.__constants.eqAccId);
|
|
1234
1312
|
log4js.debug("CancelTrade URLS -" + url);
|
|
1235
|
-
|
|
1313
|
+
log4js.debug("CancelTrade Data :" + JSON.stringify(upadatedData));
|
|
1314
|
+
var result = this.__http.PutMethod(url, upadatedData);
|
|
1236
1315
|
log4js.debug("CancelTrade Result :" + JSON.stringify(result));
|
|
1237
1316
|
return result;
|
|
1238
1317
|
}
|
|
@@ -1548,17 +1627,19 @@ class APIConnect {
|
|
|
1548
1627
|
rmk: "",
|
|
1549
1628
|
};
|
|
1550
1629
|
|
|
1551
|
-
log4js.debug("PlaceAMOTrade Data :" + JSON.stringify(data));
|
|
1552
1630
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1553
1631
|
const url = this.__config.PlaceAMOTrade_comm(this.__constants.coAccId);
|
|
1554
1632
|
log4js.debug("PlaceAMOTrade URLS -" + url);
|
|
1633
|
+
log4js.debug("PlaceAMOTrade Data :" + JSON.stringify(data));
|
|
1555
1634
|
var result = this.__http.PostMethod(url, data);
|
|
1556
1635
|
log4js.debug("PlaceAMOTrade Result :" + JSON.stringify(result));
|
|
1557
1636
|
return result;
|
|
1558
1637
|
} else {
|
|
1638
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1559
1639
|
const url = this.__config.PlaceAMOTrade(this.__constants.eqAccId);
|
|
1560
1640
|
log4js.debug("PlaceAMOTrade URLS -" + url);
|
|
1561
|
-
|
|
1641
|
+
log4js.debug("PlaceAMOTrade Data :" + JSON.stringify(upadatedData));
|
|
1642
|
+
var result = this.__http.PostMethod(url, upadatedData);
|
|
1562
1643
|
log4js.debug("PlaceAMOTrade Result :" + JSON.stringify(result));
|
|
1563
1644
|
return result;
|
|
1564
1645
|
}
|
|
@@ -1578,6 +1659,7 @@ class APIConnect {
|
|
|
1578
1659
|
* @param {string} Disclosed_Quantity Quantity to be disclosed while order_placement
|
|
1579
1660
|
* @param {string} TriggerPrice Trigger Price applicable for SL/SL-M Orders
|
|
1580
1661
|
* @param {string} ProductCode Product Code of the trade
|
|
1662
|
+
* @param {string} CurrentQuantity
|
|
1581
1663
|
* @returns Promise that resolves/rejects to the Place AMO Trade api response
|
|
1582
1664
|
*/
|
|
1583
1665
|
ModifyAMOTrade = (
|
|
@@ -1592,7 +1674,8 @@ class APIConnect {
|
|
|
1592
1674
|
Order_ID,
|
|
1593
1675
|
Disclosed_Quantity = "0",
|
|
1594
1676
|
TriggerPrice = "0",
|
|
1595
|
-
ProductCode
|
|
1677
|
+
ProductCode,
|
|
1678
|
+
CurrentQuantity = "0"
|
|
1596
1679
|
) => {
|
|
1597
1680
|
log4js.info("Inside ModifyAMOTrade method");
|
|
1598
1681
|
const paramsObj = {
|
|
@@ -1608,6 +1691,7 @@ class APIConnect {
|
|
|
1608
1691
|
dscQty: Disclosed_Quantity,
|
|
1609
1692
|
trgPrc: TriggerPrice,
|
|
1610
1693
|
prdCode: ProductCode,
|
|
1694
|
+
curQty: CurrentQuantity,
|
|
1611
1695
|
};
|
|
1612
1696
|
const validateResponse = validateModifyAMOTrade(
|
|
1613
1697
|
paramsObj,
|
|
@@ -1637,17 +1721,20 @@ class APIConnect {
|
|
|
1637
1721
|
nstOID: Order_ID,
|
|
1638
1722
|
};
|
|
1639
1723
|
|
|
1640
|
-
log4js.debug("ModifyAMOTrade Data :" + JSON.stringify(data));
|
|
1641
1724
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1642
1725
|
const url = this.__config.ModifyAMOTrade_comm(this.__constants.coAccId);
|
|
1643
1726
|
log4js.debug("ModifyAMOTrade URLS" + url);
|
|
1727
|
+
log4js.debug("ModifyAMOTrade Data :" + JSON.stringify(data));
|
|
1644
1728
|
var result = this.__http.PutMethod(url, data);
|
|
1645
1729
|
log4js.debug("ModifyAMOTrade Result :" + JSON.stringify(result));
|
|
1646
1730
|
return result;
|
|
1647
1731
|
} else {
|
|
1732
|
+
data.curQty = CurrentQuantity;
|
|
1733
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1648
1734
|
const url = this.__config.ModifyAMOTrade(this.__constants.eqAccId);
|
|
1649
1735
|
log4js.debug("ModifyAMOTrade URLS" + url);
|
|
1650
|
-
|
|
1736
|
+
log4js.debug("ModifyAMOTrade Data :" + JSON.stringify(upadatedData));
|
|
1737
|
+
var result = this.__http.PutMethod(url, upadatedData);
|
|
1651
1738
|
log4js.debug("ModifyAMOTrade Result :" + JSON.stringify(result));
|
|
1652
1739
|
return result;
|
|
1653
1740
|
}
|
|
@@ -1659,34 +1746,65 @@ class APIConnect {
|
|
|
1659
1746
|
* @param {string} Exchange Exchange
|
|
1660
1747
|
* @param {'LIMIT' | 'MARKET' | 'STOP_LIMIT' | 'STOP_MARKET'} Order_Type LIMIT | MARKET | STOP_LIMIT | STOP_MARKET
|
|
1661
1748
|
* @param {'CNC' | 'MIS' | 'NRML' | 'MTF'} Product_Code CNC | MIS | NRML | MTF
|
|
1749
|
+
* @param {string} CurrentQuantity
|
|
1662
1750
|
* @returns Promise that resolves/rejects to the Cancel AMO Trade api response
|
|
1663
1751
|
*/
|
|
1664
|
-
CancelAMOTrade = (
|
|
1752
|
+
CancelAMOTrade = (
|
|
1753
|
+
OrderId,
|
|
1754
|
+
Exchange,
|
|
1755
|
+
Order_Type,
|
|
1756
|
+
Product_Code,
|
|
1757
|
+
CurrentQuantity = "0",
|
|
1758
|
+
FillQuantity = "0",
|
|
1759
|
+
Trading_Symbol,
|
|
1760
|
+
Action,
|
|
1761
|
+
Streaming_Symbol,
|
|
1762
|
+
) => {
|
|
1665
1763
|
const data = {
|
|
1666
1764
|
nstOID: OrderId,
|
|
1667
1765
|
exc: Exchange,
|
|
1668
1766
|
prdCode: this.__constants.getValidProductCode(this.fileName, Exchange, Product_Code),
|
|
1669
1767
|
ordTyp: Order_Type,
|
|
1768
|
+
curQty: CurrentQuantity,
|
|
1670
1769
|
};
|
|
1671
1770
|
log4js.info("Inside CancelAMOTrade method");
|
|
1672
|
-
|
|
1673
|
-
if (validateResponse.error) {
|
|
1674
|
-
log4js.debug(
|
|
1675
|
-
"CancelAMOTrade validation error -" + validateResponse.error.details
|
|
1676
|
-
);
|
|
1677
|
-
return Promise.reject(validateResponse.error.details);
|
|
1678
|
-
}
|
|
1679
|
-
log4js.debug("CancelAMOTrade Data :" + JSON.stringify(data));
|
|
1771
|
+
|
|
1680
1772
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
1773
|
+
const validateResponse = validateCancelAMOTrade(data, this.excsAndprdDpNm);
|
|
1774
|
+
if (validateResponse.error) {
|
|
1775
|
+
log4js.debug(
|
|
1776
|
+
"CancelAMOTrade validation error -" + validateResponse.error.details
|
|
1777
|
+
);
|
|
1778
|
+
return Promise.reject(validateResponse.error.details);
|
|
1779
|
+
}
|
|
1780
|
+
log4js.debug("CancelAMOTrade Data :" + JSON.stringify(data));
|
|
1781
|
+
|
|
1681
1782
|
const url = this.__config.CancelAMOTrade_comm(this.__constants.coAccId);
|
|
1682
1783
|
log4js.debug("CancelAMOTrade URLS -" + url);
|
|
1683
1784
|
var result = this.__http.PutMethod(url, data);
|
|
1684
1785
|
log4js.debug("CancelAMOTrade Result :" + JSON.stringify(result));
|
|
1685
1786
|
return result;
|
|
1686
1787
|
} else {
|
|
1788
|
+
|
|
1789
|
+
data.curQty = CurrentQuantity;
|
|
1790
|
+
data.flQty = FillQuantity;
|
|
1791
|
+
data.trdSym = Trading_Symbol;
|
|
1792
|
+
data.action = Action;
|
|
1793
|
+
data.sym = Streaming_Symbol;
|
|
1794
|
+
|
|
1795
|
+
const validateResponse = validateCancelAMOTradeV1(data, this.excsAndprdDpNm);
|
|
1796
|
+
if (validateResponse.error) {
|
|
1797
|
+
log4js.debug(
|
|
1798
|
+
"CancelAMOTrade validation error -" + validateResponse.error.details
|
|
1799
|
+
);
|
|
1800
|
+
return Promise.reject(validateResponse.error.details);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1687
1804
|
const url = this.__config.CancelAMOTrade(this.__constants.eqAccId);
|
|
1688
1805
|
log4js.debug("CancelAMOTrade URLS -" + url);
|
|
1689
|
-
|
|
1806
|
+
log4js.debug("CancelAMOTrade Data :" + JSON.stringify(upadatedData));
|
|
1807
|
+
var result = this.__http.PutMethod(url, upadatedData);
|
|
1690
1808
|
log4js.debug("CancelAMOTrade Result :" + JSON.stringify(result));
|
|
1691
1809
|
return result;
|
|
1692
1810
|
}
|
|
@@ -1702,7 +1820,6 @@ class APIConnect {
|
|
|
1702
1820
|
orderlist,
|
|
1703
1821
|
this.excsAndprdDpNm
|
|
1704
1822
|
);
|
|
1705
|
-
console.log("PositionSquareOff", validateResponse);
|
|
1706
1823
|
await Promise.all(
|
|
1707
1824
|
validateResponse.map((item) => {
|
|
1708
1825
|
if (item.error) {
|
|
@@ -1730,29 +1847,37 @@ class APIConnect {
|
|
|
1730
1847
|
order["lmPrc"] = order.price;
|
|
1731
1848
|
const data = order;
|
|
1732
1849
|
|
|
1733
|
-
order.exc == "MCX" || order.exc == "NCDEX"
|
|
1734
|
-
|
|
1735
|
-
|
|
1850
|
+
if(order.exc == "MCX" || order.exc == "NCDEX") {
|
|
1851
|
+
lstComm.push(data)
|
|
1852
|
+
}else {
|
|
1853
|
+
const upadatedData = this.__checkDependentAndUpdateData(data);
|
|
1854
|
+
{lstEq.push(upadatedData)};
|
|
1855
|
+
}
|
|
1736
1856
|
});
|
|
1737
1857
|
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1858
|
+
const dataEq = {
|
|
1859
|
+
sqrLst: lstEq
|
|
1860
|
+
};
|
|
1861
|
+
if(Object.keys(dataEq).length > 0) {
|
|
1862
|
+
const postComm = ""
|
|
1863
|
+
const postEq = this.__http.PostMethod(this.__config.PositionSqOffV1URL(this.__constants.eqAccId),dataEq)
|
|
1864
|
+
var result = Promise.all([postEq, postComm]).then(([eq, comm]) => ({
|
|
1865
|
+
eq,
|
|
1866
|
+
comm,
|
|
1867
|
+
}));
|
|
1868
|
+
log4js.debug("PositionSquareOff Result :" + JSON.stringify(result));
|
|
1869
|
+
return result;
|
|
1870
|
+
} else if(Object.keys(lstComm).length > 0) {
|
|
1871
|
+
const postEq = ""
|
|
1872
|
+
const postComm = this.__http.PostMethod(this.__config.PositionSqOffURL(this.__constants.coAccId),lstComm)
|
|
1873
|
+
var result = Promise.all([postEq, postComm]).then(([eq, comm]) => ({
|
|
1874
|
+
eq,
|
|
1875
|
+
comm,
|
|
1876
|
+
}));
|
|
1877
|
+
log4js.debug("PositionSquareOff Result :" + JSON.stringify(result));
|
|
1878
|
+
return result;
|
|
1879
|
+
}
|
|
1880
|
+
return "";
|
|
1756
1881
|
};
|
|
1757
1882
|
|
|
1758
1883
|
/**
|
|
@@ -2251,6 +2376,7 @@ class APIConnect {
|
|
|
2251
2376
|
this.__constants.coAccId = res.data.lgnData.accs.coAccID;
|
|
2252
2377
|
}
|
|
2253
2378
|
this.__constants.JSession = res.data.auth;
|
|
2379
|
+
this.__constants.accs = res.data.lgnData.accs;
|
|
2254
2380
|
return res;
|
|
2255
2381
|
})
|
|
2256
2382
|
.then((res) => {
|
|
@@ -2330,6 +2456,39 @@ class APIConnect {
|
|
|
2330
2456
|
});
|
|
2331
2457
|
}
|
|
2332
2458
|
}
|
|
2459
|
+
|
|
2460
|
+
//Get Market Depth
|
|
2461
|
+
/**
|
|
2462
|
+
*
|
|
2463
|
+
* @param {string} symbol
|
|
2464
|
+
* @returns
|
|
2465
|
+
*/
|
|
2466
|
+
getMarketDepth = (
|
|
2467
|
+
symbol,
|
|
2468
|
+
) => {
|
|
2469
|
+
let response = {};
|
|
2470
|
+
log4js.info("getMarketDepth method is called.");
|
|
2471
|
+
const quoteObj = new Quote(this.__http, this.__config, this.__constants);
|
|
2472
|
+
response = quoteObj.getMarketDepthAPI(
|
|
2473
|
+
symbol,
|
|
2474
|
+
);
|
|
2475
|
+
|
|
2476
|
+
return response;
|
|
2477
|
+
};
|
|
2478
|
+
|
|
2479
|
+
//CheckDependentAndUpdateData
|
|
2480
|
+
/**
|
|
2481
|
+
*
|
|
2482
|
+
* @param {map} CheckDependentAndUpdateData = (reqBodyData) => {
|
|
2483
|
+
* @returns map
|
|
2484
|
+
*/
|
|
2485
|
+
__checkDependentAndUpdateData(reqBodyData) {
|
|
2486
|
+
let accountDataMap = this.__constants.accs;
|
|
2487
|
+
if(accountDataMap.hasOwnProperty("empOrDependent")) {
|
|
2488
|
+
reqBodyData.empOrDependent = accountDataMap.empOrDependent;
|
|
2489
|
+
}
|
|
2490
|
+
return reqBodyData;
|
|
2491
|
+
}
|
|
2333
2492
|
}
|
|
2334
2493
|
|
|
2335
2494
|
APIConnect.prototype.__constants = new __Constants();
|
package/src/config.js
CHANGED
|
@@ -133,7 +133,7 @@ class __Config {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
PlaceTradeURL = function (userid) {
|
|
136
|
-
return this.baseurleq + "trade/placetrade/" + userid;
|
|
136
|
+
return this.baseurleq + "trade/placetrade/v1/" + userid;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
PlaceTradeURL_comm = function (userid) {
|
|
@@ -193,7 +193,7 @@ class __Config {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
ModifyTradeURL = function (userid) {
|
|
196
|
-
return this.baseurleq + "trade/modifytrade/" + userid;
|
|
196
|
+
return this.baseurleq + "trade/modifytrade/v1/" + userid;
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
ModifyTradeURL_comm = function (userid) {
|
|
@@ -237,6 +237,10 @@ class __Config {
|
|
|
237
237
|
return this.baseurleq + "trade/position/sqroff/" + userid;
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
+
PositionSqOffV1URL = function (userid) {
|
|
241
|
+
return this.baseurleq + "trade/position/sqroff/v1/" + userid;
|
|
242
|
+
};
|
|
243
|
+
|
|
240
244
|
ConvertPositionURL = function (userid) {
|
|
241
245
|
return this.baseurleq + "trade/convertposition/v1/" + userid;
|
|
242
246
|
};
|
|
@@ -246,7 +250,7 @@ class __Config {
|
|
|
246
250
|
};
|
|
247
251
|
|
|
248
252
|
PlaceAMOTrade = function (userid) {
|
|
249
|
-
return this.baseurleq + "trade/amo/placetrade/" + userid;
|
|
253
|
+
return this.baseurleq + "trade/amo/placetrade/v1/" + userid;
|
|
250
254
|
};
|
|
251
255
|
|
|
252
256
|
PlaceAMOTrade_comm = function (userid) {
|
|
@@ -254,7 +258,7 @@ class __Config {
|
|
|
254
258
|
};
|
|
255
259
|
|
|
256
260
|
ModifyAMOTrade = function (userid) {
|
|
257
|
-
return this.baseurleq + "trade/amo/modifytrade/" + userid;
|
|
261
|
+
return this.baseurleq + "trade/amo/modifytrade/v1/" + userid;
|
|
258
262
|
};
|
|
259
263
|
|
|
260
264
|
ModifyAMOTrade_comm = function (userid) {
|
|
@@ -311,6 +315,11 @@ class __Config {
|
|
|
311
315
|
// return this.baseurllogin + "accounts/" + userid + "/logout";
|
|
312
316
|
return this.baseurllogin + "account/logoff/" + userid;
|
|
313
317
|
};
|
|
318
|
+
|
|
319
|
+
//MARKET DEPTH
|
|
320
|
+
MarketDepthURL = function (symbol) {
|
|
321
|
+
return this.baseurlcontent + "quote/scrip/" + symbol;
|
|
322
|
+
};
|
|
314
323
|
}
|
|
315
324
|
|
|
316
325
|
module.exports = __Config;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const log4js = require("../logger");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const { DEPTH_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
+
const {
|
|
5
|
+
validateSubscribeDepthFeed,
|
|
6
|
+
} = require("../../validations/feedStreamerValidator");
|
|
7
|
+
|
|
8
|
+
class DepthFeed {
|
|
9
|
+
/**
|
|
10
|
+
* Streamer
|
|
11
|
+
* DepthFeed Class for subsribe or unsubsribe Depth
|
|
12
|
+
*/
|
|
13
|
+
constructor(feed, constantsObj) {
|
|
14
|
+
this.feed = feed;
|
|
15
|
+
this.constants = constantsObj
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* QutoesFeed RequestBody Structure
|
|
20
|
+
* Return DepthFeed RequestBody Structure
|
|
21
|
+
* @function depthFeedRequestBody
|
|
22
|
+
* @returns object
|
|
23
|
+
*/
|
|
24
|
+
requestBody = () => {
|
|
25
|
+
return {
|
|
26
|
+
request: {
|
|
27
|
+
streaming_type: "quote2",
|
|
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 DepthFeed RequestBody
|
|
43
|
+
* Return DepthFeed RequestBody
|
|
44
|
+
* @function createDepthFeedRequest
|
|
45
|
+
* @param {Object[]} symbols - Array of subsribe Symbols
|
|
46
|
+
* @param {boolean} order - true for subsribe and false for unsubsribe
|
|
47
|
+
* @returns object
|
|
48
|
+
*/
|
|
49
|
+
createDepthFeedRequest = (symbols, depth = false) => {
|
|
50
|
+
let body = {};
|
|
51
|
+
const accTyp = this.constants.Data.data.lgnData.accTyp;
|
|
52
|
+
try {
|
|
53
|
+
body = this.requestBody();
|
|
54
|
+
const symset = symbols.map((sym) => ({
|
|
55
|
+
symbol: sym.trim()
|
|
56
|
+
}));
|
|
57
|
+
const substrMcx = '_MCX';
|
|
58
|
+
const substrNcdex = '_NCDEX';
|
|
59
|
+
const subArrContainsMcx = symbols.some(str =>
|
|
60
|
+
(str.toUpperCase()).includes(substrMcx)
|
|
61
|
+
);
|
|
62
|
+
const subArrContainsNcx = symbols.some(str => (str.toUpperCase()).includes(substrNcdex));
|
|
63
|
+
|
|
64
|
+
if ((subArrContainsMcx || subArrContainsNcx) && accTyp == 'EQ') {
|
|
65
|
+
body = {"account_type_exception" : "Symbol subscription error"}
|
|
66
|
+
}else {
|
|
67
|
+
body.request.data.symbols = symset;
|
|
68
|
+
|
|
69
|
+
if (depth) {
|
|
70
|
+
body.request.request_type = "subscribe";
|
|
71
|
+
} else {
|
|
72
|
+
body.request.request_type = "unsubscribe";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
log4js.debug("createDepthFeedRequest error - " + error);
|
|
77
|
+
} finally {
|
|
78
|
+
return body;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 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.
|
|
84
|
+
* @async
|
|
85
|
+
* @function subscribeDepthFeed
|
|
86
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
87
|
+
* @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
subscribeDepthFeed = async (symbols, callback) => {
|
|
91
|
+
try {
|
|
92
|
+
/** Validation Start */
|
|
93
|
+
const validateResponse = validateSubscribeDepthFeed(callback, symbols);
|
|
94
|
+
|
|
95
|
+
if (validateResponse.error) {
|
|
96
|
+
log4js.debug(
|
|
97
|
+
"subscribeDepthFeed validation error - " +
|
|
98
|
+
validateResponse.error.details
|
|
99
|
+
);
|
|
100
|
+
return Promise.reject(validateResponse.error.details);
|
|
101
|
+
}
|
|
102
|
+
/** Validation End */
|
|
103
|
+
|
|
104
|
+
/** Create Streaming Depth Request */
|
|
105
|
+
let depthRequest = this.createDepthFeedRequest(symbols, true);
|
|
106
|
+
if(Object.keys(depthRequest).includes("account_type_exception")) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
/** Call connect method of Feed Class */
|
|
110
|
+
this.feed.subsribe(DEPTH_SREAM_REQ_CODE, depthRequest, callback);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
log4js.debug("subscribeDepthFeed error - " + error);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
118
|
+
* @async
|
|
119
|
+
* @function unsubscribeDepthFeed
|
|
120
|
+
* @returns
|
|
121
|
+
*/
|
|
122
|
+
unsubscribeDepthFeed = async () => {
|
|
123
|
+
try {
|
|
124
|
+
/** Get Streaming Depth Request */
|
|
125
|
+
const depthRequest = this.createDepthFeedRequest([]);
|
|
126
|
+
if(Object.keys(depthRequest).includes("account_type_exception")) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
/** Unsubsribe symbols */
|
|
130
|
+
this.feed.unsubsribe(DEPTH_SREAM_REQ_CODE, depthRequest);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
log4js.debug("unsubscribeDepthFeed error - " + error);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = DepthFeed;
|
package/src/feed/feed.js
CHANGED
|
@@ -80,10 +80,11 @@ class Feed {
|
|
|
80
80
|
this.sock.on("data", (data) => {
|
|
81
81
|
try {
|
|
82
82
|
let result = data.toString();
|
|
83
|
+
const obj = JSON.parse(result)
|
|
84
|
+
const streamingType = obj['response']['streaming_type']
|
|
83
85
|
if (result) {
|
|
84
86
|
if (
|
|
85
|
-
|
|
86
|
-
result.match(new RegExp("orderFiler", "g")).length > 0
|
|
87
|
+
streamingType.toLowerCase() == "orderFiler".toLowerCase()
|
|
87
88
|
) {
|
|
88
89
|
let callbackMethod =
|
|
89
90
|
this.requestsList[streamingConstants.ORDER_STREAM_REQ_CODE][
|
|
@@ -91,8 +92,7 @@ class Feed {
|
|
|
91
92
|
];
|
|
92
93
|
callbackMethod(null, result, null);
|
|
93
94
|
} else if (
|
|
94
|
-
|
|
95
|
-
result.match(new RegExp("quote3", "g")).length > 0
|
|
95
|
+
streamingType.toLowerCase() == "quote3".toLowerCase()
|
|
96
96
|
) {
|
|
97
97
|
let callbackMethod =
|
|
98
98
|
this.requestsList[streamingConstants.QUOTE_SREAM_REQ_CODE][
|
|
@@ -100,8 +100,31 @@ class Feed {
|
|
|
100
100
|
];
|
|
101
101
|
callbackMethod(null, result, null);
|
|
102
102
|
} else if (
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
streamingType.toLowerCase() == "quote".toLowerCase()
|
|
104
|
+
) {
|
|
105
|
+
let callbackMethod =
|
|
106
|
+
this.requestsList[streamingConstants.REDUCED_QUOTE_SREAM_REQ_CODE][
|
|
107
|
+
"callback"
|
|
108
|
+
];
|
|
109
|
+
callbackMethod(null, result, null);
|
|
110
|
+
} else if (
|
|
111
|
+
streamingType.toLowerCase() == "miniquote".toLowerCase()
|
|
112
|
+
) {
|
|
113
|
+
let callbackMethod =
|
|
114
|
+
this.requestsList[streamingConstants.MINI_QUOTE_SREAM_REQ_CODE][
|
|
115
|
+
"callback"
|
|
116
|
+
];
|
|
117
|
+
callbackMethod(null, result, null);
|
|
118
|
+
} else if (
|
|
119
|
+
streamingType.toLowerCase() == "quote2".toLowerCase()
|
|
120
|
+
) {
|
|
121
|
+
let callbackMethod =
|
|
122
|
+
this.requestsList[streamingConstants.DEPTH_SREAM_REQ_CODE][
|
|
123
|
+
"callback"
|
|
124
|
+
];
|
|
125
|
+
callbackMethod(null, result, null);
|
|
126
|
+
}else if (
|
|
127
|
+
streamingType.toLowerCase() == "news".toLowerCase()
|
|
105
128
|
) {
|
|
106
129
|
let callbackMethod =
|
|
107
130
|
this.requestsList[streamingConstants.LIVENEWS_STREAM_REQ_CODE][
|
|
@@ -0,0 +1,121 @@
|
|
|
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;
|
package/src/feed/quotesFeed.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const log4js = require("../logger");
|
|
2
2
|
const configData = require("../iniparser");
|
|
3
|
-
const { QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
3
|
+
const { QUOTE_SREAM_REQ_CODE, REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
4
|
const {
|
|
5
5
|
validateSubscribeQuotesFeed,
|
|
6
6
|
validateUnsubscribeQuotesFeed,
|
|
7
|
+
validateSubscribeReducedQuotesFeed,
|
|
8
|
+
validateUnsubscribeReducedQuotesFeed,
|
|
7
9
|
} = require("../../validations/feedStreamerValidator");
|
|
8
10
|
|
|
9
11
|
class QuotesFeed {
|
|
@@ -116,6 +118,109 @@ class QuotesFeed {
|
|
|
116
118
|
console.log(error);
|
|
117
119
|
}
|
|
118
120
|
};
|
|
121
|
+
|
|
122
|
+
//Reduced Quote
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Reduced QutoesFeed RequestBody Structure
|
|
126
|
+
* Return Reduced QuotesFeed RequestBody Structure
|
|
127
|
+
* @function reducedQuotesFeedRequestBody
|
|
128
|
+
* @returns object
|
|
129
|
+
*/
|
|
130
|
+
reducedQuoteRequestBody = () => {
|
|
131
|
+
return {
|
|
132
|
+
request: {
|
|
133
|
+
streaming_type: "quote",
|
|
134
|
+
data: {
|
|
135
|
+
"accType": "EQ",
|
|
136
|
+
symbols: [],
|
|
137
|
+
},
|
|
138
|
+
formFactor: configData.formFactor,
|
|
139
|
+
appID: configData.ApiIdKey,
|
|
140
|
+
response_format: "json",
|
|
141
|
+
request_type: "",
|
|
142
|
+
},
|
|
143
|
+
echo: {},
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Create ReducedQuotesFeed RequestBody
|
|
148
|
+
* Return ReducedQuotesFeed RequestBody
|
|
149
|
+
* @function createReducedQuotesFeedRequest
|
|
150
|
+
* @param {Object[]} symbols - Array of subsribe Symbols
|
|
151
|
+
* @param {boolean} order - true for subsribe and false for unsubsribe
|
|
152
|
+
* @returns object
|
|
153
|
+
*/
|
|
154
|
+
createReducedQuotesFeedRequest = (symbols, reducedQuote = false) => {
|
|
155
|
+
let body = {};
|
|
156
|
+
try {
|
|
157
|
+
body = this.reducedQuoteRequestBody();
|
|
158
|
+
const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
|
|
159
|
+
|
|
160
|
+
body.request.data.symbols = symset;
|
|
161
|
+
|
|
162
|
+
if (reducedQuote) {
|
|
163
|
+
body.request.request_type = "subscribe";
|
|
164
|
+
} else {
|
|
165
|
+
body.request.request_type = "unsubscribe";
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
log4js.debug("createReducedQuotesFeedRequest error - " + error);
|
|
169
|
+
} finally {
|
|
170
|
+
return body;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 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.
|
|
176
|
+
* @async
|
|
177
|
+
* @function subscribeReducedQuotesFeed
|
|
178
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
179
|
+
* @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
|
|
180
|
+
* @returns
|
|
181
|
+
*/
|
|
182
|
+
subscribeReducedQuotesFeed = async (symbols, callback) => {
|
|
183
|
+
try {
|
|
184
|
+
/** Validation Start */
|
|
185
|
+
const validateResponse = validateSubscribeReducedQuotesFeed(callback, symbols);
|
|
186
|
+
|
|
187
|
+
if (validateResponse.error) {
|
|
188
|
+
log4js.debug(
|
|
189
|
+
"subscribeReducedQuotesFeed validation error - " +
|
|
190
|
+
validateResponse.error.details
|
|
191
|
+
);
|
|
192
|
+
return Promise.reject(validateResponse.error.details);
|
|
193
|
+
}
|
|
194
|
+
/** Validation End */
|
|
195
|
+
|
|
196
|
+
/** Create Streaming Quote Request */
|
|
197
|
+
let reducedQuoteRequest = this.createReducedQuotesFeedRequest(symbols, true);
|
|
198
|
+
/** Call connect method of Feed Class */
|
|
199
|
+
this.feed.subsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest, callback);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
log4js.debug("subscribeReducedQuotesFeed error - " + error);
|
|
202
|
+
console.log(error);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
208
|
+
* @async
|
|
209
|
+
* @function unsubscribeReducedQuotesFeed
|
|
210
|
+
* @returns
|
|
211
|
+
*/
|
|
212
|
+
unsubscribeReducedQuotesFeed = async () => {
|
|
213
|
+
try {
|
|
214
|
+
/** Get Streaming Reduced Quote Request */
|
|
215
|
+
const reducedQuoteRequest = this.createReducedQuotesFeedRequest([]);
|
|
216
|
+
|
|
217
|
+
/** Unsubsribe symbols */
|
|
218
|
+
this.feed.unsubsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
log4js.debug("unsubscribeReducedQuotesFeed error - " + error);
|
|
221
|
+
console.log(error);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
119
224
|
}
|
|
120
225
|
|
|
121
226
|
module.exports = QuotesFeed;
|
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;
|
|
@@ -72,6 +72,7 @@ validateModifyTrade = (object, prds) => {
|
|
|
72
72
|
// .valid(...prdName)
|
|
73
73
|
.required(),
|
|
74
74
|
nstOID: Joi.string().required(),
|
|
75
|
+
curQty: Joi.string().required(),
|
|
75
76
|
}).options({ abortEarly: false });
|
|
76
77
|
|
|
77
78
|
return modifyTradeSchema.validate(object);
|
|
@@ -98,6 +99,34 @@ validateCancelPlaceTrade = (object, prds) => {
|
|
|
98
99
|
return cancelPlaceTradeSchema.validate(object);
|
|
99
100
|
};
|
|
100
101
|
|
|
102
|
+
validateCancelPlaceTradeV1 = (object, prds) => {
|
|
103
|
+
// let prdName = [];
|
|
104
|
+
// if (prds.exc.includes(object.exc)) {
|
|
105
|
+
// prdName = prds.prd[object.exc];
|
|
106
|
+
// }
|
|
107
|
+
const cancelPlaceTradeSchema = Joi.object({
|
|
108
|
+
nstOID: Joi.string().required(),
|
|
109
|
+
exc: Joi.string()
|
|
110
|
+
.valid(...prds.exc)
|
|
111
|
+
.required(),
|
|
112
|
+
ordTyp: Joi.string()
|
|
113
|
+
.valid(...orderTypeArray)
|
|
114
|
+
.required(),
|
|
115
|
+
prdCode: Joi.string()
|
|
116
|
+
// .valid(...prdName)
|
|
117
|
+
.required(),
|
|
118
|
+
curQty: Joi.string().required(),
|
|
119
|
+
flQty: Joi.string().required(),
|
|
120
|
+
trdSym: Joi.string().required(),
|
|
121
|
+
action: Joi.string()
|
|
122
|
+
.valid(...actionTypeArray)
|
|
123
|
+
.required(),
|
|
124
|
+
sym: Joi.string().required(),
|
|
125
|
+
}).options({ abortEarly: false });
|
|
126
|
+
|
|
127
|
+
return cancelPlaceTradeSchema.validate(object);
|
|
128
|
+
};
|
|
129
|
+
|
|
101
130
|
validatePlaceGtcGtdTrade = (object, prds) => {
|
|
102
131
|
// let prdName = [];
|
|
103
132
|
// if (prds.exc.includes(object.exc)) {
|
|
@@ -188,6 +217,7 @@ validateModifyAMOTrade = (object, prds) => {
|
|
|
188
217
|
.required(),
|
|
189
218
|
nstOID: Joi.string().required(),
|
|
190
219
|
sym: Joi.string().required(),
|
|
220
|
+
curQty: Joi.string().required(),
|
|
191
221
|
}).options({ abortEarly: false });
|
|
192
222
|
|
|
193
223
|
return modifyAMOTradeSchema.validate(object);
|
|
@@ -214,6 +244,34 @@ validateCancelAMOTrade = (object, prds) => {
|
|
|
214
244
|
return cancelAMOTradeSchema.validate(object);
|
|
215
245
|
};
|
|
216
246
|
|
|
247
|
+
validateCancelAMOTradeV1 = (object, prds) => {
|
|
248
|
+
// let prdName = [];
|
|
249
|
+
// if (prds.exc.includes(object.exc)) {
|
|
250
|
+
// prdName = prds.prd[object.exc];
|
|
251
|
+
// }
|
|
252
|
+
const cancelAMOTradeSchema = Joi.object({
|
|
253
|
+
nstOID: Joi.string().required(),
|
|
254
|
+
exc: Joi.string()
|
|
255
|
+
.valid(...prds.exc)
|
|
256
|
+
.required(),
|
|
257
|
+
ordTyp: Joi.string()
|
|
258
|
+
.valid(...orderTypeArray)
|
|
259
|
+
.required(),
|
|
260
|
+
prdCode: Joi.string()
|
|
261
|
+
// .valid(...prdName)
|
|
262
|
+
.required(),
|
|
263
|
+
curQty: Joi.string().required(),
|
|
264
|
+
flQty: Joi.string().required(),
|
|
265
|
+
trdSym: Joi.string().required(),
|
|
266
|
+
action: Joi.string()
|
|
267
|
+
.valid(...actionTypeArray)
|
|
268
|
+
.required(),
|
|
269
|
+
sym: Joi.string().required(),
|
|
270
|
+
}).options({ abortEarly: false });
|
|
271
|
+
|
|
272
|
+
return cancelAMOTradeSchema.validate(object);
|
|
273
|
+
};
|
|
274
|
+
|
|
217
275
|
validateConvertPositionCOMM = (object, prds) => {
|
|
218
276
|
// let prdName = [];
|
|
219
277
|
// if (prds.exc.includes(object.exc)) {
|
|
@@ -46,6 +46,38 @@ validateStreamerCallback = (callback) => {
|
|
|
46
46
|
|
|
47
47
|
return UnsubcribeFeedQuoteSchema.validate(unsubcribeFeedQuoteObj);
|
|
48
48
|
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Validator For Subsribe Reduced Quote Feed
|
|
52
|
+
*/
|
|
53
|
+
validateSubscribeReducedQuotesFeed = (callback, symbols) => {
|
|
54
|
+
let subcribeFeedReducedQuoteObj = {
|
|
55
|
+
callback: callback,
|
|
56
|
+
symbols: symbols,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const subcribeFeedReducedQuoteSchema = Joi.object({
|
|
60
|
+
callback: Joi.function().required(),
|
|
61
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
62
|
+
}).options({ abortEarly: false });
|
|
63
|
+
|
|
64
|
+
return subcribeFeedReducedQuoteSchema.validate(subcribeFeedReducedQuoteObj);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Validator For Unsubsribe Reduced Quote Feed
|
|
69
|
+
*/
|
|
70
|
+
validateUnsubscribeReducedQuotesFeed = (symbols) => {
|
|
71
|
+
let unsubcribeFeedReducedQuoteObj = {
|
|
72
|
+
symbols: symbols,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const UnsubcribeFeedReducedQuoteSchema = Joi.object({
|
|
76
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
77
|
+
}).options({ abortEarly: false });
|
|
78
|
+
|
|
79
|
+
return UnsubcribeFeedReducedQuoteSchema.validate(unsubcribeFeedReducedQuoteObj);
|
|
80
|
+
};
|
|
49
81
|
|
|
50
82
|
validateSubscribeOrdersFeed = (accId, userId, callback) => {
|
|
51
83
|
let subcribeOrdersFeedObj = {
|
|
@@ -62,7 +94,69 @@ validateStreamerCallback = (callback) => {
|
|
|
62
94
|
|
|
63
95
|
return subcribeOrdersFeedSchema.validate(subcribeOrdersFeedObj);
|
|
64
96
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
97
|
|
|
68
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Validator For Subsribe MiniQuote Feed
|
|
100
|
+
*/
|
|
101
|
+
validateSubscribeMiniQuoteFeed = (callback, symbols) => {
|
|
102
|
+
let subcribeFeedMiniQuoteObj = {
|
|
103
|
+
callback: callback,
|
|
104
|
+
symbols: symbols,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const subcribeFeedMiniQuoteSchema = Joi.object({
|
|
108
|
+
callback: Joi.function().required(),
|
|
109
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
110
|
+
}).options({ abortEarly: false });
|
|
111
|
+
|
|
112
|
+
return subcribeFeedMiniQuoteSchema.validate(subcribeFeedMiniQuoteObj);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Validator For Unsubsribe MiniQuote Feed
|
|
117
|
+
*/
|
|
118
|
+
validateUnsubscribeMiniQuoteFeed = (symbols) => {
|
|
119
|
+
let unsubcribeFeedMiniQuoteObj = {
|
|
120
|
+
symbols: symbols,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const UnsubcribeFeedMiniQuoteSchema = Joi.object({
|
|
124
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
125
|
+
}).options({ abortEarly: false });
|
|
126
|
+
|
|
127
|
+
return UnsubcribeFeedMiniQuoteSchema.validate(unsubcribeFeedMiniQuoteObj);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Validator For Subsribe Market Depth Feed
|
|
132
|
+
*/
|
|
133
|
+
validateSubscribeDepthFeed = (callback, symbols) => {
|
|
134
|
+
let subcribeFeedDepthObj = {
|
|
135
|
+
callback: callback,
|
|
136
|
+
symbols: symbols,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const subcribeFeedDepthSchema = Joi.object({
|
|
140
|
+
callback: Joi.function().required(),
|
|
141
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
142
|
+
}).options({ abortEarly: false });
|
|
143
|
+
|
|
144
|
+
return subcribeFeedDepthSchema.validate(subcribeFeedDepthObj);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Validator For Unsubsribe Depth Feed
|
|
149
|
+
*/
|
|
150
|
+
validateUnsubscribeDepthFeed = (symbols) => {
|
|
151
|
+
let unsubcribeFeedDepthObj = {
|
|
152
|
+
symbols: symbols,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const UnsubcribeFeedDepthSchema = Joi.object({
|
|
156
|
+
symbols: Joi.array().items(Joi.string().min(1).required()).required(),
|
|
157
|
+
}).options({ abortEarly: false });
|
|
158
|
+
|
|
159
|
+
return UnsubcribeFeedDepthSchema.validate(unsubcribeFeedDepthObj);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
module.exports = { validateStreamerCallback, validateSubscribeQuotesFeed, validateUnsubscribeQuotesFeed, validateSubscribeReducedQuotesFeed, validateUnsubscribeReducedQuotesFeed, validateSubscribeOrdersFeed, validateSubscribeMiniQuoteFeed, validateUnsubscribeMiniQuoteFeed, validateSubscribeDepthFeed, validateUnsubscribeDepthFeed};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const Joi = require("Joi");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validate Market Depth input params
|
|
5
|
+
*/
|
|
6
|
+
validateMarketDepth = (symbol) => {
|
|
7
|
+
const paramsObject = {
|
|
8
|
+
symbol: symbol,
|
|
9
|
+
};
|
|
10
|
+
const depthParamsSchema = Joi.object({
|
|
11
|
+
symbol: Joi.string().required(),
|
|
12
|
+
}).options({ abortEarly: false });
|
|
13
|
+
|
|
14
|
+
return depthParamsSchema.validate(paramsObject);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
validateMarketDepth
|
|
19
|
+
};
|