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/liveNewsFeed.js
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
const log4js = require("../logger");
|
|
2
|
-
const configData = require("../iniparser");
|
|
3
|
-
const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
-
const {
|
|
5
|
-
validateStreamerCallback,
|
|
6
|
-
} = require("../../validations/feedStreamerValidator");
|
|
7
|
-
|
|
8
|
-
class LiveNewsFeed {
|
|
9
|
-
/**
|
|
10
|
-
* Streamer
|
|
11
|
-
* LiveNewsFeed Class for subsribe or unsubsribe News
|
|
12
|
-
*/
|
|
13
|
-
constructor(feed) {
|
|
14
|
-
this.feed = feed;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* LiveNews Feed RequestBody Schema
|
|
19
|
-
* @function liveNewsRequestBody
|
|
20
|
-
* @returns object
|
|
21
|
-
*/
|
|
22
|
-
requestBody = () => {
|
|
23
|
-
return {
|
|
24
|
-
request: {
|
|
25
|
-
streaming_type: "news",
|
|
26
|
-
formFactor: configData.formFactor,
|
|
27
|
-
appID: configData.ApiIdKey,
|
|
28
|
-
response_format: "json",
|
|
29
|
-
request_type: "",
|
|
30
|
-
},
|
|
31
|
-
echo: {},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Create LiveNews Request Body
|
|
37
|
-
* Returns liveNewsRequestBody
|
|
38
|
-
* @function createLivenewsRequest
|
|
39
|
-
* @param {boolean} subsribe - true for subsribe and false for unsubsribe
|
|
40
|
-
* @returns object
|
|
41
|
-
*/
|
|
42
|
-
createLivenewsRequest = (subscribe = false) => {
|
|
43
|
-
let body = {};
|
|
44
|
-
try {
|
|
45
|
-
body = this.requestBody();
|
|
46
|
-
if (subscribe) {
|
|
47
|
-
body.request.request_type = "subscribe";
|
|
48
|
-
} else {
|
|
49
|
-
body.request.request_type = "unsubscribe";
|
|
50
|
-
}
|
|
51
|
-
} catch (error) {
|
|
52
|
-
log4js.debug("createLivenewsRequest error - " + error);
|
|
53
|
-
} finally {
|
|
54
|
-
return body;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Subsribe LiveNews
|
|
60
|
-
* 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.
|
|
61
|
-
* @async
|
|
62
|
-
* @function subscribeLiveNewsFeed
|
|
63
|
-
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
subscribeLiveNewsFeed = async (callback) => {
|
|
67
|
-
try {
|
|
68
|
-
/** Validation Start */
|
|
69
|
-
const validateResponse = validateStreamerCallback(callback);
|
|
70
|
-
|
|
71
|
-
if (validateResponse.error) {
|
|
72
|
-
log4js.debug(
|
|
73
|
-
"subscribeLiveNewsFeed validation error - " +
|
|
74
|
-
validateResponse.error.details
|
|
75
|
-
);
|
|
76
|
-
return Promise.reject(validateResponse.error.details);
|
|
77
|
-
}
|
|
78
|
-
/** Validation End */
|
|
79
|
-
|
|
80
|
-
/** Get LiveNews Request */
|
|
81
|
-
const liveNewsRequest = this.createLivenewsRequest(true);
|
|
82
|
-
/** Call connect method of Feed Class */
|
|
83
|
-
this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
log4js.debug("subscribeLiveNewsFeed error - " + error);
|
|
86
|
-
console.log(error);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Unsubsribe LiveNews Feed
|
|
92
|
-
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
93
|
-
* @async
|
|
94
|
-
* @function unsubscribeLiveNewsFeed
|
|
95
|
-
* @param {Object[]} - Array of unsubsribe Symbols
|
|
96
|
-
* @returns
|
|
97
|
-
*/
|
|
98
|
-
unsubscribeLiveNewsFeed = async () => {
|
|
99
|
-
try {
|
|
100
|
-
/** Get LiveNews Request */
|
|
101
|
-
const liveNewsRequest = this.createLivenewsRequest();
|
|
102
|
-
|
|
103
|
-
/** Unsubscribe liveNews */
|
|
104
|
-
this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
log4js.debug("unsubscribeLiveNews error - " + error);
|
|
107
|
-
console.log(error);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
module.exports = LiveNewsFeed;
|
|
1
|
+
const log4js = require("../logger");
|
|
2
|
+
const configData = require("../iniparser");
|
|
3
|
+
const { LIVENEWS_STREAM_REQ_CODE } = require("../../enums/streamingConstants");
|
|
4
|
+
const {
|
|
5
|
+
validateStreamerCallback,
|
|
6
|
+
} = require("../../validations/feedStreamerValidator");
|
|
7
|
+
|
|
8
|
+
class LiveNewsFeed {
|
|
9
|
+
/**
|
|
10
|
+
* Streamer
|
|
11
|
+
* LiveNewsFeed Class for subsribe or unsubsribe News
|
|
12
|
+
*/
|
|
13
|
+
constructor(feed) {
|
|
14
|
+
this.feed = feed;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* LiveNews Feed RequestBody Schema
|
|
19
|
+
* @function liveNewsRequestBody
|
|
20
|
+
* @returns object
|
|
21
|
+
*/
|
|
22
|
+
requestBody = () => {
|
|
23
|
+
return {
|
|
24
|
+
request: {
|
|
25
|
+
streaming_type: "news",
|
|
26
|
+
formFactor: configData.formFactor,
|
|
27
|
+
appID: configData.ApiIdKey,
|
|
28
|
+
response_format: "json",
|
|
29
|
+
request_type: "",
|
|
30
|
+
},
|
|
31
|
+
echo: {},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create LiveNews Request Body
|
|
37
|
+
* Returns liveNewsRequestBody
|
|
38
|
+
* @function createLivenewsRequest
|
|
39
|
+
* @param {boolean} subsribe - true for subsribe and false for unsubsribe
|
|
40
|
+
* @returns object
|
|
41
|
+
*/
|
|
42
|
+
createLivenewsRequest = (subscribe = false) => {
|
|
43
|
+
let body = {};
|
|
44
|
+
try {
|
|
45
|
+
body = this.requestBody();
|
|
46
|
+
if (subscribe) {
|
|
47
|
+
body.request.request_type = "subscribe";
|
|
48
|
+
} else {
|
|
49
|
+
body.request.request_type = "unsubscribe";
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
log4js.debug("createLivenewsRequest error - " + error);
|
|
53
|
+
} finally {
|
|
54
|
+
return body;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Subsribe LiveNews
|
|
60
|
+
* 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.
|
|
61
|
+
* @async
|
|
62
|
+
* @function subscribeLiveNewsFeed
|
|
63
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
subscribeLiveNewsFeed = async (callback) => {
|
|
67
|
+
try {
|
|
68
|
+
/** Validation Start */
|
|
69
|
+
const validateResponse = validateStreamerCallback(callback);
|
|
70
|
+
|
|
71
|
+
if (validateResponse.error) {
|
|
72
|
+
log4js.debug(
|
|
73
|
+
"subscribeLiveNewsFeed validation error - " +
|
|
74
|
+
validateResponse.error.details
|
|
75
|
+
);
|
|
76
|
+
return Promise.reject(validateResponse.error.details);
|
|
77
|
+
}
|
|
78
|
+
/** Validation End */
|
|
79
|
+
|
|
80
|
+
/** Get LiveNews Request */
|
|
81
|
+
const liveNewsRequest = this.createLivenewsRequest(true);
|
|
82
|
+
/** Call connect method of Feed Class */
|
|
83
|
+
this.feed.subsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest, callback);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
log4js.debug("subscribeLiveNewsFeed error - " + error);
|
|
86
|
+
console.log(error);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Unsubsribe LiveNews Feed
|
|
92
|
+
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
93
|
+
* @async
|
|
94
|
+
* @function unsubscribeLiveNewsFeed
|
|
95
|
+
* @param {Object[]} - Array of unsubsribe Symbols
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
unsubscribeLiveNewsFeed = async () => {
|
|
99
|
+
try {
|
|
100
|
+
/** Get LiveNews Request */
|
|
101
|
+
const liveNewsRequest = this.createLivenewsRequest();
|
|
102
|
+
|
|
103
|
+
/** Unsubscribe liveNews */
|
|
104
|
+
this.feed.unsubsribe(LIVENEWS_STREAM_REQ_CODE, liveNewsRequest);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
log4js.debug("unsubscribeLiveNews error - " + error);
|
|
107
|
+
console.log(error);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = LiveNewsFeed;
|
|
@@ -1,121 +1,122 @@
|
|
|
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
|
-
|
|
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
|
-
* @param {
|
|
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
|
-
* @param {
|
|
75
|
-
* @
|
|
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
|
-
|
|
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, constantsObj) {
|
|
15
|
+
this.feed = feed;
|
|
16
|
+
this.constants = constantsObj;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* QutoesFeed RequestBody Structure
|
|
21
|
+
* Return MiniQuoteFeed RequestBody Structure
|
|
22
|
+
* @function miniQuoteFeedRequestBody
|
|
23
|
+
* @returns object
|
|
24
|
+
*/
|
|
25
|
+
requestBody = () => {
|
|
26
|
+
return {
|
|
27
|
+
request: {
|
|
28
|
+
streaming_type: "miniquote",
|
|
29
|
+
data: {
|
|
30
|
+
"accType": this.constants.Data.data.lgnData.accTyp,//"EQ",
|
|
31
|
+
symbols: [],
|
|
32
|
+
},
|
|
33
|
+
formFactor: configData.formFactor,
|
|
34
|
+
appID: configData.ApiIdKey,
|
|
35
|
+
response_format: "json",
|
|
36
|
+
request_type: "",
|
|
37
|
+
},
|
|
38
|
+
echo: {},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create MiniQuoteFeed RequestBody
|
|
44
|
+
* Return MiniQuoteFeed RequestBody
|
|
45
|
+
* @function createMiniQuoteFeedRequest
|
|
46
|
+
* @param {Object[]} symbols - Array of subsribe Symbols
|
|
47
|
+
* @param {boolean} order - true for subsribe and false for unsubsribe
|
|
48
|
+
* @returns object
|
|
49
|
+
*/
|
|
50
|
+
createMiniQuoteFeedRequest = (symbols, miniQuote = false) => {
|
|
51
|
+
let body = {};
|
|
52
|
+
try {
|
|
53
|
+
body = this.requestBody();
|
|
54
|
+
const symset = symbols.map((sym) => ({ symbol: sym.trim() }));
|
|
55
|
+
|
|
56
|
+
body.request.data.symbols = symset;
|
|
57
|
+
|
|
58
|
+
if (miniQuote) {
|
|
59
|
+
body.request.request_type = "subscribe";
|
|
60
|
+
} else {
|
|
61
|
+
body.request.request_type = "unsubscribe";
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
log4js.debug("createMiniQuoteFeedRequest error - " + error);
|
|
65
|
+
} finally {
|
|
66
|
+
return body;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 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.
|
|
72
|
+
* @async
|
|
73
|
+
* @function subscribeMiniQuoteFeed
|
|
74
|
+
* @param {(err?, data?, close?: number) => void} callBack Callback to receive the Feed in
|
|
75
|
+
* @param {Array<string>} symbols Symbol list for subscription: Symbol_exchange to be obtained from Contract File
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
subscribeMiniQuoteFeed = async (symbols, callback) => {
|
|
79
|
+
try {
|
|
80
|
+
/** Validation Start */
|
|
81
|
+
const validateResponse = validateSubscribeMiniQuoteFeed(callback, symbols);
|
|
82
|
+
|
|
83
|
+
if (validateResponse.error) {
|
|
84
|
+
log4js.debug(
|
|
85
|
+
"subscribeMiniQuoteFeed validation error - " +
|
|
86
|
+
validateResponse.error.details
|
|
87
|
+
);
|
|
88
|
+
return Promise.reject(validateResponse.error.details);
|
|
89
|
+
}
|
|
90
|
+
/** Validation End */
|
|
91
|
+
|
|
92
|
+
/** Create Streaming MiniQuote Request */
|
|
93
|
+
let miniQuoteRequest = this.createMiniQuoteFeedRequest(symbols, true);
|
|
94
|
+
/** Call connect method of Feed Class */
|
|
95
|
+
this.feed.subsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest, callback);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
log4js.debug("subscribeMiniQuoteFeed error - " + error);
|
|
98
|
+
console.log(error);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* This method will unsubscribe the symbols from the streamer. After successful invokation of this, will stop the streamer packets of these symbols.
|
|
104
|
+
* @async
|
|
105
|
+
* @function unsubscribeMiniQuoteFeed
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
unsubscribeMiniQuoteFeed = async () => {
|
|
109
|
+
try {
|
|
110
|
+
/** Get Streaming MiniQuote Request */
|
|
111
|
+
const miniQuoteRequest = this.createMiniQuoteFeedRequest([]);
|
|
112
|
+
|
|
113
|
+
/** Unsubsribe symbols */
|
|
114
|
+
this.feed.unsubsribe(MINI_QUOTE_SREAM_REQ_CODE, miniQuoteRequest);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
log4js.debug("unsubscribeMiniQuoteFeed error - " + error);
|
|
117
|
+
console.log(error);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = MiniQuoteFeed;
|