market-data-tradingview-ws 0.0.1 → 0.0.2
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/index.js +2 -5
- package/lib/client.js +4 -4
- package/lib/tradingView.js +2 -2
- package/lib/utils.js +28 -28
- package/package.json +1 -2
- package/server.js +2 -2
package/index.js
CHANGED
package/lib/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const WebSocket = require('ws');
|
|
2
|
+
const tradingView = require('./tradingView.js');
|
|
3
3
|
|
|
4
4
|
const tv = new tradingView();
|
|
5
5
|
|
|
@@ -26,7 +26,7 @@ const sessions = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
module.exports = class Client {
|
|
30
30
|
#ws;
|
|
31
31
|
#sessions; // = new Map();
|
|
32
32
|
#token = null;
|
|
@@ -43,7 +43,7 @@ export class Client {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getSessionKeys() {
|
|
46
|
-
return this.#sessions.keys();
|
|
46
|
+
return this.#sessions.values.keys();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async getToken({ login, pass }) {
|
package/lib/tradingView.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const Utils = require('./utils.js');
|
|
2
2
|
const u = new Utils();
|
|
3
3
|
|
|
4
4
|
const letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
@@ -6,7 +6,7 @@ const cleanerRgx = /~h~/g;
|
|
|
6
6
|
const splitterRgx = /~m~[0-9]{1,}~m~/g;
|
|
7
7
|
const urlSymbolSearch = 'https://symbol-search.tradingview.com/symbol_search';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
module.exports = class tradingView {
|
|
10
10
|
async getToken({ login, pass }) {
|
|
11
11
|
const url = 'https://www.tradingview.com/accounts/signin/';
|
|
12
12
|
const headers = {
|
package/lib/utils.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import https from 'https';
|
|
1
|
+
// import https from 'https';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = class Utils {
|
|
4
4
|
pause(time = 1000) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
6
|
setTimeout(resolve, time);
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
request(options = {}, raw = false, content = '') {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
// request(options = {}, raw = false, content = '') {
|
|
11
|
+
// return new Promise((cb, err) => {
|
|
12
|
+
// const req = https.request(options, (res) => {
|
|
13
|
+
// let data = '';
|
|
14
|
+
// res.on('data', (c) => {
|
|
15
|
+
// data += c;
|
|
16
|
+
// });
|
|
17
|
+
// res.on('end', () => {
|
|
18
|
+
// if (raw) {
|
|
19
|
+
// cb({ data, cookies: res.headers['set-cookie'] });
|
|
20
|
+
// return;
|
|
21
|
+
// }
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
// try {
|
|
24
|
+
// data = JSON.parse(data);
|
|
25
|
+
// } catch (error) {
|
|
26
|
+
// console.log(data);
|
|
27
|
+
// err(new Error("Can't parse server response"));
|
|
28
|
+
// return;
|
|
29
|
+
// }
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// cb({ data, cookies: res.headers['set-cookie'] });
|
|
32
|
+
// });
|
|
33
|
+
// });
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
// req.on('error', err);
|
|
36
|
+
// req.end(content);
|
|
37
|
+
// });
|
|
38
|
+
// }
|
|
39
39
|
}
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
process.title = 'marketDataClient';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const Client = './lib/client.js';
|
|
6
|
+
const Utils = './lib/utils.js';
|
|
7
7
|
const u = new Utils();
|
|
8
8
|
|
|
9
9
|
const url = 'wss://data.tradingview.com/socket.io/websocket';
|