api_connect_nodejs 2.0.2 → 2.0.5
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 +19 -19
- package/enums/actionType.js +10 -10
- package/enums/assetType.js +25 -25
- package/enums/chartExchangeType.js +15 -15
- package/enums/chartType.js +13 -13
- package/enums/eodIntervalType.js +11 -11
- package/enums/exchangeType.js +14 -14
- 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/streamingConstants.js +14 -11
- 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 +2397 -2430
- package/src/apiUtils.js +221 -129
- package/src/chart.js +258 -258
- package/src/config.js +321 -326
- package/src/feed/depthFeed.js +137 -0
- package/src/feed/feed.js +162 -139
- package/src/feed/liveNewsFeed.js +112 -112
- package/src/feed/miniQuoteFeed.js +121 -0
- package/src/feed/ordersFeed.js +124 -124
- package/src/feed/quotesFeed.js +226 -121
- package/src/http.js +197 -197
- package/src/iniparser.js +42 -42
- package/src/liveNews.js +362 -362
- package/src/logger.js +16 -16
- package/src/order.js +48 -48
- package/src/quote.js +75 -0
- package/src/researchCalls.js +175 -175
- package/src/watchlist.js +378 -378
- package/validations/apiConnectValidator.js +521 -508
- package/validations/chartValidator.js +85 -85
- package/validations/feedStreamerValidator.js +162 -68
- package/validations/liveNewsValidator.js +60 -60
- package/validations/quoteValidator.js +19 -0
- package/validations/researchCallsValidator.js +86 -86
- package/validations/watchlistValidator.js +60 -60
package/src/http.js
CHANGED
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
const https = require("https");
|
|
2
|
-
const JSZip = require("jszip");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
class __Http {
|
|
5
|
-
constructor(constants, baseurl) {
|
|
6
|
-
this.__constants = constants;
|
|
7
|
-
this.__baseurl = baseurl;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
__fileName = "";
|
|
11
|
-
|
|
12
|
-
get fileName() {
|
|
13
|
-
return this.__VendorSession;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
set fileName(val) {
|
|
17
|
-
this.__VendorSession = val;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
createHeaders(sendSource) {
|
|
21
|
-
let headers = {
|
|
22
|
-
"Content-Type": "application/json",
|
|
23
|
-
"User-Agent":null,
|
|
24
|
-
Authorization: this.__constants.JSession,
|
|
25
|
-
SourceToken: this.__constants.VendorSession,
|
|
26
|
-
AppIdKey: this.__constants.AppIdKey,
|
|
27
|
-
};
|
|
28
|
-
if (sendSource) headers.Source = this.__constants.ApiKey;
|
|
29
|
-
return headers;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
GetMethod(url, sendSource = true) {
|
|
33
|
-
let headers = this.createHeaders(sendSource);
|
|
34
|
-
const options = { hostname: this.__baseurl, path: url, headers: headers };
|
|
35
|
-
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
const req = https.get(options, (res) => {
|
|
38
|
-
let body = [];
|
|
39
|
-
res.on("data", (d) => {
|
|
40
|
-
body.push(d);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
res.on("end", () => {
|
|
44
|
-
try {
|
|
45
|
-
body = JSON.parse(Buffer.concat(body).toString());
|
|
46
|
-
|
|
47
|
-
if (res.headers.appidkey) {
|
|
48
|
-
this.__constants.AppIdKey = res.headers.appidkey;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (res.statusCode === 200) {
|
|
52
|
-
resolve(body);
|
|
53
|
-
} else if (res.statusCode > 200 && res.statusCode <= 299) {
|
|
54
|
-
resolve("");
|
|
55
|
-
} else if (res.statusCode === 401 || res.statusCode === 403) {
|
|
56
|
-
fs.unlinkSync(this.fileName);
|
|
57
|
-
reject(body);
|
|
58
|
-
} else {
|
|
59
|
-
reject(body);
|
|
60
|
-
}
|
|
61
|
-
} catch (e) {
|
|
62
|
-
reject(e);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
req.on("error", reject);
|
|
68
|
-
req.end();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
PostMethod(url, data, sendSource = true) {
|
|
73
|
-
let headers = this.createHeaders(sendSource);
|
|
74
|
-
const options = {
|
|
75
|
-
hostname: this.__baseurl,
|
|
76
|
-
path: url,
|
|
77
|
-
method: "POST",
|
|
78
|
-
headers: headers,
|
|
79
|
-
};
|
|
80
|
-
return this.__postPutDeleteMethod(options, data);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
PutMethod(url, data) {
|
|
84
|
-
let headers = this.createHeaders();
|
|
85
|
-
const options = {
|
|
86
|
-
hostname: this.__baseurl,
|
|
87
|
-
path: url,
|
|
88
|
-
method: "PUT",
|
|
89
|
-
headers: headers,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
return this.__postPutDeleteMethod(options, data);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
DeleteMethod(url, data, sendSource = true) {
|
|
96
|
-
let headers = this.createHeaders(sendSource);
|
|
97
|
-
headers["Content-Length"] = Buffer.byteLength(JSON.stringify(data));
|
|
98
|
-
const options = {
|
|
99
|
-
hostname: this.__baseurl,
|
|
100
|
-
path: url,
|
|
101
|
-
method: "DELETE",
|
|
102
|
-
headers: headers,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
return this.__postPutDeleteMethod(options, data);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
__postPutDeleteMethod(options, data) {
|
|
109
|
-
return new Promise((resolve, reject) => {
|
|
110
|
-
const req = https.request(options, (res) => {
|
|
111
|
-
let body = [];
|
|
112
|
-
res.on("data", (d) => {
|
|
113
|
-
body.push(d);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
res.on("end", () => {
|
|
117
|
-
try {
|
|
118
|
-
body = JSON.parse(Buffer.concat(body).toString());
|
|
119
|
-
|
|
120
|
-
if (res.headers.appidkey) {
|
|
121
|
-
this.__constants.AppIdKey = res.headers.appidkey;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (res.statusCode === 200) {
|
|
125
|
-
resolve(body);
|
|
126
|
-
} else if (res.statusCode === 401 || res.statusCode === 403) {
|
|
127
|
-
try {
|
|
128
|
-
fs.unlinkSync(this.fileName);
|
|
129
|
-
} catch {
|
|
130
|
-
} finally {
|
|
131
|
-
reject(body);
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
reject(body);
|
|
135
|
-
}
|
|
136
|
-
} catch (e) {
|
|
137
|
-
reject(e);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
req.on("error", reject);
|
|
142
|
-
|
|
143
|
-
req.write(JSON.stringify(data));
|
|
144
|
-
req.end();
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
GetZipFileMethod(url, fileName) {
|
|
149
|
-
let headers = this.createHeaders();
|
|
150
|
-
const options = {
|
|
151
|
-
hostname: this.__baseurl,
|
|
152
|
-
path: url,
|
|
153
|
-
headers: headers,
|
|
154
|
-
secureProtocol: "TLSv1_2_method",
|
|
155
|
-
};
|
|
156
|
-
return new Promise((resolve, reject) => {
|
|
157
|
-
let body = [];
|
|
158
|
-
const req = https.get(
|
|
159
|
-
options,
|
|
160
|
-
(res) => {
|
|
161
|
-
res.on("data", (d) => {
|
|
162
|
-
body.push(d);
|
|
163
|
-
});
|
|
164
|
-
res.on("end", () => {
|
|
165
|
-
if (res.statusCode === 200) {
|
|
166
|
-
let buf = Buffer.concat(body);
|
|
167
|
-
|
|
168
|
-
function saveCSV(b) {
|
|
169
|
-
fs.writeFile(fileName, b, "binary", function (err) {
|
|
170
|
-
if (err) {
|
|
171
|
-
reject("could not extract file");
|
|
172
|
-
} else {
|
|
173
|
-
resolve();
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
JSZip.loadAsync(buf)
|
|
179
|
-
.then((zip) => zip.file(fileName).async("nodebuffer"))
|
|
180
|
-
.then(saveCSV);
|
|
181
|
-
} else {
|
|
182
|
-
reject(body);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
(err) => {
|
|
187
|
-
console.log("err", err);
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
req.on("error", reject);
|
|
192
|
-
req.end();
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
module.exports = __Http;
|
|
1
|
+
const https = require("https");
|
|
2
|
+
const JSZip = require("jszip");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
class __Http {
|
|
5
|
+
constructor(constants, baseurl) {
|
|
6
|
+
this.__constants = constants;
|
|
7
|
+
this.__baseurl = baseurl;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
__fileName = "";
|
|
11
|
+
|
|
12
|
+
get fileName() {
|
|
13
|
+
return this.__VendorSession;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
set fileName(val) {
|
|
17
|
+
this.__VendorSession = val;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
createHeaders(sendSource) {
|
|
21
|
+
let headers = {
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
"User-Agent":null,
|
|
24
|
+
Authorization: this.__constants.JSession,
|
|
25
|
+
SourceToken: this.__constants.VendorSession,
|
|
26
|
+
AppIdKey: this.__constants.AppIdKey,
|
|
27
|
+
};
|
|
28
|
+
if (sendSource) headers.Source = this.__constants.ApiKey;
|
|
29
|
+
return headers;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
GetMethod(url, sendSource = true) {
|
|
33
|
+
let headers = this.createHeaders(sendSource);
|
|
34
|
+
const options = { hostname: this.__baseurl, path: url, headers: headers };
|
|
35
|
+
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const req = https.get(options, (res) => {
|
|
38
|
+
let body = [];
|
|
39
|
+
res.on("data", (d) => {
|
|
40
|
+
body.push(d);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
res.on("end", () => {
|
|
44
|
+
try {
|
|
45
|
+
body = JSON.parse(Buffer.concat(body).toString());
|
|
46
|
+
|
|
47
|
+
if (res.headers.appidkey) {
|
|
48
|
+
this.__constants.AppIdKey = res.headers.appidkey;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (res.statusCode === 200) {
|
|
52
|
+
resolve(body);
|
|
53
|
+
} else if (res.statusCode > 200 && res.statusCode <= 299) {
|
|
54
|
+
resolve("");
|
|
55
|
+
} else if (res.statusCode === 401 || res.statusCode === 403) {
|
|
56
|
+
fs.unlinkSync(this.fileName);
|
|
57
|
+
reject(body);
|
|
58
|
+
} else {
|
|
59
|
+
reject(body);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
reject(e);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
req.on("error", reject);
|
|
68
|
+
req.end();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
PostMethod(url, data, sendSource = true) {
|
|
73
|
+
let headers = this.createHeaders(sendSource);
|
|
74
|
+
const options = {
|
|
75
|
+
hostname: this.__baseurl,
|
|
76
|
+
path: url,
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: headers,
|
|
79
|
+
};
|
|
80
|
+
return this.__postPutDeleteMethod(options, data);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
PutMethod(url, data) {
|
|
84
|
+
let headers = this.createHeaders();
|
|
85
|
+
const options = {
|
|
86
|
+
hostname: this.__baseurl,
|
|
87
|
+
path: url,
|
|
88
|
+
method: "PUT",
|
|
89
|
+
headers: headers,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return this.__postPutDeleteMethod(options, data);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
DeleteMethod(url, data, sendSource = true) {
|
|
96
|
+
let headers = this.createHeaders(sendSource);
|
|
97
|
+
headers["Content-Length"] = Buffer.byteLength(JSON.stringify(data));
|
|
98
|
+
const options = {
|
|
99
|
+
hostname: this.__baseurl,
|
|
100
|
+
path: url,
|
|
101
|
+
method: "DELETE",
|
|
102
|
+
headers: headers,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return this.__postPutDeleteMethod(options, data);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
__postPutDeleteMethod(options, data) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const req = https.request(options, (res) => {
|
|
111
|
+
let body = [];
|
|
112
|
+
res.on("data", (d) => {
|
|
113
|
+
body.push(d);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
res.on("end", () => {
|
|
117
|
+
try {
|
|
118
|
+
body = JSON.parse(Buffer.concat(body).toString());
|
|
119
|
+
|
|
120
|
+
if (res.headers.appidkey) {
|
|
121
|
+
this.__constants.AppIdKey = res.headers.appidkey;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (res.statusCode === 200) {
|
|
125
|
+
resolve(body);
|
|
126
|
+
} else if (res.statusCode === 401 || res.statusCode === 403) {
|
|
127
|
+
try {
|
|
128
|
+
fs.unlinkSync(this.fileName);
|
|
129
|
+
} catch {
|
|
130
|
+
} finally {
|
|
131
|
+
reject(body);
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
reject(body);
|
|
135
|
+
}
|
|
136
|
+
} catch (e) {
|
|
137
|
+
reject(e);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
req.on("error", reject);
|
|
142
|
+
|
|
143
|
+
req.write(JSON.stringify(data));
|
|
144
|
+
req.end();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
GetZipFileMethod(url, fileName) {
|
|
149
|
+
let headers = this.createHeaders();
|
|
150
|
+
const options = {
|
|
151
|
+
hostname: this.__baseurl,
|
|
152
|
+
path: url,
|
|
153
|
+
headers: headers,
|
|
154
|
+
secureProtocol: "TLSv1_2_method",
|
|
155
|
+
};
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
let body = [];
|
|
158
|
+
const req = https.get(
|
|
159
|
+
options,
|
|
160
|
+
(res) => {
|
|
161
|
+
res.on("data", (d) => {
|
|
162
|
+
body.push(d);
|
|
163
|
+
});
|
|
164
|
+
res.on("end", () => {
|
|
165
|
+
if (res.statusCode === 200) {
|
|
166
|
+
let buf = Buffer.concat(body);
|
|
167
|
+
|
|
168
|
+
function saveCSV(b) {
|
|
169
|
+
fs.writeFile(fileName, b, "binary", function (err) {
|
|
170
|
+
if (err) {
|
|
171
|
+
reject("could not extract file");
|
|
172
|
+
} else {
|
|
173
|
+
resolve();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
JSZip.loadAsync(buf)
|
|
179
|
+
.then((zip) => zip.file(fileName).async("nodebuffer"))
|
|
180
|
+
.then(saveCSV);
|
|
181
|
+
} else {
|
|
182
|
+
reject(body);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
(err) => {
|
|
187
|
+
console.log("err", err);
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
req.on("error", reject);
|
|
192
|
+
req.end();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
module.exports = __Http;
|
package/src/iniparser.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const ini = require("ini");
|
|
3
|
-
|
|
4
|
-
BasePathLogin = "";
|
|
5
|
-
BasePathEq = "";
|
|
6
|
-
BasePathComm = "";
|
|
7
|
-
BasePathMf = "";
|
|
8
|
-
BasePathContent = "";
|
|
9
|
-
ApiIdKey = "";
|
|
10
|
-
LogLevel = "";
|
|
11
|
-
hostName = "";
|
|
12
|
-
port = "";
|
|
13
|
-
formFactor = "";
|
|
14
|
-
|
|
15
|
-
const ConfigParser = function () {
|
|
16
|
-
var config = ini.parse(fs.readFileSync("./conf/settings.ini", "utf-8"));
|
|
17
|
-
BasePathLogin = config.GLOBAL.BasePathLogin;
|
|
18
|
-
BasePathEq = config.GLOBAL.BasePathEq;
|
|
19
|
-
BasePathComm = config.GLOBAL.BasePathComm;
|
|
20
|
-
BasePathMf = config.GLOBAL.BasePathMf;
|
|
21
|
-
BasePathContent = config.GLOBAL.BasePathContent;
|
|
22
|
-
ApiIdKey = config.GLOBAL.ApiIdKey;
|
|
23
|
-
LogLevel = config.GLOBAL.LogLevel;
|
|
24
|
-
hostName = config.STREAM.hostName;
|
|
25
|
-
port = config.STREAM.port;
|
|
26
|
-
formFactor = config.STREAM.formFactor;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
ConfigParser();
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
BasePathLogin,
|
|
33
|
-
BasePathEq,
|
|
34
|
-
BasePathComm,
|
|
35
|
-
BasePathMf,
|
|
36
|
-
ApiIdKey,
|
|
37
|
-
LogLevel,
|
|
38
|
-
hostName,
|
|
39
|
-
port,
|
|
40
|
-
formFactor,
|
|
41
|
-
BasePathContent,
|
|
42
|
-
};
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const ini = require("ini");
|
|
3
|
+
|
|
4
|
+
BasePathLogin = "";
|
|
5
|
+
BasePathEq = "";
|
|
6
|
+
BasePathComm = "";
|
|
7
|
+
BasePathMf = "";
|
|
8
|
+
BasePathContent = "";
|
|
9
|
+
ApiIdKey = "";
|
|
10
|
+
LogLevel = "";
|
|
11
|
+
hostName = "";
|
|
12
|
+
port = "";
|
|
13
|
+
formFactor = "";
|
|
14
|
+
|
|
15
|
+
const ConfigParser = function () {
|
|
16
|
+
var config = ini.parse(fs.readFileSync("./conf/settings.ini", "utf-8"));
|
|
17
|
+
BasePathLogin = config.GLOBAL.BasePathLogin;
|
|
18
|
+
BasePathEq = config.GLOBAL.BasePathEq;
|
|
19
|
+
BasePathComm = config.GLOBAL.BasePathComm;
|
|
20
|
+
BasePathMf = config.GLOBAL.BasePathMf;
|
|
21
|
+
BasePathContent = config.GLOBAL.BasePathContent;
|
|
22
|
+
ApiIdKey = config.GLOBAL.ApiIdKey;
|
|
23
|
+
LogLevel = config.GLOBAL.LogLevel;
|
|
24
|
+
hostName = config.STREAM.hostName;
|
|
25
|
+
port = config.STREAM.port;
|
|
26
|
+
formFactor = config.STREAM.formFactor;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
ConfigParser();
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
BasePathLogin,
|
|
33
|
+
BasePathEq,
|
|
34
|
+
BasePathComm,
|
|
35
|
+
BasePathMf,
|
|
36
|
+
ApiIdKey,
|
|
37
|
+
LogLevel,
|
|
38
|
+
hostName,
|
|
39
|
+
port,
|
|
40
|
+
formFactor,
|
|
41
|
+
BasePathContent,
|
|
42
|
+
};
|