api_connect_nodejs 2.0.12 → 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 -154
- 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/feed/ordersFeed.js
CHANGED
|
@@ -1,124 +1,125 @@
|
|
|
1
|
-
const log4js = require("../logger");
|
|
2
|
-
const configData = require("../iniparser");
|
|
3
|
-
const { ORDER_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
-
const {
|
|
5
|
-
validateSubscribeOrdersFeed,
|
|
6
|
-
} = require("../../validations/feedStreamerValidator");
|
|
7
|
-
class OrdersFeed {
|
|
8
|
-
/**
|
|
9
|
-
* Streamer
|
|
10
|
-
* OrderFeed Class for subsribe or unsubsribe order
|
|
11
|
-
* @param {string} accid Customer Account ID
|
|
12
|
-
* @param {string} userid User ID
|
|
13
|
-
*/
|
|
14
|
-
constructor(feed, accountId, userId) {
|
|
15
|
-
this.feed = feed;
|
|
16
|
-
this.accountId = accountId;
|
|
17
|
-
this.userId = userId;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
72
|
-
* @
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
108
|
-
* @
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
const log4js = require("../logger");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const { ORDER_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
+
const {
|
|
5
|
+
validateSubscribeOrdersFeed,
|
|
6
|
+
} = require("../../validations/feedStreamerValidator");
|
|
7
|
+
class OrdersFeed {
|
|
8
|
+
/**
|
|
9
|
+
* Streamer
|
|
10
|
+
* OrderFeed Class for subsribe or unsubsribe order
|
|
11
|
+
* @param {string} accid Customer Account ID
|
|
12
|
+
* @param {string} userid User ID
|
|
13
|
+
*/
|
|
14
|
+
constructor(feed, accountId, userId, constantsObj) {
|
|
15
|
+
this.feed = feed;
|
|
16
|
+
this.accountId = accountId;
|
|
17
|
+
this.userId = userId;
|
|
18
|
+
this.constants = constantsObj;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Orders Feed RequestBody Structure
|
|
23
|
+
* Return OrderFeed RequestBody Structure
|
|
24
|
+
* @function ordersFeedRequestBody
|
|
25
|
+
* @returns object
|
|
26
|
+
*/
|
|
27
|
+
ordersFeedRequestBody = () => {
|
|
28
|
+
return {
|
|
29
|
+
request: {
|
|
30
|
+
streaming_type: "orderFiler",
|
|
31
|
+
data: {
|
|
32
|
+
accType: this.constants.Data.data.lgnData.accTyp,//"EQ",
|
|
33
|
+
userID: this.userId,
|
|
34
|
+
accID: this.accountId,
|
|
35
|
+
responseType: ["ORDER_UPDATE", "TRADE_UPDATE"],
|
|
36
|
+
},
|
|
37
|
+
formFactor: configData.formFactor,
|
|
38
|
+
appID: configData.ApiIdKey,
|
|
39
|
+
response_format: "json",
|
|
40
|
+
request_type: "",
|
|
41
|
+
},
|
|
42
|
+
echo: {},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create OrdersFeed Request Body
|
|
48
|
+
* @param {boolean} subscribe - true for subsribe and false for unsubsribe
|
|
49
|
+
* @returns object
|
|
50
|
+
*/
|
|
51
|
+
createOrderRequest = (subscribe = false) => {
|
|
52
|
+
let body = {};
|
|
53
|
+
try {
|
|
54
|
+
body = this.ordersFeedRequestBody();
|
|
55
|
+
if (subscribe) {
|
|
56
|
+
body.request.request_type = "subscribe";
|
|
57
|
+
} else {
|
|
58
|
+
body.request.request_type = "unsubscribe";
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
log4js.debug("createOrderRequest error - " + error);
|
|
62
|
+
} finally {
|
|
63
|
+
return body;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Subsribe Order Feed
|
|
69
|
+
* 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.
|
|
70
|
+
* @async
|
|
71
|
+
* @function subscribeOrdersFeed
|
|
72
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
subscribeOrdersFeed = async (callback) => {
|
|
76
|
+
try {
|
|
77
|
+
/** Validation Start */
|
|
78
|
+
const validateResponse = validateSubscribeOrdersFeed(
|
|
79
|
+
this.accountId,
|
|
80
|
+
this.userId,
|
|
81
|
+
callback
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (validateResponse.error) {
|
|
85
|
+
log4js.debug(
|
|
86
|
+
"SubscribeOrdersFeed validation error - " +
|
|
87
|
+
validateResponse.error.details
|
|
88
|
+
);
|
|
89
|
+
return Promise.reject(validateResponse.error.details);
|
|
90
|
+
}
|
|
91
|
+
/** Validation End */
|
|
92
|
+
|
|
93
|
+
/** Get Order Request */
|
|
94
|
+
let orderRequest = this.createOrderRequest(true);
|
|
95
|
+
|
|
96
|
+
/** Call connect method of Feed Class */
|
|
97
|
+
this.feed.subsribe(ORDER_STREAM_REQ_CODE, orderRequest, callback);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
log4js.debug("SubscribeOrdersFeed error - " + error);
|
|
100
|
+
console.log(error);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Unsubsribe Order Feed
|
|
106
|
+
* This method will unsubscribe the streamer. After successful invokation of this, will stop the streamer.
|
|
107
|
+
* @async
|
|
108
|
+
* @function unsubscribeOrdersFeed
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
unsubscribeOrdersFeed = async () => {
|
|
112
|
+
try {
|
|
113
|
+
/** Get Order Request */
|
|
114
|
+
const orderRequest = this.createOrderRequest();
|
|
115
|
+
|
|
116
|
+
/** Unsubsribe OrderFeed */
|
|
117
|
+
this.feed.unsubsribe(ORDER_STREAM_REQ_CODE, orderRequest);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
log4js.debug("unsubscribeOrdersFeed error - " + error);
|
|
120
|
+
console.log(error);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = OrdersFeed;
|
package/src/feed/quotesFeed.js
CHANGED
|
@@ -1,122 +1,123 @@
|
|
|
1
|
-
const log4js = require("../logger");
|
|
2
|
-
const configData = require("../iniparser");
|
|
3
|
-
const { REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
-
const {
|
|
5
|
-
validateSubscribeReducedQuotesFeed,
|
|
6
|
-
validateUnsubscribeReducedQuotesFeed,
|
|
7
|
-
} = require("../../validations/feedStreamerValidator");
|
|
8
|
-
|
|
9
|
-
class QuotesFeed {
|
|
10
|
-
/**
|
|
11
|
-
* Streamer
|
|
12
|
-
* QuotesFeed Class for subsribe or unsubsribe Quotes
|
|
13
|
-
*/
|
|
14
|
-
constructor(feed) {
|
|
15
|
-
this.feed = feed;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
* @param {
|
|
48
|
-
* @
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
* @param {
|
|
76
|
-
* @
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
106
|
-
* @
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
1
|
+
const log4js = require("../logger");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const { REDUCED_QUOTE_SREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
+
const {
|
|
5
|
+
validateSubscribeReducedQuotesFeed,
|
|
6
|
+
validateUnsubscribeReducedQuotesFeed,
|
|
7
|
+
} = require("../../validations/feedStreamerValidator");
|
|
8
|
+
|
|
9
|
+
class QuotesFeed {
|
|
10
|
+
/**
|
|
11
|
+
* Streamer
|
|
12
|
+
* QuotesFeed Class for subsribe or unsubsribe Quotes
|
|
13
|
+
*/
|
|
14
|
+
constructor(feed, constantsObj) {
|
|
15
|
+
this.feed = feed;
|
|
16
|
+
this.constants = constantsObj;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Reduced Quote
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reduced QutoesFeed RequestBody Structure
|
|
23
|
+
* Return Reduced QuotesFeed RequestBody Structure
|
|
24
|
+
* @function reducedQuotesFeedRequestBody
|
|
25
|
+
* @returns object
|
|
26
|
+
*/
|
|
27
|
+
reducedQuoteRequestBody = () => {
|
|
28
|
+
return {
|
|
29
|
+
request: {
|
|
30
|
+
streaming_type: "quote",
|
|
31
|
+
data: {
|
|
32
|
+
"accType": this.constants.Data.data.lgnData.accTyp,//"EQ",
|
|
33
|
+
symbols: [],
|
|
34
|
+
},
|
|
35
|
+
formFactor: configData.formFactor,
|
|
36
|
+
appID: configData.ApiIdKey,
|
|
37
|
+
response_format: "json",
|
|
38
|
+
request_type: "",
|
|
39
|
+
},
|
|
40
|
+
echo: {},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Create ReducedQuotesFeed RequestBody
|
|
45
|
+
* Return ReducedQuotesFeed RequestBody
|
|
46
|
+
* @function createReducedQuotesFeedRequest
|
|
47
|
+
* @param {Object[]} symbols - Array of subsribe Symbols
|
|
48
|
+
* @param {boolean} order - true for subsribe and false for unsubsribe
|
|
49
|
+
* @returns object
|
|
50
|
+
*/
|
|
51
|
+
createReducedQuotesFeedRequest = (symbols, reducedQuote = false) => {
|
|
52
|
+
let body = {};
|
|
53
|
+
try {
|
|
54
|
+
body = this.reducedQuoteRequestBody();
|
|
55
|
+
const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
|
|
56
|
+
|
|
57
|
+
body.request.data.symbols = symset;
|
|
58
|
+
|
|
59
|
+
if (reducedQuote) {
|
|
60
|
+
body.request.request_type = "subscribe";
|
|
61
|
+
} else {
|
|
62
|
+
body.request.request_type = "unsubscribe";
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
log4js.debug("createReducedQuotesFeedRequest 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 subscribeReducedQuotesFeed
|
|
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
|
+
subscribeReducedQuotesFeed = async (symbols, callback) => {
|
|
80
|
+
try {
|
|
81
|
+
/** Validation Start */
|
|
82
|
+
const validateResponse = validateSubscribeReducedQuotesFeed(callback, symbols);
|
|
83
|
+
|
|
84
|
+
if (validateResponse.error) {
|
|
85
|
+
log4js.debug(
|
|
86
|
+
"subscribeReducedQuotesFeed 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 reducedQuoteRequest = this.createReducedQuotesFeedRequest(symbols, true);
|
|
95
|
+
/** Call connect method of Feed Class */
|
|
96
|
+
this.feed.subsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest, callback);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
log4js.debug("subscribeReducedQuotesFeed 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 unsubscribeReducedQuotesFeed
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
unsubscribeReducedQuotesFeed = async () => {
|
|
110
|
+
try {
|
|
111
|
+
/** Get Streaming Reduced Quote Request */
|
|
112
|
+
const reducedQuoteRequest = this.createReducedQuotesFeedRequest([]);
|
|
113
|
+
|
|
114
|
+
/** Unsubsribe symbols */
|
|
115
|
+
this.feed.unsubsribe(REDUCED_QUOTE_SREAM_REQ_CODE, reducedQuoteRequest);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
log4js.debug("unsubscribeReducedQuotesFeed error - " + error);
|
|
118
|
+
console.log(error);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = QuotesFeed;
|