api_connect_nodejs 2.0.10 → 2.0.12
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 +2 -1
- package/enums/chartExchangeType.js +1 -0
- package/enums/exchangeType.js +1 -0
- package/enums/segmentType.js +11 -0
- package/enums/streamingConstants.js +0 -1
- package/package.json +2 -2
- package/src/apiConnect.js +66 -8
- package/src/chart.js +148 -2
- package/src/config.js +17 -0
- package/src/feed/feed.js +0 -8
- package/src/feed/quotesFeed.js +1 -105
- package/src/http.js +3 -4
- package/src/iniparser.js +3 -0
- package/src/report.js +49 -0
- package/validations/apiConnectValidator.js +156 -37
- package/validations/chartValidator.js +40 -0
- package/validations/reportValidator.js +35 -0
- package/api_connect_nodejs-2.0.10.tgz +0 -0
package/conf/settings.ini
CHANGED
|
@@ -6,10 +6,11 @@ BasePathEq = https://nc.nuvamawealth.com/edelmw-eq/eq/
|
|
|
6
6
|
BasePathComm = https://nc.nuvamawealth.com/edelmw-comm/comm/
|
|
7
7
|
BasePathMf = https://nc.nuvamawealth.com/edelmw-mf/mf/
|
|
8
8
|
BasePathContent = https://nc.nuvamawealth.com/edelmw-content/content/
|
|
9
|
+
BasePathReport = https://nc.nuvamawealth.com/app-report/equity/
|
|
9
10
|
EquityContractURL = https://nc.nuvamawealth.com/app/toccontracts/instruments.zip
|
|
10
11
|
MFContractURL = https://nc.nuvamawealth.com/app/toccontracts/mfInstruments.zip
|
|
11
12
|
|
|
12
|
-
ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
13
|
+
ApiIdKey = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOjAsImZmIjoiVyIsImJkIjoid2ViLXBjIiwibmJmIjoxNzEwNzUzMjIzLCJzcmMiOiJlbXRtdyIsImF2IjoiMi4wLjEyIiwiYXBwaWQiOiI3MTI5YzEzOGFmZjk4NjMyZWRhMjU3ZDFhNjMzZTIwNCIsImlzcyI6ImVtdCIsImV4cCI6MTcxMDc4NjYwMCwiaWF0IjoxNzEwNzUzNTIzfQ.6qtvIewJcvfeKUJmFxRtz06x0xgSFAVW7qXvcgUfulo
|
|
13
14
|
TlsVersion = 1.2
|
|
14
15
|
LogLevel = All
|
|
15
16
|
|
package/enums/exchangeType.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api_connect_nodejs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Command to run :",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@joi/date": "^2.1.0",
|
|
11
|
-
|
|
11
|
+
"chai": "^4.3.6",
|
|
12
12
|
"csv-parser": "^3.0.0",
|
|
13
13
|
"csv-writer": "^1.6.0",
|
|
14
14
|
"fast-csv": "^4.3.6",
|
package/src/apiConnect.js
CHANGED
|
@@ -4,6 +4,7 @@ const log4js = require("./logger.js");
|
|
|
4
4
|
const Order = require("./order");
|
|
5
5
|
const Chart = require("./chart");
|
|
6
6
|
const Quote = require("./quote");
|
|
7
|
+
const Report = require("./report");
|
|
7
8
|
const LiveNews = require("./liveNews");
|
|
8
9
|
const Watchlist = require("./watchlist");
|
|
9
10
|
const ResearchCalls = require("./researchCalls");
|
|
@@ -79,13 +80,13 @@ class APIConnect {
|
|
|
79
80
|
const checkDone = (res) => {
|
|
80
81
|
count = count - 1;
|
|
81
82
|
if (count == 0) {
|
|
82
|
-
|
|
83
|
+
resolve(res);
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
86
|
const readFilePromise = new Promise((resolve, reject) => {
|
|
86
87
|
fs.readFile(this.fileName, "utf8", (err, data) => {
|
|
87
88
|
if (err) {
|
|
88
|
-
|
|
89
|
+
//var promises=[]
|
|
89
90
|
// if file doesn't exist, then generate it
|
|
90
91
|
// these two functions will fill the __constants and generate ${fileName}
|
|
91
92
|
// promises.push(this.__GenerateVendorSession(this.apiKey, this.password, this.reqId));
|
|
@@ -103,7 +104,7 @@ class APIConnect {
|
|
|
103
104
|
})
|
|
104
105
|
.catch((err) => reject(err));
|
|
105
106
|
} else {
|
|
106
|
-
|
|
107
|
+
const j = JSON.parse(data);
|
|
107
108
|
this.__constants.VendorSession = j.vt;
|
|
108
109
|
this.__constants.JSession = j.auth;
|
|
109
110
|
this.__constants.eqAccId = j.eqaccid;
|
|
@@ -126,15 +127,15 @@ class APIConnect {
|
|
|
126
127
|
// Check if ${fileName} exists
|
|
127
128
|
readFilePromise
|
|
128
129
|
.then((res) => {
|
|
129
|
-
|
|
130
|
+
count++;
|
|
130
131
|
this.__CheckUpdate().then(checkDone).catch(reject);
|
|
131
132
|
this.excsAndprdDpNm = this.__constants.getProductsAndExchange(
|
|
132
133
|
this.__constants.prds
|
|
133
134
|
);
|
|
134
|
-
|
|
135
|
+
this.__Instruments()
|
|
135
136
|
.then(async (res) => {
|
|
136
137
|
//console.log("instrument then");
|
|
137
|
-
|
|
138
|
+
checkDone(res);
|
|
138
139
|
})
|
|
139
140
|
.catch((err) => reject(err));
|
|
140
141
|
})
|
|
@@ -496,7 +497,7 @@ class APIConnect {
|
|
|
496
497
|
* @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
|
|
497
498
|
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
498
499
|
* @param {string} symbol
|
|
499
|
-
* @param {"NSE" | "BSE" | "NFO" | "
|
|
500
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
500
501
|
* @param {string} tillDate yyyy-MM-dd
|
|
501
502
|
* @param {boolean} includeContinuousFuture
|
|
502
503
|
* @returns
|
|
@@ -529,7 +530,7 @@ class APIConnect {
|
|
|
529
530
|
* @param {"D1" | "W1" | "MN1"} interval
|
|
530
531
|
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
531
532
|
* @param {string} symbol
|
|
532
|
-
* @param {"NSE" | "BSE" | "NFO" | "
|
|
533
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
533
534
|
* @param {string} tillDate yyyy-MM-dd
|
|
534
535
|
* @param {boolean} includeContinuousFuture
|
|
535
536
|
* @returns
|
|
@@ -557,6 +558,41 @@ class APIConnect {
|
|
|
557
558
|
return response;
|
|
558
559
|
};
|
|
559
560
|
|
|
561
|
+
/**
|
|
562
|
+
*
|
|
563
|
+
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
564
|
+
* @param {string} symbol
|
|
565
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
566
|
+
* @param {string} fromDate yyyy-MM-dd
|
|
567
|
+
* @param {string} toDate yyyy-MM-dd
|
|
568
|
+
* @param {boolean} includeContinuousFuture
|
|
569
|
+
* @returns
|
|
570
|
+
*/
|
|
571
|
+
getCustomPeriodChart = (
|
|
572
|
+
assetType,
|
|
573
|
+
symbol,
|
|
574
|
+
exchangeType,
|
|
575
|
+
fromDate,
|
|
576
|
+
toDate,
|
|
577
|
+
includeContinuousFuture = false
|
|
578
|
+
) => {
|
|
579
|
+
let response = {};
|
|
580
|
+
log4js.info("getCustomPeriodChart method is called.");
|
|
581
|
+
let interval = "D1";
|
|
582
|
+
const chartObj = new Chart(this.__http, this.__config, this.__constants);
|
|
583
|
+
response = chartObj.getCustomPeriodChartAPI(
|
|
584
|
+
interval,
|
|
585
|
+
assetType,
|
|
586
|
+
symbol,
|
|
587
|
+
exchangeType,
|
|
588
|
+
fromDate,
|
|
589
|
+
toDate,
|
|
590
|
+
includeContinuousFuture
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
return response;
|
|
594
|
+
};
|
|
595
|
+
|
|
560
596
|
//Get News Categories
|
|
561
597
|
getNewsCategories = () => {
|
|
562
598
|
log4js.info("Inside getNewsCategories method");
|
|
@@ -1268,6 +1304,7 @@ class APIConnect {
|
|
|
1268
1304
|
exc: Exchange,
|
|
1269
1305
|
prdCode: this.__constants.getValidProductCode(this.fileName, Exchange, ProductCode),
|
|
1270
1306
|
ordTyp: Order_Type,
|
|
1307
|
+
curQty: CurrentQuantity,
|
|
1271
1308
|
};
|
|
1272
1309
|
|
|
1273
1310
|
if (Exchange == "MCX" || Exchange == "NCDEX") {
|
|
@@ -2476,6 +2513,27 @@ class APIConnect {
|
|
|
2476
2513
|
return response;
|
|
2477
2514
|
};
|
|
2478
2515
|
|
|
2516
|
+
//Get TRansaction History
|
|
2517
|
+
/**
|
|
2518
|
+
*
|
|
2519
|
+
* @param {string} segment
|
|
2520
|
+
* @param {string} fromDate
|
|
2521
|
+
* @param {string} toDate
|
|
2522
|
+
* @returns
|
|
2523
|
+
*/
|
|
2524
|
+
getTransactionHistory = (
|
|
2525
|
+
segment, fromDate, toDate
|
|
2526
|
+
) => {
|
|
2527
|
+
let response = {};
|
|
2528
|
+
log4js.info("getTransactionHistory method is called.");
|
|
2529
|
+
const reportObj = new Report(this.__http, this.__config, this.__constants);
|
|
2530
|
+
response = reportObj.getTransactionHistoryAPI(
|
|
2531
|
+
segment, fromDate, toDate
|
|
2532
|
+
);
|
|
2533
|
+
|
|
2534
|
+
return response;
|
|
2535
|
+
};
|
|
2536
|
+
|
|
2479
2537
|
//CheckDependentAndUpdateData
|
|
2480
2538
|
/**
|
|
2481
2539
|
*
|
package/src/chart.js
CHANGED
|
@@ -71,6 +71,66 @@ class Chart {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Modifying the response
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
datewithoutTime = function (inputDate) {
|
|
79
|
+
var d = new Date(inputDate);
|
|
80
|
+
d.setHours(0, 0, 0, 0);
|
|
81
|
+
return d;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
modifyResponseForCustomPeriod = async (response, toDate) => {
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const modifyResponse = {};
|
|
88
|
+
let msgID = "";
|
|
89
|
+
let srvTm = "";
|
|
90
|
+
var convertedToDate = new Date(toDate);
|
|
91
|
+
const charts = [];
|
|
92
|
+
if (Object.keys(response).length !== 0) {
|
|
93
|
+
msgID = response["msgID"];
|
|
94
|
+
srvTm = response["srvTm"];
|
|
95
|
+
const data = response.data;
|
|
96
|
+
const pltPnts = data.pltPnts;
|
|
97
|
+
if (
|
|
98
|
+
Object.keys(data).length !== 0 &&
|
|
99
|
+
Object.keys(pltPnts).length !== 0
|
|
100
|
+
) {
|
|
101
|
+
const isArray = await this.checkResponseHaveArrayOrNot(pltPnts);
|
|
102
|
+
if (isArray && pltPnts.ltt.length > 0) {
|
|
103
|
+
modifyResponse["nextTillDate"] = pltPnts.ltt[0];
|
|
104
|
+
for (let i = 0; i < pltPnts.ltt.length; i++) {
|
|
105
|
+
|
|
106
|
+
var convertedPlotPointDate = new Date(pltPnts.ltt[i]);
|
|
107
|
+
|
|
108
|
+
if(this.datewithoutTime(convertedPlotPointDate) > this.datewithoutTime(convertedToDate)) {
|
|
109
|
+
break
|
|
110
|
+
}
|
|
111
|
+
const dataArray = [];
|
|
112
|
+
dataArray[0] = pltPnts.ltt[i];
|
|
113
|
+
dataArray[1] = pltPnts.open[i];
|
|
114
|
+
dataArray[2] = pltPnts.high[i];
|
|
115
|
+
dataArray[3] = pltPnts.low[i];
|
|
116
|
+
dataArray[4] = pltPnts.close[i];
|
|
117
|
+
dataArray[5] = pltPnts.vol[i];
|
|
118
|
+
charts.push(dataArray);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
modifyResponse["data"] = charts;
|
|
125
|
+
modifyResponse["msgID"] = msgID;
|
|
126
|
+
modifyResponse["srvTm"] = srvTm;
|
|
127
|
+
log4js.debug("modifyResponse for Custom period:" + JSON.stringify(modifyResponse));
|
|
128
|
+
return modifyResponse;
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return Promise.reject(e);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
74
134
|
convertToBoolean = async (value) => {
|
|
75
135
|
if (value === "TRUE" || value === "true") {
|
|
76
136
|
return true;
|
|
@@ -94,7 +154,7 @@ class Chart {
|
|
|
94
154
|
* @param {"M1" | "M3" | "M5" | "M15" | "M30" | "H1"} interval
|
|
95
155
|
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
96
156
|
* @param {string} symbol
|
|
97
|
-
* @param {"NSE" | "BSE" | "NFO" | "
|
|
157
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
98
158
|
* @param {string} tillDate
|
|
99
159
|
* @param {boolean} includeContinuousFuture
|
|
100
160
|
* @returns
|
|
@@ -177,7 +237,7 @@ class Chart {
|
|
|
177
237
|
* @param {"D1" | "W1" | "MN1"} interval
|
|
178
238
|
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
179
239
|
* @param {string} symbol
|
|
180
|
-
* @param {"NSE" | "BSE" | "NFO" | "
|
|
240
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
181
241
|
* @param {string} tillDate yyyy-MM-dd
|
|
182
242
|
* @param {boolean} includeContinuousFuture
|
|
183
243
|
* @returns
|
|
@@ -254,5 +314,91 @@ class Chart {
|
|
|
254
314
|
return Promise.reject(error);
|
|
255
315
|
}
|
|
256
316
|
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
*
|
|
320
|
+
* @param {"D1" | "W1" | "MN1"} interval
|
|
321
|
+
* @param {"FUTSTK" | "FUTIDX" | "FUTCUR" | "FUTCOM" | "OPTIDX" | "OPTSTK" | "OPTCUR" | "OPTFUT" | "EQUITY" | "INDEX"} assetType
|
|
322
|
+
* @param {string} symbol
|
|
323
|
+
* @param {"NSE" | "BSE" | "NFO" | "BFO" | "CDS" | "MCX" | "NCDEX" | "INDEX"} exchangeType
|
|
324
|
+
* @param {string} fromDate yyyy-MM-dd
|
|
325
|
+
* @param {string} toDate yyyy-MM-dd
|
|
326
|
+
* @param {boolean} includeContinuousFuture
|
|
327
|
+
* @returns
|
|
328
|
+
*/
|
|
329
|
+
getCustomPeriodChartAPI = async (
|
|
330
|
+
interval,
|
|
331
|
+
assetType,
|
|
332
|
+
symbol,
|
|
333
|
+
exchangeType,
|
|
334
|
+
fromDate,
|
|
335
|
+
toDate,
|
|
336
|
+
includeContinuousFuture
|
|
337
|
+
) => {
|
|
338
|
+
let result = {};
|
|
339
|
+
try {
|
|
340
|
+
//Convert into boolean
|
|
341
|
+
includeContinuousFuture = await this.convertToBoolean(
|
|
342
|
+
includeContinuousFuture
|
|
343
|
+
);
|
|
344
|
+
interval = "D1"
|
|
345
|
+
/**
|
|
346
|
+
* Validate eod chart params
|
|
347
|
+
*/
|
|
348
|
+
const validateResponse = validateChartCustomPeriod(
|
|
349
|
+
interval,
|
|
350
|
+
assetType,
|
|
351
|
+
symbol,
|
|
352
|
+
exchangeType,
|
|
353
|
+
fromDate,
|
|
354
|
+
toDate,
|
|
355
|
+
includeContinuousFuture
|
|
356
|
+
);
|
|
357
|
+
if (validateResponse.error) {
|
|
358
|
+
log4js.debug(
|
|
359
|
+
"CustomPeriod chart validation error - " + JSON.stringify(validateResponse.error.details)
|
|
360
|
+
);
|
|
361
|
+
return Promise.reject(validateResponse.error.details);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
//Request Body
|
|
365
|
+
const requestBodyData = this.chartRequestBody();
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* If AssetType Amongst FUTIDX, FUTSTK,FUTCUR,FUTCOM then we take user input(includeContinuousFuture) otherwise set false
|
|
369
|
+
*/
|
|
370
|
+
if (!Object.values(futureAssetType).includes(assetType)) {
|
|
371
|
+
includeContinuousFuture = false;
|
|
372
|
+
} else {
|
|
373
|
+
requestBodyData.conti = includeContinuousFuture;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
requestBodyData.frmDt = fromDate;
|
|
377
|
+
requestBodyData.toDt = toDate;
|
|
378
|
+
requestBodyData.prdTyp = "CUST"
|
|
379
|
+
delete requestBodyData.ltt;
|
|
380
|
+
|
|
381
|
+
const url = this.__config.ChartURL(
|
|
382
|
+
interval,
|
|
383
|
+
exchangeType,
|
|
384
|
+
assetType,
|
|
385
|
+
symbol
|
|
386
|
+
);
|
|
387
|
+
log4js.debug("EOD URL -" + url);
|
|
388
|
+
|
|
389
|
+
const response = await this.__http.PostMethod(url, requestBodyData);
|
|
390
|
+
if (result.length !== 0) {
|
|
391
|
+
result = this.modifyResponseForCustomPeriod(response, toDate);
|
|
392
|
+
} else {
|
|
393
|
+
result = response;
|
|
394
|
+
}
|
|
395
|
+
log4js.debug("EOD Result :" + JSON.stringify(result));
|
|
396
|
+
return result;
|
|
397
|
+
} catch (error) {
|
|
398
|
+
log4js.debug("EOD error - " + error);
|
|
399
|
+
return Promise.reject(error);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
257
403
|
}
|
|
258
404
|
module.exports = Chart;
|
package/src/config.js
CHANGED
|
@@ -5,8 +5,10 @@ class __Config {
|
|
|
5
5
|
baseurleq = "/edelmw-eq/eq/";
|
|
6
6
|
baseurlcomm = "/edelmw-comm/comm/";
|
|
7
7
|
baseurlcontent = "/edelmw-content/content/";
|
|
8
|
+
baseurlreport = "/app-report/equity/";
|
|
8
9
|
baseurllogin = "/edelmw-login/login/";
|
|
9
10
|
baseurlmf = "/edelmw-mf/mf/";
|
|
11
|
+
|
|
10
12
|
EquityContractURL = "/app/toccontracts/instruments.zip";
|
|
11
13
|
MFContractURL = "/app/toccontracts/mfInstruments.zip";
|
|
12
14
|
|
|
@@ -16,6 +18,7 @@ class __Config {
|
|
|
16
18
|
this.baseurllogin = configData.BasePathLogin;
|
|
17
19
|
this.baseurlmf = configData.BasePathMf;
|
|
18
20
|
this.baseurlcontent = configData.BasePathContent;
|
|
21
|
+
this.baseurlreport = configData.BasePathReport;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
ChartURL = function (interval, exc, aType, symbol) {
|
|
@@ -320,6 +323,20 @@ class __Config {
|
|
|
320
323
|
MarketDepthURL = function (symbol) {
|
|
321
324
|
return this.baseurlcontent + "quote/scrip/" + symbol;
|
|
322
325
|
};
|
|
326
|
+
|
|
327
|
+
//TRANSACTION HISTORY
|
|
328
|
+
TransactionHistoryURL = function (accountCode, fromDate, toDate) {
|
|
329
|
+
return (
|
|
330
|
+
this.baseurlreport +
|
|
331
|
+
"pnl/transaction" +
|
|
332
|
+
"?accountId=" +
|
|
333
|
+
accountCode +
|
|
334
|
+
"&fromDate=" +
|
|
335
|
+
fromDate +
|
|
336
|
+
"&toDate=" +
|
|
337
|
+
toDate
|
|
338
|
+
);
|
|
339
|
+
};
|
|
323
340
|
}
|
|
324
341
|
|
|
325
342
|
module.exports = __Config;
|
package/src/feed/feed.js
CHANGED
|
@@ -91,14 +91,6 @@ class Feed {
|
|
|
91
91
|
"callback"
|
|
92
92
|
];
|
|
93
93
|
callbackMethod(null, result, null);
|
|
94
|
-
} else if (
|
|
95
|
-
streamingType.toLowerCase() == "quote3".toLowerCase()
|
|
96
|
-
) {
|
|
97
|
-
let callbackMethod =
|
|
98
|
-
this.requestsList[streamingConstants.QUOTE_SREAM_REQ_CODE][
|
|
99
|
-
"callback"
|
|
100
|
-
];
|
|
101
|
-
callbackMethod(null, result, null);
|
|
102
94
|
} else if (
|
|
103
95
|
streamingType.toLowerCase() == "quote".toLowerCase()
|
|
104
96
|
) {
|
package/src/feed/quotesFeed.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const log4js = require("../logger");
|
|
2
2
|
const configData = require("../iniparser");
|
|
3
|
-
const {
|
|
3
|
+
const { REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
4
|
const {
|
|
5
|
-
validateSubscribeQuotesFeed,
|
|
6
|
-
validateUnsubscribeQuotesFeed,
|
|
7
5
|
validateSubscribeReducedQuotesFeed,
|
|
8
6
|
validateUnsubscribeReducedQuotesFeed,
|
|
9
7
|
} = require("../../validations/feedStreamerValidator");
|
|
@@ -17,108 +15,6 @@ class QuotesFeed {
|
|
|
17
15
|
this.feed = feed;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* QutoesFeed RequestBody Structure
|
|
22
|
-
* Return QuotesFeed RequestBody Structure
|
|
23
|
-
* @function quotesFeedRequestBody
|
|
24
|
-
* @returns object
|
|
25
|
-
*/
|
|
26
|
-
requestBody = () => {
|
|
27
|
-
return {
|
|
28
|
-
request: {
|
|
29
|
-
streaming_type: "quote3",
|
|
30
|
-
data: {
|
|
31
|
-
"accType": "EQ",
|
|
32
|
-
symbols: [],
|
|
33
|
-
},
|
|
34
|
-
formFactor: configData.formFactor,
|
|
35
|
-
appID: configData.ApiIdKey,
|
|
36
|
-
response_format: "json",
|
|
37
|
-
request_type: "",
|
|
38
|
-
},
|
|
39
|
-
echo: {},
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create QuotesFeed RequestBody
|
|
45
|
-
* Return QuotesFeed RequestBody
|
|
46
|
-
* @function createQuotesFeedRequest
|
|
47
|
-
* @param {Object[]} symbols - Array of subsribe Symbols
|
|
48
|
-
* @param {boolean} order - true for subsribe and false for unsubsribe
|
|
49
|
-
* @returns object
|
|
50
|
-
*/
|
|
51
|
-
createQuotesFeedRequest = (symbols, quote = false) => {
|
|
52
|
-
let body = {};
|
|
53
|
-
try {
|
|
54
|
-
body = this.requestBody();
|
|
55
|
-
const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
|
|
56
|
-
|
|
57
|
-
body.request.data.symbols = symset;
|
|
58
|
-
|
|
59
|
-
if (quote) {
|
|
60
|
-
body.request.request_type = "subscribe";
|
|
61
|
-
} else {
|
|
62
|
-
body.request.request_type = "unsubscribe";
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
log4js.debug("createQuotesFeedRequest error - " + error);
|
|
66
|
-
} finally {
|
|
67
|
-
return body;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 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.
|
|
73
|
-
* @async
|
|
74
|
-
* @function subscribeQuotesFeed
|
|
75
|
-
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
76
|
-
* @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
|
|
77
|
-
* @returns
|
|
78
|
-
*/
|
|
79
|
-
subscribeQuotesFeed = async (symbols, callback) => {
|
|
80
|
-
try {
|
|
81
|
-
/** Validation Start */
|
|
82
|
-
const validateResponse = validateSubscribeQuotesFeed(callback, symbols);
|
|
83
|
-
|
|
84
|
-
if (validateResponse.error) {
|
|
85
|
-
log4js.debug(
|
|
86
|
-
"subscribeQuotesFeed validation error - " +
|
|
87
|
-
validateResponse.error.details
|
|
88
|
-
);
|
|
89
|
-
return Promise.reject(validateResponse.error.details);
|
|
90
|
-
}
|
|
91
|
-
/** Validation End */
|
|
92
|
-
|
|
93
|
-
/** Create Streaming Quote Request */
|
|
94
|
-
let quoteRequest = this.createQuotesFeedRequest(symbols, true);
|
|
95
|
-
/** Call connect method of Feed Class */
|
|
96
|
-
this.feed.subsribe(QUOTE_SREAM_REQ_CODE, quoteRequest, callback);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
log4js.debug("subscribeQuotesFeed error - " + error);
|
|
99
|
-
console.log(error);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
105
|
-
* @async
|
|
106
|
-
* @function unsubscribeQuotesFeed
|
|
107
|
-
* @returns
|
|
108
|
-
*/
|
|
109
|
-
unsubscribeQuotesFeed = async () => {
|
|
110
|
-
try {
|
|
111
|
-
/** Get Streaming Quote Request */
|
|
112
|
-
const quoteRequest = this.createQuotesFeedRequest([]);
|
|
113
|
-
|
|
114
|
-
/** Unsubsribe symbols */
|
|
115
|
-
this.feed.unsubsribe(QUOTE_SREAM_REQ_CODE, quoteRequest);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
log4js.debug("unsubscribeQuotesFeed error - " + error);
|
|
118
|
-
console.log(error);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
18
|
//Reduced Quote
|
|
123
19
|
|
|
124
20
|
/**
|
package/src/http.js
CHANGED
|
@@ -30,12 +30,12 @@ class __Http {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
GetMethod(url, sendSource = true) {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
let headers = this.createHeaders(sendSource);
|
|
34
|
+
const options = { hostname: this.__baseurl, path: url, headers: headers };
|
|
35
35
|
|
|
36
36
|
return new Promise((resolve, reject) => {
|
|
37
37
|
const req = https.get(options, (res) => {
|
|
38
|
-
|
|
38
|
+
let body = [];
|
|
39
39
|
res.on("data", (d) => {
|
|
40
40
|
body.push(d);
|
|
41
41
|
});
|
|
@@ -43,7 +43,6 @@ class __Http {
|
|
|
43
43
|
res.on("end", () => {
|
|
44
44
|
try {
|
|
45
45
|
body = JSON.parse(Buffer.concat(body).toString());
|
|
46
|
-
|
|
47
46
|
if (res.headers.appidkey) {
|
|
48
47
|
this.__constants.AppIdKey = res.headers.appidkey;
|
|
49
48
|
}
|
package/src/iniparser.js
CHANGED
|
@@ -6,6 +6,7 @@ BasePathEq = "";
|
|
|
6
6
|
BasePathComm = "";
|
|
7
7
|
BasePathMf = "";
|
|
8
8
|
BasePathContent = "";
|
|
9
|
+
BasePathReport = "";
|
|
9
10
|
ApiIdKey = "";
|
|
10
11
|
LogLevel = "";
|
|
11
12
|
hostName = "";
|
|
@@ -19,6 +20,7 @@ const ConfigParser = function () {
|
|
|
19
20
|
BasePathComm = config.GLOBAL.BasePathComm;
|
|
20
21
|
BasePathMf = config.GLOBAL.BasePathMf;
|
|
21
22
|
BasePathContent = config.GLOBAL.BasePathContent;
|
|
23
|
+
BasePathReport = config.GLOBAL.BasePathReport;
|
|
22
24
|
ApiIdKey = config.GLOBAL.ApiIdKey;
|
|
23
25
|
LogLevel = config.GLOBAL.LogLevel;
|
|
24
26
|
hostName = config.STREAM.hostName;
|
|
@@ -39,4 +41,5 @@ module.exports = {
|
|
|
39
41
|
port,
|
|
40
42
|
formFactor,
|
|
41
43
|
BasePathContent,
|
|
44
|
+
BasePathReport,
|
|
42
45
|
};
|
package/src/report.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const log4js = require("./logger.js");
|
|
2
|
+
const {
|
|
3
|
+
validateTransactionHistory,
|
|
4
|
+
} = require("../validations/reportValidator");
|
|
5
|
+
const segmentType = require("../enums/segmentType.js");
|
|
6
|
+
|
|
7
|
+
class Report {
|
|
8
|
+
constructor(http, config, constants) {
|
|
9
|
+
this.__http = http;
|
|
10
|
+
this.__config = config;
|
|
11
|
+
this.__constants = constants;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {string} symbol
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getTransactionHistoryAPI = async (segment, fromDate, toDate) => {
|
|
20
|
+
try {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Validate Transaction History params
|
|
24
|
+
*/
|
|
25
|
+
const validateResponse = validateTransactionHistory(
|
|
26
|
+
segment,
|
|
27
|
+
fromDate,
|
|
28
|
+
toDate,
|
|
29
|
+
);
|
|
30
|
+
if (validateResponse.error) {
|
|
31
|
+
log4js.debug(
|
|
32
|
+
"Transaction History validation error - " + validateResponse.error.details
|
|
33
|
+
);
|
|
34
|
+
return Promise.reject(validateResponse.error.details);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const url = (segment == segmentType.EQUITY)
|
|
38
|
+
? this.__config.TransactionHistoryURL(this.__constants.eqAccId, fromDate, toDate)
|
|
39
|
+
: this.__config.TransactionHistoryURL(this.__constants.coAccId, fromDate, toDate);
|
|
40
|
+
log4js.debug("Transaction History URL -" + url);
|
|
41
|
+
const response = await this.__http.GetMethod(url, false);
|
|
42
|
+
return response;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
log4js.debug("Transaction History error - " + error);
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
module.exports = Report;
|
|
@@ -30,11 +30,20 @@ validatePlaceTrade = (object, prds) => {
|
|
|
30
30
|
ordTyp: Joi.string()
|
|
31
31
|
.valid(...orderTypeArray)
|
|
32
32
|
.required(),
|
|
33
|
-
qty: Joi.number()
|
|
33
|
+
qty: Joi.number()
|
|
34
|
+
.positive()
|
|
35
|
+
.required(),
|
|
34
36
|
sym: Joi.string().required(),
|
|
35
|
-
lmPrc: Joi.string()
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
lmPrc: Joi.string()
|
|
38
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
39
|
+
.required()
|
|
40
|
+
.error(new Error('Parameter Limit Price cannot be Negative or non-numeric')),
|
|
41
|
+
dscQty: Joi.string()
|
|
42
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
43
|
+
.error(new Error('Parameter Disclosed Quantity cannot be Negative or non-numeric')),
|
|
44
|
+
trgPrc: Joi.string()
|
|
45
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
46
|
+
.error(new Error('Parameter Trigger price cannot be Negative or non-numeric')),
|
|
38
47
|
prdCode: Joi.string()
|
|
39
48
|
// .valid(...prdName)
|
|
40
49
|
.required(),
|
|
@@ -63,18 +72,29 @@ validateModifyTrade = (object, prds) => {
|
|
|
63
72
|
ordTyp: Joi.string()
|
|
64
73
|
.valid(...orderTypeArray)
|
|
65
74
|
.required(),
|
|
66
|
-
qty: Joi.number()
|
|
75
|
+
qty: Joi.number()
|
|
76
|
+
.positive()
|
|
77
|
+
.required(),
|
|
67
78
|
dscQty: Joi.string(),
|
|
68
79
|
sym: Joi.string().required(),
|
|
69
|
-
lmPrc: Joi.number()
|
|
70
|
-
|
|
80
|
+
lmPrc: Joi.number()
|
|
81
|
+
.min(0)
|
|
82
|
+
.required(),
|
|
83
|
+
trgPrc: Joi.string()
|
|
84
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
85
|
+
.error(new Error('Parameter trigger price cannot be Negative or non-numeric')),
|
|
71
86
|
prdCode: Joi.string()
|
|
72
87
|
// .valid(...prdName)
|
|
73
88
|
.required(),
|
|
74
89
|
nstOID: Joi.string().required(),
|
|
75
|
-
curQty: Joi.string()
|
|
90
|
+
curQty: Joi.string()
|
|
91
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
92
|
+
.required()
|
|
93
|
+
.error(new Error('Parameter Current Quantity cannot be Negative or non-numeric')),
|
|
76
94
|
}).options({ abortEarly: false });
|
|
77
95
|
|
|
96
|
+
const re = modifyTradeSchema.validate(object);
|
|
97
|
+
console.log(re);
|
|
78
98
|
return modifyTradeSchema.validate(object);
|
|
79
99
|
};
|
|
80
100
|
|
|
@@ -94,8 +114,13 @@ validateCancelPlaceTrade = (object, prds) => {
|
|
|
94
114
|
prdCode: Joi.string()
|
|
95
115
|
// .valid(...prdName)
|
|
96
116
|
.required(),
|
|
117
|
+
curQty: Joi.string()
|
|
118
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
119
|
+
.error(new Error('Parameter Current Quantity cannot be Negative or non-numeric'))
|
|
97
120
|
}).options({ abortEarly: false });
|
|
98
121
|
|
|
122
|
+
const re = cancelPlaceTradeSchema.validate(object);
|
|
123
|
+
console.log(re);
|
|
99
124
|
return cancelPlaceTradeSchema.validate(object);
|
|
100
125
|
};
|
|
101
126
|
|
|
@@ -104,6 +129,7 @@ validateCancelPlaceTradeV1 = (object, prds) => {
|
|
|
104
129
|
// if (prds.exc.includes(object.exc)) {
|
|
105
130
|
// prdName = prds.prd[object.exc];
|
|
106
131
|
// }
|
|
132
|
+
|
|
107
133
|
const cancelPlaceTradeSchema = Joi.object({
|
|
108
134
|
nstOID: Joi.string().required(),
|
|
109
135
|
exc: Joi.string()
|
|
@@ -115,8 +141,12 @@ validateCancelPlaceTradeV1 = (object, prds) => {
|
|
|
115
141
|
prdCode: Joi.string()
|
|
116
142
|
// .valid(...prdName)
|
|
117
143
|
.required(),
|
|
118
|
-
curQty: Joi.string().required()
|
|
119
|
-
|
|
144
|
+
curQty: Joi.string().required()
|
|
145
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
146
|
+
.error(new Error('Parameter Current Quantity cannot be Negative or non-numeric')),
|
|
147
|
+
flQty: Joi.string().required()
|
|
148
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
149
|
+
.error(new Error('Parameter Fill Quantity cannot be Negative or non-numeric')),
|
|
120
150
|
trdSym: Joi.string().required(),
|
|
121
151
|
action: Joi.string()
|
|
122
152
|
.valid(...actionTypeArray)
|
|
@@ -124,6 +154,8 @@ validateCancelPlaceTradeV1 = (object, prds) => {
|
|
|
124
154
|
sym: Joi.string().required(),
|
|
125
155
|
}).options({ abortEarly: false });
|
|
126
156
|
|
|
157
|
+
const re = cancelPlaceTradeSchema.validate(object);
|
|
158
|
+
console.log(re);
|
|
127
159
|
return cancelPlaceTradeSchema.validate(object);
|
|
128
160
|
};
|
|
129
161
|
|
|
@@ -146,8 +178,12 @@ validatePlaceGtcGtdTrade = (object, prds) => {
|
|
|
146
178
|
ordTyp: Joi.string()
|
|
147
179
|
.valid(...orderTypeArray)
|
|
148
180
|
.required(),
|
|
149
|
-
qty: Joi.number()
|
|
150
|
-
|
|
181
|
+
qty: Joi.number()
|
|
182
|
+
.positive()
|
|
183
|
+
.required(),
|
|
184
|
+
lmPrc: Joi.number()
|
|
185
|
+
.min(0)
|
|
186
|
+
.required(),
|
|
151
187
|
prdCode: Joi.string()
|
|
152
188
|
// .valid(...prdName)
|
|
153
189
|
.required(),
|
|
@@ -155,6 +191,8 @@ validatePlaceGtcGtdTrade = (object, prds) => {
|
|
|
155
191
|
sym: Joi.string().required(),
|
|
156
192
|
}).options({ abortEarly: false });
|
|
157
193
|
|
|
194
|
+
const re = PlaceGtcGtdTradeSchema.validate(object);
|
|
195
|
+
console.log(re);
|
|
158
196
|
return PlaceGtcGtdTradeSchema.validate(object);
|
|
159
197
|
};
|
|
160
198
|
validatePlaceAMOTrade = (object, prds) => {
|
|
@@ -176,16 +214,24 @@ validatePlaceAMOTrade = (object, prds) => {
|
|
|
176
214
|
ordTyp: Joi.string()
|
|
177
215
|
.valid(...orderTypeArray)
|
|
178
216
|
.required(),
|
|
179
|
-
qty: Joi.number()
|
|
217
|
+
qty: Joi.number()
|
|
218
|
+
.positive()
|
|
219
|
+
.required(),
|
|
180
220
|
dscQty: Joi.string(),
|
|
181
221
|
sym: Joi.string().required(),
|
|
182
|
-
lmPrc: Joi.number()
|
|
183
|
-
|
|
222
|
+
lmPrc: Joi.number()
|
|
223
|
+
.min(0)
|
|
224
|
+
.required(),
|
|
225
|
+
trgPrc: Joi.string()
|
|
226
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
227
|
+
.error(new Error('Parameter trigger price cannot be Negative or non-numeric')),
|
|
184
228
|
prdCode: Joi.string()
|
|
185
229
|
// .valid(...prdName)
|
|
186
230
|
.required(),
|
|
187
231
|
}).options({ abortEarly: false });
|
|
188
232
|
|
|
233
|
+
const re = placeAMOTradeSchema.validate(object);
|
|
234
|
+
console.log(re);
|
|
189
235
|
return placeAMOTradeSchema.validate(object);
|
|
190
236
|
};
|
|
191
237
|
|
|
@@ -208,18 +254,32 @@ validateModifyAMOTrade = (object, prds) => {
|
|
|
208
254
|
ordTyp: Joi.string()
|
|
209
255
|
.valid(...orderTypeArray)
|
|
210
256
|
.required(),
|
|
211
|
-
qty: Joi.number()
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
257
|
+
qty: Joi.number()
|
|
258
|
+
.positive()
|
|
259
|
+
.required(),
|
|
260
|
+
dscQty: Joi.string()
|
|
261
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
262
|
+
.error(new Error('Parameter Disclosed Quantity cannot be Negative or non-numeric')),
|
|
263
|
+
lmPrc: Joi.number()
|
|
264
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
265
|
+
.required()
|
|
266
|
+
.error(new Error('Parameter limit price cannot be Negative or non-numeric')),
|
|
267
|
+
trgPrc: Joi.string()
|
|
268
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
269
|
+
.error(new Error('Parameter trigger price cannot be Negative or non-numeric')),
|
|
215
270
|
prdCode: Joi.string()
|
|
216
271
|
// .valid(...prdName)
|
|
217
272
|
.required(),
|
|
218
273
|
nstOID: Joi.string().required(),
|
|
219
274
|
sym: Joi.string().required(),
|
|
220
|
-
curQty: Joi.string()
|
|
275
|
+
curQty: Joi.string()
|
|
276
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
277
|
+
.required()
|
|
278
|
+
.error(new Error('Parameter Current Quantity cannot be Negative or non-numeric')),
|
|
221
279
|
}).options({ abortEarly: false });
|
|
222
280
|
|
|
281
|
+
const re = modifyAMOTradeSchema.validate(object);
|
|
282
|
+
console.log(re);
|
|
223
283
|
return modifyAMOTradeSchema.validate(object);
|
|
224
284
|
};
|
|
225
285
|
|
|
@@ -239,8 +299,13 @@ validateCancelAMOTrade = (object, prds) => {
|
|
|
239
299
|
prdCode: Joi.string()
|
|
240
300
|
// .valid(...prdName)
|
|
241
301
|
.required(),
|
|
302
|
+
curQty: Joi.string()
|
|
303
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
304
|
+
.error(new Error('Parameter Current Quantity cannot be Negative or non-numeric')),
|
|
242
305
|
}).options({ abortEarly: false });
|
|
243
306
|
|
|
307
|
+
const re = cancelAMOTradeSchema.validate(object);
|
|
308
|
+
console.log(re);
|
|
244
309
|
return cancelAMOTradeSchema.validate(object);
|
|
245
310
|
};
|
|
246
311
|
|
|
@@ -269,6 +334,8 @@ validateCancelAMOTradeV1 = (object, prds) => {
|
|
|
269
334
|
sym: Joi.string().required(),
|
|
270
335
|
}).options({ abortEarly: false });
|
|
271
336
|
|
|
337
|
+
const re = cancelAMOTradeSchema.validate(object);
|
|
338
|
+
console.log(re);
|
|
272
339
|
return cancelAMOTradeSchema.validate(object);
|
|
273
340
|
};
|
|
274
341
|
|
|
@@ -280,7 +347,10 @@ validateConvertPositionCOMM = (object, prds) => {
|
|
|
280
347
|
const ConvertPositionCOMMSchema = Joi.object({
|
|
281
348
|
sym: Joi.string().required(),
|
|
282
349
|
cnvTyp: Joi.string().valid("D", "C").required(),
|
|
283
|
-
qty: Joi.string()
|
|
350
|
+
qty: Joi.string()
|
|
351
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
352
|
+
.required()
|
|
353
|
+
.error(new Error('Parameter Quantity cannot be Negative or non-numeric')),
|
|
284
354
|
action: Joi.string().valid("B", "S").required(),
|
|
285
355
|
prdCode: Joi.string()
|
|
286
356
|
// .valid(...prdName)
|
|
@@ -295,6 +365,8 @@ validateConvertPositionCOMM = (object, prds) => {
|
|
|
295
365
|
trdSym: Joi.string().required(),
|
|
296
366
|
}).options({ abortEarly: false });
|
|
297
367
|
|
|
368
|
+
const re = ConvertPositionCOMMSchema.validate(object);
|
|
369
|
+
console.log(re);
|
|
298
370
|
return ConvertPositionCOMMSchema.validate(object);
|
|
299
371
|
};
|
|
300
372
|
|
|
@@ -321,7 +393,9 @@ validatePlaceMF = (object) => {
|
|
|
321
393
|
isin: Joi.string().required(),
|
|
322
394
|
txnTyp: Joi.string().required(),
|
|
323
395
|
clientCode: Joi.string().required(),
|
|
324
|
-
qty: Joi.number()
|
|
396
|
+
qty: Joi.number()
|
|
397
|
+
.positive()
|
|
398
|
+
.required(),
|
|
325
399
|
amt: Joi.number().positive().required(),
|
|
326
400
|
reInvFlg: Joi.string().required(),
|
|
327
401
|
folioNo: Joi.any().when("txnTyp", {
|
|
@@ -349,7 +423,9 @@ validateModifyMF = (object) => {
|
|
|
349
423
|
isin: Joi.string().required(),
|
|
350
424
|
txnTyp: Joi.string().required(),
|
|
351
425
|
clientCode: Joi.string().required(),
|
|
352
|
-
qty: Joi.number()
|
|
426
|
+
qty: Joi.number()
|
|
427
|
+
.positive()
|
|
428
|
+
.required(),
|
|
353
429
|
amt: Joi.number().positive().required(),
|
|
354
430
|
reInvFlg: Joi.string().required(),
|
|
355
431
|
folioNo: Joi.any().when("txnTyp", {
|
|
@@ -408,16 +484,33 @@ validatePlaceBracketTrade = (object, prds) => {
|
|
|
408
484
|
.required(),
|
|
409
485
|
sym: Joi.string().required(),
|
|
410
486
|
trnsTyp: Joi.string().required(),
|
|
411
|
-
qty: Joi.number()
|
|
487
|
+
qty: Joi.number()
|
|
488
|
+
.positive()
|
|
489
|
+
.required(),
|
|
412
490
|
dur: Joi.string().required(),
|
|
413
|
-
dsQty: Joi.string()
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
491
|
+
dsQty: Joi.string()
|
|
492
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
493
|
+
.required()
|
|
494
|
+
.error(new Error('Parameter Disclosed Quantity cannot be Negative or non-numeric')),
|
|
495
|
+
prc: Joi.number()
|
|
496
|
+
.min(0)
|
|
497
|
+
.required(),
|
|
498
|
+
slVal: Joi.string()
|
|
499
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
500
|
+
.required()
|
|
501
|
+
.error(new Error('Parameter Stop Loss cannot be Negative or non-numeric')),
|
|
502
|
+
trlSl: Joi.string().valid("Y", "N").required(),
|
|
503
|
+
trlSlVal: Joi.string()
|
|
504
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
505
|
+
.error(new Error('Parameter Trailing stop loss value cannot be Negative or non-numeric')),
|
|
506
|
+
sqOffVal: Joi.string()
|
|
507
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
508
|
+
.required()
|
|
509
|
+
.error(new Error('Parameter Square off cannot be Negative or non-numeric')),
|
|
419
510
|
}).options({ abortEarly: false });
|
|
420
511
|
|
|
512
|
+
const re = PlaceBracketTradeSchema.validate(object);
|
|
513
|
+
console.log(re);
|
|
421
514
|
return PlaceBracketTradeSchema.validate(object);
|
|
422
515
|
};
|
|
423
516
|
|
|
@@ -483,15 +576,26 @@ validatePlaceBasketTrade = (orderList, prds) => {
|
|
|
483
576
|
dur: Joi.string()
|
|
484
577
|
.valid(...validityArray)
|
|
485
578
|
.required(),
|
|
486
|
-
price: Joi.string()
|
|
579
|
+
price: Joi.string()
|
|
580
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
581
|
+
.required()
|
|
582
|
+
.error(new Error('Parameter Price cannot be Negative or non-numeric')),
|
|
487
583
|
trgPrc: Joi.string().required(),
|
|
488
|
-
qty: Joi.number()
|
|
489
|
-
|
|
584
|
+
qty: Joi.number()
|
|
585
|
+
.positive()
|
|
586
|
+
.required(),
|
|
587
|
+
dscQty: Joi.string()
|
|
588
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
589
|
+
.required()
|
|
590
|
+
.error(new Error('Parameter Disclosed Quantity cannot be Negative or non-numeric')),
|
|
490
591
|
GTDDate: Joi.string().required(),
|
|
491
592
|
rmk: Joi.string().allow("").required(),
|
|
492
593
|
sym: Joi.string().required(),
|
|
493
594
|
})
|
|
494
595
|
.options({ abortEarly: false });
|
|
596
|
+
|
|
597
|
+
const re = orderListSchema.validate(item);
|
|
598
|
+
console.log(re);
|
|
495
599
|
return orderListSchema.validate(item);
|
|
496
600
|
});
|
|
497
601
|
};
|
|
@@ -517,11 +621,23 @@ validatePositionSquareOff = (orderList, prds) => {
|
|
|
517
621
|
ordTyp: Joi.string()
|
|
518
622
|
.valid(...orderTypeArray)
|
|
519
623
|
.required(),
|
|
520
|
-
qty: Joi.string()
|
|
521
|
-
|
|
624
|
+
qty: Joi.string()
|
|
625
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
626
|
+
.required()
|
|
627
|
+
.error(new Error('Parameter Quantity cannot be Negative or non-numeric')),
|
|
628
|
+
dscQty: Joi.string()
|
|
629
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
630
|
+
.required()
|
|
631
|
+
.error(new Error('Parameter Disclosed Quantity cannot be Negative or non-numeric')),
|
|
522
632
|
sym: Joi.string().required(),
|
|
523
|
-
trgPrc: Joi.string()
|
|
524
|
-
|
|
633
|
+
trgPrc: Joi.string()
|
|
634
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
635
|
+
.required()
|
|
636
|
+
.error(new Error('Parameter Trigger price cannot be Negative or non-numeric')),
|
|
637
|
+
price: Joi.string()
|
|
638
|
+
.pattern(new RegExp("^\\d+(\\.\\d+)?"))
|
|
639
|
+
.required()
|
|
640
|
+
.error(new Error('Parameter Price cannot be Negative or non-numeric')),
|
|
525
641
|
prdCode: Joi.string()
|
|
526
642
|
// .valid(...prdName)
|
|
527
643
|
.required(),
|
|
@@ -529,6 +645,9 @@ validatePositionSquareOff = (orderList, prds) => {
|
|
|
529
645
|
GTDDate: Joi.string().required(),
|
|
530
646
|
})
|
|
531
647
|
.options({ abortEarly: false });
|
|
648
|
+
|
|
649
|
+
const re = orderListSchema.validate(item);
|
|
650
|
+
console.log(re);
|
|
532
651
|
return orderListSchema.validate(item);
|
|
533
652
|
});
|
|
534
653
|
};
|
|
@@ -79,7 +79,47 @@ validateChartEOD = (interval, aType, symbol, exc, tillDate, conti) => {
|
|
|
79
79
|
return chartSchema.validate(paramsObject);
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Validate Chart CustomPeriod input params
|
|
84
|
+
*/
|
|
85
|
+
validateChartCustomPeriod = (interval, aType, symbol, exc, fromDate, toDate, conti) => {
|
|
86
|
+
const paramsObject = {
|
|
87
|
+
interval: interval,
|
|
88
|
+
aType: aType,
|
|
89
|
+
symbol: symbol,
|
|
90
|
+
exc: exc,
|
|
91
|
+
fromDate: fromDate,
|
|
92
|
+
toDate: toDate,
|
|
93
|
+
conti: conti,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const chartSchema = Joi.object({
|
|
97
|
+
interval: Joi.string()
|
|
98
|
+
.valid(...eodIntervalTypeArray)
|
|
99
|
+
.required(),
|
|
100
|
+
aType: Joi.string()
|
|
101
|
+
.valid(...assetTypeArray)
|
|
102
|
+
.required(),
|
|
103
|
+
symbol: Joi.string().required(),
|
|
104
|
+
exc: Joi.string()
|
|
105
|
+
.valid(...chartExchangeTypeArray)
|
|
106
|
+
.required(),
|
|
107
|
+
fromDate: Joi.alternatives().try(
|
|
108
|
+
JoiDate.date().format("YYYY-MM-DD").utc(),
|
|
109
|
+
Joi.string().required()
|
|
110
|
+
),
|
|
111
|
+
toDate: Joi.alternatives().try(
|
|
112
|
+
JoiDate.date().format("YYYY-MM-DD").utc(),
|
|
113
|
+
Joi.string().required()
|
|
114
|
+
),
|
|
115
|
+
conti: Joi.boolean().strict(),
|
|
116
|
+
}).options({ abortEarly: false });
|
|
117
|
+
|
|
118
|
+
return chartSchema.validate(paramsObject);
|
|
119
|
+
};
|
|
120
|
+
|
|
82
121
|
module.exports = {
|
|
83
122
|
validateChartIntraday,
|
|
84
123
|
validateChartEOD,
|
|
124
|
+
validateChartCustomPeriod,
|
|
85
125
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const Joi = require("Joi");
|
|
2
|
+
|
|
3
|
+
const enumSegmentType = require("../enums/segmentType");
|
|
4
|
+
const JoiDate = require("Joi").extend(require("@joi/date"));
|
|
5
|
+
const segmentTypeArray = Object.values(enumSegmentType);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Validate Transaction History input params
|
|
9
|
+
*/
|
|
10
|
+
validateTransactionHistory = (segment,fromDate,toDate) => {
|
|
11
|
+
const paramsObject = {
|
|
12
|
+
segment,
|
|
13
|
+
fromDate,
|
|
14
|
+
toDate
|
|
15
|
+
};
|
|
16
|
+
const transactionHistoryParamsSchema = Joi.object({
|
|
17
|
+
segment: Joi.string()
|
|
18
|
+
.valid(...segmentTypeArray)
|
|
19
|
+
.required(),
|
|
20
|
+
fromDate: Joi.alternatives().try(
|
|
21
|
+
JoiDate.date().format("YYYY-MM-DD").utc(),
|
|
22
|
+
Joi.string().required()
|
|
23
|
+
),
|
|
24
|
+
toDate: Joi.alternatives().try(
|
|
25
|
+
JoiDate.date().format("YYYY-MM-DD").utc(),
|
|
26
|
+
Joi.string().required()
|
|
27
|
+
),
|
|
28
|
+
}).options({ abortEarly: false });
|
|
29
|
+
|
|
30
|
+
return transactionHistoryParamsSchema.validate(paramsObject);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
validateTransactionHistory
|
|
35
|
+
};
|
|
Binary file
|