api_connect_nodejs 2.0.13 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/conf/settings.ini +17 -20
- package/enums/actionType.js +10 -10
- package/enums/assetType.js +25 -25
- package/enums/chartExchangeType.js +16 -16
- package/enums/chartType.js +13 -13
- package/enums/eodIntervalType.js +11 -11
- package/enums/exchangeType.js +15 -15
- package/enums/intradayIntervalType.js +14 -14
- package/enums/marketCapType.js +12 -12
- package/enums/orderType.js +21 -21
- package/enums/productType.js +24 -24
- package/enums/segementsType.js +13 -13
- package/enums/segmentType.js +10 -10
- package/enums/streamingConstants.js +13 -13
- package/enums/termsType.js +12 -12
- package/enums/validity.js +22 -22
- package/index.js +3 -3
- package/package.json +25 -25
- package/src/apiConnect.js +2682 -2559
- package/src/apiUtils.js +221 -221
- package/src/chart.js +404 -404
- package/src/config.js +347 -342
- package/src/feed/depthFeed.js +136 -136
- package/src/feed/feed.js +170 -170
- package/src/feed/liveNewsFeed.js +112 -112
- package/src/feed/miniQuoteFeed.js +122 -121
- package/src/feed/ordersFeed.js +125 -124
- package/src/feed/quotesFeed.js +123 -122
- package/src/http.js +260 -197
- package/src/iniparser.js +45 -45
- package/src/liveNews.js +362 -362
- package/src/logger.js +16 -16
- package/src/order.js +48 -48
- package/src/quote.js +75 -75
- package/src/report.js +49 -49
- package/src/researchCalls.js +175 -175
- package/src/watchlist.js +378 -378
- package/validations/apiConnectValidator.js +701 -698
- package/validations/chartValidator.js +125 -125
- package/validations/feedStreamerValidator.js +162 -162
- package/validations/liveNewsValidator.js +60 -60
- package/validations/quoteValidator.js +19 -19
- package/validations/reportValidator.js +35 -35
- package/validations/researchCallsValidator.js +86 -86
- package/validations/watchlistValidator.js +60 -60
package/src/logger.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const log4js = require("log4js");
|
|
2
|
-
const configData = require("./iniparser.js");
|
|
3
|
-
|
|
4
|
-
// Logger configuration
|
|
5
|
-
log4js.configure({
|
|
6
|
-
appenders: { fileAppender: { type: "file", filename: "./logs/APIConnect.log" } },
|
|
7
|
-
categories: {
|
|
8
|
-
default: { appenders: ["fileAppender"], level: configData.LogLevel },
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// Create the logger
|
|
13
|
-
const logger = log4js.getLogger();
|
|
14
|
-
|
|
15
|
-
// Log a message
|
|
16
|
-
module.exports = logger;
|
|
1
|
+
const log4js = require("log4js");
|
|
2
|
+
const configData = require("./iniparser.js");
|
|
3
|
+
|
|
4
|
+
// Logger configuration
|
|
5
|
+
log4js.configure({
|
|
6
|
+
appenders: { fileAppender: { type: "file", filename: "./logs/APIConnect.log" } },
|
|
7
|
+
categories: {
|
|
8
|
+
default: { appenders: ["fileAppender"], level: configData.LogLevel },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Create the logger
|
|
13
|
+
const logger = log4js.getLogger();
|
|
14
|
+
|
|
15
|
+
// Log a message
|
|
16
|
+
module.exports = logger;
|
package/src/order.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
class Order {
|
|
2
|
-
/**
|
|
3
|
-
* @param {string} Exchange Exchange of the scrip
|
|
4
|
-
* @param {string} TradingSymbol Trading Symbol, to be obtained from Contract Notes
|
|
5
|
-
* @param {string} StreamingSymbol ScripCode_exchange
|
|
6
|
-
* @param {'BUY' | 'SELL'} Action BUY | SELL
|
|
7
|
-
* @param {'CNC' | 'MIS' | 'NRML'} ProductCode CNC | MIS | NRML
|
|
8
|
-
* @param {'LIMIT' | 'MARKET'} OrderType LIMIT | MARKET
|
|
9
|
-
* @param {'DAY' | 'IOC'} Duration Validity DAY | IOC
|
|
10
|
-
* @param {string} Price Limit price of the scrip
|
|
11
|
-
* @param {string} TriggerPrice Trigger Price in case of SL/SL-M Order
|
|
12
|
-
* @param {number} Quantity Quantity of scrip to be purchansed
|
|
13
|
-
* @param {string} DisclosedQuantity Disclosed Quantity for the Order
|
|
14
|
-
* @param {string} GTDDate Good Till Date in dd/MM/yyyy format
|
|
15
|
-
* @param {string} Remark Remark
|
|
16
|
-
*/
|
|
17
|
-
constructor(
|
|
18
|
-
Exchange,
|
|
19
|
-
TradingSymbol,
|
|
20
|
-
StreamingSymbol,
|
|
21
|
-
Action,
|
|
22
|
-
ProductCode,
|
|
23
|
-
OrderType,
|
|
24
|
-
Duration,
|
|
25
|
-
Price,
|
|
26
|
-
TriggerPrice,
|
|
27
|
-
Quantity,
|
|
28
|
-
DisclosedQuantity,
|
|
29
|
-
GTDDate,
|
|
30
|
-
Remark
|
|
31
|
-
) {
|
|
32
|
-
this.trdSym = TradingSymbol;
|
|
33
|
-
this.exc = Exchange;
|
|
34
|
-
this.action = Action;
|
|
35
|
-
this.dur = Duration;
|
|
36
|
-
this.ordTyp = OrderType;
|
|
37
|
-
this.qty = Quantity;
|
|
38
|
-
this.dscQty = DisclosedQuantity;
|
|
39
|
-
this.sym = StreamingSymbol;
|
|
40
|
-
this.price = Price;
|
|
41
|
-
this.trgPrc = TriggerPrice;
|
|
42
|
-
this.prdCode = ProductCode;
|
|
43
|
-
this.GTDDate = GTDDate;
|
|
44
|
-
this.rmk = Remark;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
module.exports = Order;
|
|
1
|
+
class Order {
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} Exchange Exchange of the scrip
|
|
4
|
+
* @param {string} TradingSymbol Trading Symbol, to be obtained from Contract Notes
|
|
5
|
+
* @param {string} StreamingSymbol ScripCode_exchange
|
|
6
|
+
* @param {'BUY' | 'SELL'} Action BUY | SELL
|
|
7
|
+
* @param {'CNC' | 'MIS' | 'NRML'} ProductCode CNC | MIS | NRML
|
|
8
|
+
* @param {'LIMIT' | 'MARKET'} OrderType LIMIT | MARKET
|
|
9
|
+
* @param {'DAY' | 'IOC'} Duration Validity DAY | IOC
|
|
10
|
+
* @param {string} Price Limit price of the scrip
|
|
11
|
+
* @param {string} TriggerPrice Trigger Price in case of SL/SL-M Order
|
|
12
|
+
* @param {number} Quantity Quantity of scrip to be purchansed
|
|
13
|
+
* @param {string} DisclosedQuantity Disclosed Quantity for the Order
|
|
14
|
+
* @param {string} GTDDate Good Till Date in dd/MM/yyyy format
|
|
15
|
+
* @param {string} Remark Remark
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
Exchange,
|
|
19
|
+
TradingSymbol,
|
|
20
|
+
StreamingSymbol,
|
|
21
|
+
Action,
|
|
22
|
+
ProductCode,
|
|
23
|
+
OrderType,
|
|
24
|
+
Duration,
|
|
25
|
+
Price,
|
|
26
|
+
TriggerPrice,
|
|
27
|
+
Quantity,
|
|
28
|
+
DisclosedQuantity,
|
|
29
|
+
GTDDate,
|
|
30
|
+
Remark
|
|
31
|
+
) {
|
|
32
|
+
this.trdSym = TradingSymbol;
|
|
33
|
+
this.exc = Exchange;
|
|
34
|
+
this.action = Action;
|
|
35
|
+
this.dur = Duration;
|
|
36
|
+
this.ordTyp = OrderType;
|
|
37
|
+
this.qty = Quantity;
|
|
38
|
+
this.dscQty = DisclosedQuantity;
|
|
39
|
+
this.sym = StreamingSymbol;
|
|
40
|
+
this.price = Price;
|
|
41
|
+
this.trgPrc = TriggerPrice;
|
|
42
|
+
this.prdCode = ProductCode;
|
|
43
|
+
this.GTDDate = GTDDate;
|
|
44
|
+
this.rmk = Remark;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = Order;
|
package/src/quote.js
CHANGED
|
@@ -1,75 +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;
|
|
1
|
+
const log4js = require("./logger.js");
|
|
2
|
+
const {
|
|
3
|
+
validateMarketDepth,
|
|
4
|
+
} = require("../validations/quoteValidator");
|
|
5
|
+
|
|
6
|
+
class Quote {
|
|
7
|
+
constructor(http, config, constants) {
|
|
8
|
+
this.__http = http;
|
|
9
|
+
this.__config = config;
|
|
10
|
+
this.__constants = constants;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Modifying the response
|
|
14
|
+
*/
|
|
15
|
+
modifyResponse = async (response) => {
|
|
16
|
+
try {
|
|
17
|
+
const modifiedResponse = {};
|
|
18
|
+
let msgID = "";
|
|
19
|
+
let srvTm = "";
|
|
20
|
+
if (Object.keys(response).length !== 0) {
|
|
21
|
+
msgID = response["msgID"];
|
|
22
|
+
srvTm = response["srvTm"];
|
|
23
|
+
const data = response.data;
|
|
24
|
+
const mkd = data.mkd;
|
|
25
|
+
modifiedResponse["data"] = mkd;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
modifiedResponse["msgID"] = msgID;
|
|
29
|
+
modifiedResponse["srvTm"] = srvTm;
|
|
30
|
+
log4js.debug("modifiedResponse :" + JSON.stringify(modifiedResponse));
|
|
31
|
+
return modifiedResponse;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return Promise.reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {string} symbol
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
getMarketDepthAPI = async (symbol) => {
|
|
43
|
+
let result = {};
|
|
44
|
+
try {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validate market depth params
|
|
48
|
+
*/
|
|
49
|
+
const validateResponse = validateMarketDepth(
|
|
50
|
+
symbol,
|
|
51
|
+
);
|
|
52
|
+
if (validateResponse.error) {
|
|
53
|
+
log4js.debug(
|
|
54
|
+
"market depth validation error - " + validateResponse.error.details
|
|
55
|
+
);
|
|
56
|
+
return Promise.reject(validateResponse.error.details);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const url = this.__config.MarketDepthURL(symbol);
|
|
60
|
+
log4js.debug("market depth URL -" + url);
|
|
61
|
+
const response = await this.__http.GetMethod(url, false);
|
|
62
|
+
|
|
63
|
+
if (result.length !== 0) {
|
|
64
|
+
result = this.modifyResponse(response);
|
|
65
|
+
} else {
|
|
66
|
+
result = response;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
log4js.debug("Market depth error - " + error);
|
|
71
|
+
return Promise.reject(error);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
module.exports = Quote;
|
package/src/report.js
CHANGED
|
@@ -1,49 +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;
|
|
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;
|