@icgio/clients-config 1.0.273 → 1.0.275
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/.gitsecret/keys/crls.d/DIR.txt +1 -1
- package/.gitsecret/paths/mapping.cfg +1 -1
- package/config-archive.json +1 -12
- package/config.json +27 -3
- package/data-source.js.secret +0 -0
- package/index.js +19 -19
- package/package.json +27 -27
- package/secretread.js.secret +0 -0
- package/update-config-json.js +278 -278
|
@@ -1 +1 @@
|
|
|
1
|
-
v:1:
|
|
1
|
+
v:1:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
secretread.js:
|
|
1
|
+
secretread.js:eaf6aec5190330d3b1d712ddcee24c32bedc32e842dc84a5f03a3a18029a1a29
|
|
2
2
|
data-source.js:a88043810676f6017be94bbcc357f8f0d439890c6698cc0b02941b605e7dbd9a
|
package/config-archive.json
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"AVALOX": {
|
|
10
10
|
"Gate": ["AVALOXUSDT"],
|
|
11
|
-
"Mexc": ["AVALOXUSDT"],
|
|
12
11
|
"Bitmart": ["AVALOXUSDT"]
|
|
13
12
|
},
|
|
14
13
|
"AVAV": {
|
|
@@ -399,7 +398,7 @@
|
|
|
399
398
|
"ACLUSDT": ["Gate"]
|
|
400
399
|
},
|
|
401
400
|
"AVALOX": {
|
|
402
|
-
"AVALOXUSDT": ["
|
|
401
|
+
"AVALOXUSDT": ["Bitmart"]
|
|
403
402
|
},
|
|
404
403
|
"AVAV": {
|
|
405
404
|
"AVAVUSDT": ["Bitget"]
|
|
@@ -1053,7 +1052,6 @@
|
|
|
1053
1052
|
"balance": {
|
|
1054
1053
|
"AAI": true,
|
|
1055
1054
|
"ACL": true,
|
|
1056
|
-
"AVALOX": true,
|
|
1057
1055
|
"AVAV": true,
|
|
1058
1056
|
"AXL": true,
|
|
1059
1057
|
"BCHEM": true,
|
|
@@ -1145,7 +1143,6 @@
|
|
|
1145
1143
|
"trades": {
|
|
1146
1144
|
"AAI": true,
|
|
1147
1145
|
"ACL": true,
|
|
1148
|
-
"AVALOX": true,
|
|
1149
1146
|
"AVAV": true,
|
|
1150
1147
|
"AXL": true,
|
|
1151
1148
|
"BCHEM": true,
|
|
@@ -1230,7 +1227,6 @@
|
|
|
1230
1227
|
"client_levels": {
|
|
1231
1228
|
"AAI": [1, 2, 5, 10, 20, 50, 100],
|
|
1232
1229
|
"ACL": [10, 50, 100],
|
|
1233
|
-
"AVALOX": [1, 2, 5, 10, 20, 50, 100],
|
|
1234
1230
|
"AVAV": [2, 5, 10],
|
|
1235
1231
|
"AXL": [10, 50, 100],
|
|
1236
1232
|
"BCHEM": [1, 2, 5, 10, 20, 50, 100],
|
|
@@ -1316,7 +1312,6 @@
|
|
|
1316
1312
|
"client_price_index_curs": {
|
|
1317
1313
|
"AAI": ["BTC", "ETH"],
|
|
1318
1314
|
"ACL": ["BTC, ETH"],
|
|
1319
|
-
"AVALOX": ["BTC", "ETH"],
|
|
1320
1315
|
"AVAV": ["BTC", "ETH"],
|
|
1321
1316
|
"AXL": ["BTC", "ETH"],
|
|
1322
1317
|
"BCHEM": ["BTC", "ETH"],
|
|
@@ -1401,7 +1396,6 @@
|
|
|
1401
1396
|
"client_telegram_ids": {
|
|
1402
1397
|
"AAI": "-4873414367",
|
|
1403
1398
|
"ACL": "-4283734918",
|
|
1404
|
-
"AVALOX": "-1002106426914",
|
|
1405
1399
|
"AVAV": "-4199615909",
|
|
1406
1400
|
"AXL": "-1002044946729",
|
|
1407
1401
|
"BCHEM": "-4802690196",
|
|
@@ -1511,7 +1505,6 @@
|
|
|
1511
1505
|
},
|
|
1512
1506
|
"client_telegram_sender": {
|
|
1513
1507
|
"AAI": "icg",
|
|
1514
|
-
"AVALOX": "icg",
|
|
1515
1508
|
"AXL": "icg",
|
|
1516
1509
|
"BCHEM": "icg",
|
|
1517
1510
|
"BVT": "icg",
|
|
@@ -1557,10 +1550,6 @@
|
|
|
1557
1550
|
"username": "aai@icg.io",
|
|
1558
1551
|
"password": "beaHR4UKtHRKEuY"
|
|
1559
1552
|
},
|
|
1560
|
-
"AVALOX": {
|
|
1561
|
-
"username": "avalox@icg.io",
|
|
1562
|
-
"password": "omXfKUcHl2whb4W"
|
|
1563
|
-
},
|
|
1564
1553
|
"AXL": {
|
|
1565
1554
|
"username": "axl@icg.io",
|
|
1566
1555
|
"password": "lUzpE7Ku0elfayb"
|
package/config.json
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
"Bitrue": ["ARMYUSDT"],
|
|
5
5
|
"Mexc": ["ARMYUSDT"]
|
|
6
6
|
},
|
|
7
|
+
"AVALOX": {
|
|
8
|
+
"Mexc": ["AVALOXUSDT"]
|
|
9
|
+
},
|
|
7
10
|
"B3TR": {
|
|
8
11
|
"Bitrue": ["B3TRUSDT"],
|
|
9
12
|
"Mexc": ["B3TRUSDT"]
|
|
@@ -49,8 +52,7 @@
|
|
|
49
52
|
"OPUL": {
|
|
50
53
|
"Ascendex": ["OPULUSDT"],
|
|
51
54
|
"Gate": ["OPULUSDT"],
|
|
52
|
-
"Kucoin": ["OPULUSDT"]
|
|
53
|
-
"Weex": ["OPULUSDT"]
|
|
55
|
+
"Kucoin": ["OPULUSDT"]
|
|
54
56
|
},
|
|
55
57
|
"SARA": {
|
|
56
58
|
"Bitmart": ["SARAUSDT"]
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
},
|
|
71
73
|
"client_not_include_exchanges": {
|
|
72
74
|
"ARMY": [],
|
|
75
|
+
"AVALOX": [],
|
|
73
76
|
"B3TR": [],
|
|
74
77
|
"CCDOG": [],
|
|
75
78
|
"FREEZONE": [],
|
|
@@ -90,6 +93,9 @@
|
|
|
90
93
|
"ARMY": {
|
|
91
94
|
"ARMYUSDT": ["Mexc"]
|
|
92
95
|
},
|
|
96
|
+
"AVALOX": {
|
|
97
|
+
"AVALOXUSDT": ["Mexc"]
|
|
98
|
+
},
|
|
93
99
|
"B3TR": {
|
|
94
100
|
"B3TRUSDT": ["Bitrue", "Mexc"]
|
|
95
101
|
},
|
|
@@ -148,6 +154,11 @@
|
|
|
148
154
|
"orderbook": 1,
|
|
149
155
|
"deposits_withdrawals": 1
|
|
150
156
|
},
|
|
157
|
+
"AVALOX": {
|
|
158
|
+
"balance": 1,
|
|
159
|
+
"trades": 1,
|
|
160
|
+
"orderbook": 1
|
|
161
|
+
},
|
|
151
162
|
"B3TR": {
|
|
152
163
|
"balance": 1,
|
|
153
164
|
"trades": 1,
|
|
@@ -242,6 +253,7 @@
|
|
|
242
253
|
"client_enabled": {
|
|
243
254
|
"balance": {
|
|
244
255
|
"ARMY": true,
|
|
256
|
+
"AVALOX": true,
|
|
245
257
|
"B3TR": true,
|
|
246
258
|
"CCDOG": true,
|
|
247
259
|
"FREEZONE": true,
|
|
@@ -283,6 +295,7 @@
|
|
|
283
295
|
"trades_detail": {},
|
|
284
296
|
"trades": {
|
|
285
297
|
"ARMY": true,
|
|
298
|
+
"AVALOX": true,
|
|
286
299
|
"B3TR": true,
|
|
287
300
|
"CCDOG": true,
|
|
288
301
|
"FREEZONE": true,
|
|
@@ -303,6 +316,7 @@
|
|
|
303
316
|
},
|
|
304
317
|
"client_levels": {
|
|
305
318
|
"ARMY": [1, 2, 5, 10, 20, 50, 100],
|
|
319
|
+
"AVALOX": [1, 2, 5, 10, 20, 50, 100],
|
|
306
320
|
"B3TR": [1, 2, 5, 10, 20, 50, 100],
|
|
307
321
|
"CCDOG": [1, 2, 5, 10, 20, 50, 100],
|
|
308
322
|
"FREEZONE": [1, 2, 5, 10, 20, 50, 100],
|
|
@@ -321,6 +335,7 @@
|
|
|
321
335
|
},
|
|
322
336
|
"client_price_index_curs": {
|
|
323
337
|
"ARMY": ["BTC", "ETH"],
|
|
338
|
+
"AVALOX": ["BTC", "ETH"],
|
|
324
339
|
"B3TR": ["BTC", "ETH"],
|
|
325
340
|
"CCDOG": ["BTC", "ETH"],
|
|
326
341
|
"FREEZONE": ["BTC", "ETH"],
|
|
@@ -339,6 +354,7 @@
|
|
|
339
354
|
},
|
|
340
355
|
"client_telegram_ids": {
|
|
341
356
|
"ARMY": "-4733838023",
|
|
357
|
+
"AVALOX": "-1002106426914",
|
|
342
358
|
"B3TR": "-4957633893",
|
|
343
359
|
"CCDOG": "-4866473272",
|
|
344
360
|
"FREEZONE": "-5013286765",
|
|
@@ -372,6 +388,7 @@
|
|
|
372
388
|
"client_additional_telegram_ids": {},
|
|
373
389
|
"client_telegram_sender": {
|
|
374
390
|
"ARMY": "icg",
|
|
391
|
+
"AVALOX": "icg",
|
|
375
392
|
"B3TR": "icg",
|
|
376
393
|
"CCDOG": "icg",
|
|
377
394
|
"FREEZONE": "icg",
|
|
@@ -391,6 +408,7 @@
|
|
|
391
408
|
"dashboard_users": {
|
|
392
409
|
"ADMIN": { "username": "admin@icg.io" },
|
|
393
410
|
"ARMY": { "username": "army@icg.io" },
|
|
411
|
+
"AVALOX": {"username": "avalox@icg.io" },
|
|
394
412
|
"B3TR": { "username": "b3tr@icg.io" },
|
|
395
413
|
"CCDOG": { "username": "ccdog@icg.io" },
|
|
396
414
|
"FREEZONE": { "username": "freezone@icg.io" },
|
|
@@ -408,7 +426,13 @@
|
|
|
408
426
|
"SWFTC": { "username": "swftc@icg.io" },
|
|
409
427
|
"SWFTC-COINBASE": { "username": "swftc-coinbase@icg.io" }
|
|
410
428
|
},
|
|
411
|
-
"server_config_enabled": {
|
|
429
|
+
"server_config_enabled": {
|
|
430
|
+
"FREEZONE": true,
|
|
431
|
+
"HKBITEX-BTC": true,
|
|
432
|
+
"HKBITEX-ETH": true,
|
|
433
|
+
"MECO": true,
|
|
434
|
+
"SHRAP": true
|
|
435
|
+
},
|
|
412
436
|
"server_config_whitelist_ips": {},
|
|
413
437
|
"server_config_admin_whitelist_ips": {
|
|
414
438
|
"ARMY": ["172.105.237.102", "139.162.90.70"],
|
package/data-source.js.secret
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
function safe_require(path) {
|
|
2
|
-
try {
|
|
3
|
-
return require(path)
|
|
4
|
-
} catch (error) {
|
|
5
|
-
if (error.code === 'MODULE_NOT_FOUND') {
|
|
6
|
-
return {}
|
|
7
|
-
} else {
|
|
8
|
-
throw error
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
config: safe_require('./config.js'),
|
|
15
|
-
secretread: safe_require('./secretread.js').secret,
|
|
16
|
-
secretread_shared: safe_require('./secretread.js').shared,
|
|
17
|
-
'data-source': safe_require('./data-source.js'),
|
|
18
|
-
benchmarks: safe_require('./config-benchmarks.js'),
|
|
19
|
-
}
|
|
1
|
+
function safe_require(path) {
|
|
2
|
+
try {
|
|
3
|
+
return require(path)
|
|
4
|
+
} catch (error) {
|
|
5
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
6
|
+
return {}
|
|
7
|
+
} else {
|
|
8
|
+
throw error
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
config: safe_require('./config.js'),
|
|
15
|
+
secretread: safe_require('./secretread.js').secret,
|
|
16
|
+
secretread_shared: safe_require('./secretread.js').shared,
|
|
17
|
+
'data-source': safe_require('./data-source.js'),
|
|
18
|
+
benchmarks: safe_require('./config-benchmarks.js'),
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@icgio/clients-config",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/icgio/clients-config.git"
|
|
12
|
-
},
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/icgio/clients-config/issues"
|
|
17
|
-
},
|
|
18
|
-
"homepage": "https://github.com/icgio/clients-config#readme",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"lodash": "^4.17.20"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"fs-extra": "^11.2.0",
|
|
24
|
-
"node-cmd": "^5.0.0",
|
|
25
|
-
"prompt": "^1.3.0"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@icgio/clients-config",
|
|
3
|
+
"version": "1.0.275",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/icgio/clients-config.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/icgio/clients-config/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/icgio/clients-config#readme",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"lodash": "^4.17.20"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"fs-extra": "^11.2.0",
|
|
24
|
+
"node-cmd": "^5.0.0",
|
|
25
|
+
"prompt": "^1.3.0"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/secretread.js.secret
CHANGED
|
Binary file
|
package/update-config-json.js
CHANGED
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const prompt = require('prompt')
|
|
3
|
-
|
|
4
|
-
const config_file_path = './config.json'
|
|
5
|
-
const config_archive_file_path = './config-archive.json'
|
|
6
|
-
|
|
7
|
-
prompt.start()
|
|
8
|
-
|
|
9
|
-
function read_config_file(path) {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
fs.readFile(path, 'utf8', (err, data) => {
|
|
12
|
-
if (err) reject(err)
|
|
13
|
-
else resolve(data)
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function write_config_file(data, path) {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
fs.writeFile(path, JSON.stringify(data, null, 2), 'utf8', (err) => {
|
|
21
|
-
if (err) return reject(err)
|
|
22
|
-
else resolve()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function process_config() {
|
|
28
|
-
try {
|
|
29
|
-
const schema = {
|
|
30
|
-
properties: {
|
|
31
|
-
action: {
|
|
32
|
-
description: 'Enter the action ( add, delete )',
|
|
33
|
-
pattern: /^(add|delete)$/,
|
|
34
|
-
message: 'Action must be one of "add", "delete"',
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
client_name: {
|
|
38
|
-
description: 'Enter the client name you want to perform the action on',
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
prompt.get(schema, (err, result) => {
|
|
45
|
-
if (err) {
|
|
46
|
-
console.error(err)
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
switch (result.action) {
|
|
51
|
-
case 'add':
|
|
52
|
-
add_client(result.client_name)
|
|
53
|
-
break
|
|
54
|
-
case 'delete':
|
|
55
|
-
delete_client(result.client_name)
|
|
56
|
-
break
|
|
57
|
-
default:
|
|
58
|
-
console.log('Invalid action')
|
|
59
|
-
break
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error(`Error processing the config file: ${error}`)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function delete_client(client_name) {
|
|
68
|
-
read_config_file(config_file_path)
|
|
69
|
-
.then((config_file_data) => {
|
|
70
|
-
config_file_data = JSON.parse(config_file_data)
|
|
71
|
-
|
|
72
|
-
update_config_archive(config_file_data, client_name)
|
|
73
|
-
.then(() => {
|
|
74
|
-
delete config_file_data.client_exchange_pairs[client_name]
|
|
75
|
-
delete config_file_data.client_pair_main_exchanges[client_name]
|
|
76
|
-
delete config_file_data.client_not_include_exchanges[client_name]
|
|
77
|
-
delete config_file_data.client_levels[client_name]
|
|
78
|
-
delete config_file_data.client_price_index_curs[client_name]
|
|
79
|
-
delete config_file_data.client_telegram_ids[client_name]
|
|
80
|
-
delete config_file_data.clients_reporter_interval[client_name]
|
|
81
|
-
|
|
82
|
-
for (let key in config_file_data.client_enabled) {
|
|
83
|
-
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
84
|
-
delete config_file_data.client_enabled[key][client_name]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
write_config_file(config_file_data, config_file_path)
|
|
89
|
-
.then(() => {
|
|
90
|
-
console.log(`Client '${client_name}' has been deleted successfully.`)
|
|
91
|
-
})
|
|
92
|
-
.catch((err) => {
|
|
93
|
-
console.error(`Error writing to config file: ${err}`)
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
.catch((err) => {
|
|
97
|
-
console.error(`Error updating config archive: ${err}`)
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
.catch((err) => {
|
|
101
|
-
console.error(`Error reading config file: ${err}`)
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function add_client(client_name) {
|
|
106
|
-
const schema = {
|
|
107
|
-
properties: {
|
|
108
|
-
client_exchange_pairs: {
|
|
109
|
-
description: 'Enter client exchange pairs (JSON format i.e { "Mexc": ["RWXUSDT"], "Bitget": ["RWXUSDT"] } )',
|
|
110
|
-
required: true,
|
|
111
|
-
pattern: /^\{.*\}$/,
|
|
112
|
-
message: 'Please enter a valid JSON object.',
|
|
113
|
-
},
|
|
114
|
-
client_not_include_exchanges: {
|
|
115
|
-
description: 'Enter client not include exchanges (Comma-separated values, e.g., Jubi, Lbank)',
|
|
116
|
-
required: false,
|
|
117
|
-
},
|
|
118
|
-
client_pair_main_exchanges: {
|
|
119
|
-
description: 'Enter client pair main exchanges (JSON format i.e {"ETHUSDT": ["Bitget", "Gate"]} )',
|
|
120
|
-
required: true,
|
|
121
|
-
pattern: /^\{.*\}$/,
|
|
122
|
-
message: 'Please enter a valid JSON object.',
|
|
123
|
-
},
|
|
124
|
-
clients_reporter_interval: {
|
|
125
|
-
description: 'Enter clients reporter interval (JSON format i.e { "balance": 1, "trades": 1, "orderbook": 1} )',
|
|
126
|
-
required: true,
|
|
127
|
-
pattern: /^\{.*\}$/,
|
|
128
|
-
message: 'Please enter a valid JSON object.',
|
|
129
|
-
},
|
|
130
|
-
client_levels: {
|
|
131
|
-
description: 'Enter client levels (Comma-separated values, e.g. 2, 5, 10 ) ',
|
|
132
|
-
required: true,
|
|
133
|
-
},
|
|
134
|
-
client_price_index_curs: {
|
|
135
|
-
description: 'Enter client benchmarks (Comma-separated values, e.g., BTC,ETH)',
|
|
136
|
-
required: false,
|
|
137
|
-
},
|
|
138
|
-
client_telegram_ids: {
|
|
139
|
-
description: 'Enter client telegram ids i.e 1233457 ',
|
|
140
|
-
required: true,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
read_config_file(config_file_path)
|
|
145
|
-
.then((config_file_data) => {
|
|
146
|
-
prompt.get(schema, (err, result) => {
|
|
147
|
-
if (err) {
|
|
148
|
-
console.error(err)
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
config_file_data = JSON.parse(config_file_data)
|
|
152
|
-
|
|
153
|
-
let exchange_pairs = result.client_exchange_pairs.trim()
|
|
154
|
-
exchange_pairs = JSON.parse(exchange_pairs)
|
|
155
|
-
|
|
156
|
-
let pair_exchanges = result.client_pair_main_exchanges.trim()
|
|
157
|
-
pair_exchanges = JSON.parse(pair_exchanges)
|
|
158
|
-
|
|
159
|
-
let reporter_interval = result.clients_reporter_interval.trim()
|
|
160
|
-
reporter_interval = JSON.parse(reporter_interval)
|
|
161
|
-
|
|
162
|
-
let not_include_exchanges = []
|
|
163
|
-
if (result.client_not_include_exchanges) {
|
|
164
|
-
not_include_exchanges = result.client_not_include_exchanges.split(',').map((value) => value.trim())
|
|
165
|
-
not_include_exchanges.sort()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let benchmarks = []
|
|
169
|
-
if (result.client_price_index_curs) {
|
|
170
|
-
benchmarks = result.client_price_index_curs.split(',').map((value) => value.trim())
|
|
171
|
-
benchmarks.sort()
|
|
172
|
-
}
|
|
173
|
-
let levels = result.client_levels.split(',').map((value) => Number(value.trim()))
|
|
174
|
-
|
|
175
|
-
config_file_data.client_exchange_pairs[client_name] = exchange_pairs
|
|
176
|
-
config_file_data.client_pair_main_exchanges[client_name] = pair_exchanges
|
|
177
|
-
|
|
178
|
-
config_file_data.clients_reporter_interval[client_name] = reporter_interval
|
|
179
|
-
|
|
180
|
-
config_file_data.client_not_include_exchanges[client_name] = not_include_exchanges
|
|
181
|
-
config_file_data.client_levels[client_name] = levels
|
|
182
|
-
config_file_data.client_price_index_curs[client_name] = benchmarks
|
|
183
|
-
|
|
184
|
-
config_file_data.client_telegram_ids[client_name] = result.client_telegram_ids
|
|
185
|
-
|
|
186
|
-
config_file_data.client_exchange_pairs = sort(config_file_data.client_exchange_pairs)
|
|
187
|
-
config_file_data.client_pair_main_exchanges = sort(config_file_data.client_pair_main_exchanges)
|
|
188
|
-
config_file_data.clients_reporter_interval = sort(config_file_data.clients_reporter_interval)
|
|
189
|
-
config_file_data.client_not_include_exchanges = sort(config_file_data.client_not_include_exchanges)
|
|
190
|
-
config_file_data.client_levels = sort(config_file_data.client_levels)
|
|
191
|
-
config_file_data.client_price_index_curs = sort(config_file_data.client_price_index_curs)
|
|
192
|
-
config_file_data.client_telegram_ids = sort(config_file_data.client_telegram_ids)
|
|
193
|
-
|
|
194
|
-
write_config_file(config_file_data, config_file_path)
|
|
195
|
-
.then(() => {
|
|
196
|
-
console.log(`Client '${client_name}' has been added successfully.`)
|
|
197
|
-
})
|
|
198
|
-
.catch((err) => {
|
|
199
|
-
console.error(`Error writing to config file: ${err}`)
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
.catch((err) => {
|
|
204
|
-
console.error(`Error reading config file: ${err}`)
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function update_config_archive(config_file_data, client_name) {
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
210
|
-
read_config_file(config_archive_file_path)
|
|
211
|
-
.then((config_archive_data) => {
|
|
212
|
-
try {
|
|
213
|
-
config_archive_data = JSON.parse(config_archive_data)
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error(`Error parsing config archive data: ${error}`)
|
|
216
|
-
reject(error)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
config_archive_data.client_exchange_pairs[client_name] = config_file_data.client_exchange_pairs[client_name]
|
|
220
|
-
config_archive_data.client_pair_main_exchanges[client_name] = config_file_data.client_pair_main_exchanges[client_name]
|
|
221
|
-
config_archive_data.clients_reporter_interval[client_name] = config_file_data.clients_reporter_interval[client_name]
|
|
222
|
-
config_archive_data.client_not_include_exchanges[client_name] = config_file_data.client_not_include_exchanges[client_name]
|
|
223
|
-
config_archive_data.client_levels[client_name] = config_file_data.client_levels[client_name]
|
|
224
|
-
config_archive_data.client_price_index_curs[client_name] = config_file_data.client_price_index_curs[client_name]
|
|
225
|
-
config_archive_data.client_telegram_ids[client_name] = config_file_data.client_telegram_ids[client_name]
|
|
226
|
-
|
|
227
|
-
if (!config_archive_data.client_enabled) {
|
|
228
|
-
config_archive_data.client_enabled = {}
|
|
229
|
-
}
|
|
230
|
-
for (let key in config_file_data.client_enabled) {
|
|
231
|
-
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
232
|
-
if (!config_archive_data.client_enabled[key]) {
|
|
233
|
-
config_archive_data.client_enabled[key] = {}
|
|
234
|
-
}
|
|
235
|
-
config_archive_data.client_enabled[key][client_name] = config_file_data.client_enabled[key][client_name]
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
config_archive_data.client_exchange_pairs = sort(config_archive_data.client_exchange_pairs)
|
|
240
|
-
config_archive_data.client_pair_main_exchanges = sort(config_archive_data.client_pair_main_exchanges)
|
|
241
|
-
config_archive_data.clients_reporter_interval = sort(config_archive_data.clients_reporter_interval)
|
|
242
|
-
config_archive_data.client_not_include_exchanges = sort(config_archive_data.client_not_include_exchanges)
|
|
243
|
-
config_archive_data.client_levels = sort(config_archive_data.client_levels)
|
|
244
|
-
config_archive_data.client_price_index_curs = sort(config_archive_data.client_price_index_curs)
|
|
245
|
-
config_archive_data.client_telegram_ids = sort(config_archive_data.client_telegram_ids)
|
|
246
|
-
|
|
247
|
-
for (let key in config_archive_data.client_enabled) {
|
|
248
|
-
if (config_archive_data.client_enabled.hasOwnProperty(key)) {
|
|
249
|
-
config_archive_data.client_enabled[key] = sort(config_archive_data.client_enabled[key])
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
write_config_file(config_archive_data, config_archive_file_path)
|
|
254
|
-
.then(() => {
|
|
255
|
-
resolve()
|
|
256
|
-
})
|
|
257
|
-
.catch((err) => {
|
|
258
|
-
console.error(`Error writing to config file: ${err}`)
|
|
259
|
-
reject(err)
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
.catch((err) => {
|
|
263
|
-
console.error(`Error reading config archive file: ${err}`)
|
|
264
|
-
reject(err)
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function sort(obj) {
|
|
270
|
-
return Object.keys(obj)
|
|
271
|
-
.sort()
|
|
272
|
-
.reduce((result, key) => {
|
|
273
|
-
result[key] = obj[key]
|
|
274
|
-
return result
|
|
275
|
-
}, {})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
process_config()
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const prompt = require('prompt')
|
|
3
|
+
|
|
4
|
+
const config_file_path = './config.json'
|
|
5
|
+
const config_archive_file_path = './config-archive.json'
|
|
6
|
+
|
|
7
|
+
prompt.start()
|
|
8
|
+
|
|
9
|
+
function read_config_file(path) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
fs.readFile(path, 'utf8', (err, data) => {
|
|
12
|
+
if (err) reject(err)
|
|
13
|
+
else resolve(data)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function write_config_file(data, path) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
fs.writeFile(path, JSON.stringify(data, null, 2), 'utf8', (err) => {
|
|
21
|
+
if (err) return reject(err)
|
|
22
|
+
else resolve()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function process_config() {
|
|
28
|
+
try {
|
|
29
|
+
const schema = {
|
|
30
|
+
properties: {
|
|
31
|
+
action: {
|
|
32
|
+
description: 'Enter the action ( add, delete )',
|
|
33
|
+
pattern: /^(add|delete)$/,
|
|
34
|
+
message: 'Action must be one of "add", "delete"',
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
client_name: {
|
|
38
|
+
description: 'Enter the client name you want to perform the action on',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
prompt.get(schema, (err, result) => {
|
|
45
|
+
if (err) {
|
|
46
|
+
console.error(err)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
switch (result.action) {
|
|
51
|
+
case 'add':
|
|
52
|
+
add_client(result.client_name)
|
|
53
|
+
break
|
|
54
|
+
case 'delete':
|
|
55
|
+
delete_client(result.client_name)
|
|
56
|
+
break
|
|
57
|
+
default:
|
|
58
|
+
console.log('Invalid action')
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(`Error processing the config file: ${error}`)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function delete_client(client_name) {
|
|
68
|
+
read_config_file(config_file_path)
|
|
69
|
+
.then((config_file_data) => {
|
|
70
|
+
config_file_data = JSON.parse(config_file_data)
|
|
71
|
+
|
|
72
|
+
update_config_archive(config_file_data, client_name)
|
|
73
|
+
.then(() => {
|
|
74
|
+
delete config_file_data.client_exchange_pairs[client_name]
|
|
75
|
+
delete config_file_data.client_pair_main_exchanges[client_name]
|
|
76
|
+
delete config_file_data.client_not_include_exchanges[client_name]
|
|
77
|
+
delete config_file_data.client_levels[client_name]
|
|
78
|
+
delete config_file_data.client_price_index_curs[client_name]
|
|
79
|
+
delete config_file_data.client_telegram_ids[client_name]
|
|
80
|
+
delete config_file_data.clients_reporter_interval[client_name]
|
|
81
|
+
|
|
82
|
+
for (let key in config_file_data.client_enabled) {
|
|
83
|
+
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
84
|
+
delete config_file_data.client_enabled[key][client_name]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
write_config_file(config_file_data, config_file_path)
|
|
89
|
+
.then(() => {
|
|
90
|
+
console.log(`Client '${client_name}' has been deleted successfully.`)
|
|
91
|
+
})
|
|
92
|
+
.catch((err) => {
|
|
93
|
+
console.error(`Error writing to config file: ${err}`)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
console.error(`Error updating config archive: ${err}`)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
.catch((err) => {
|
|
101
|
+
console.error(`Error reading config file: ${err}`)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function add_client(client_name) {
|
|
106
|
+
const schema = {
|
|
107
|
+
properties: {
|
|
108
|
+
client_exchange_pairs: {
|
|
109
|
+
description: 'Enter client exchange pairs (JSON format i.e { "Mexc": ["RWXUSDT"], "Bitget": ["RWXUSDT"] } )',
|
|
110
|
+
required: true,
|
|
111
|
+
pattern: /^\{.*\}$/,
|
|
112
|
+
message: 'Please enter a valid JSON object.',
|
|
113
|
+
},
|
|
114
|
+
client_not_include_exchanges: {
|
|
115
|
+
description: 'Enter client not include exchanges (Comma-separated values, e.g., Jubi, Lbank)',
|
|
116
|
+
required: false,
|
|
117
|
+
},
|
|
118
|
+
client_pair_main_exchanges: {
|
|
119
|
+
description: 'Enter client pair main exchanges (JSON format i.e {"ETHUSDT": ["Bitget", "Gate"]} )',
|
|
120
|
+
required: true,
|
|
121
|
+
pattern: /^\{.*\}$/,
|
|
122
|
+
message: 'Please enter a valid JSON object.',
|
|
123
|
+
},
|
|
124
|
+
clients_reporter_interval: {
|
|
125
|
+
description: 'Enter clients reporter interval (JSON format i.e { "balance": 1, "trades": 1, "orderbook": 1} )',
|
|
126
|
+
required: true,
|
|
127
|
+
pattern: /^\{.*\}$/,
|
|
128
|
+
message: 'Please enter a valid JSON object.',
|
|
129
|
+
},
|
|
130
|
+
client_levels: {
|
|
131
|
+
description: 'Enter client levels (Comma-separated values, e.g. 2, 5, 10 ) ',
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
client_price_index_curs: {
|
|
135
|
+
description: 'Enter client benchmarks (Comma-separated values, e.g., BTC,ETH)',
|
|
136
|
+
required: false,
|
|
137
|
+
},
|
|
138
|
+
client_telegram_ids: {
|
|
139
|
+
description: 'Enter client telegram ids i.e 1233457 ',
|
|
140
|
+
required: true,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
read_config_file(config_file_path)
|
|
145
|
+
.then((config_file_data) => {
|
|
146
|
+
prompt.get(schema, (err, result) => {
|
|
147
|
+
if (err) {
|
|
148
|
+
console.error(err)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
config_file_data = JSON.parse(config_file_data)
|
|
152
|
+
|
|
153
|
+
let exchange_pairs = result.client_exchange_pairs.trim()
|
|
154
|
+
exchange_pairs = JSON.parse(exchange_pairs)
|
|
155
|
+
|
|
156
|
+
let pair_exchanges = result.client_pair_main_exchanges.trim()
|
|
157
|
+
pair_exchanges = JSON.parse(pair_exchanges)
|
|
158
|
+
|
|
159
|
+
let reporter_interval = result.clients_reporter_interval.trim()
|
|
160
|
+
reporter_interval = JSON.parse(reporter_interval)
|
|
161
|
+
|
|
162
|
+
let not_include_exchanges = []
|
|
163
|
+
if (result.client_not_include_exchanges) {
|
|
164
|
+
not_include_exchanges = result.client_not_include_exchanges.split(',').map((value) => value.trim())
|
|
165
|
+
not_include_exchanges.sort()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let benchmarks = []
|
|
169
|
+
if (result.client_price_index_curs) {
|
|
170
|
+
benchmarks = result.client_price_index_curs.split(',').map((value) => value.trim())
|
|
171
|
+
benchmarks.sort()
|
|
172
|
+
}
|
|
173
|
+
let levels = result.client_levels.split(',').map((value) => Number(value.trim()))
|
|
174
|
+
|
|
175
|
+
config_file_data.client_exchange_pairs[client_name] = exchange_pairs
|
|
176
|
+
config_file_data.client_pair_main_exchanges[client_name] = pair_exchanges
|
|
177
|
+
|
|
178
|
+
config_file_data.clients_reporter_interval[client_name] = reporter_interval
|
|
179
|
+
|
|
180
|
+
config_file_data.client_not_include_exchanges[client_name] = not_include_exchanges
|
|
181
|
+
config_file_data.client_levels[client_name] = levels
|
|
182
|
+
config_file_data.client_price_index_curs[client_name] = benchmarks
|
|
183
|
+
|
|
184
|
+
config_file_data.client_telegram_ids[client_name] = result.client_telegram_ids
|
|
185
|
+
|
|
186
|
+
config_file_data.client_exchange_pairs = sort(config_file_data.client_exchange_pairs)
|
|
187
|
+
config_file_data.client_pair_main_exchanges = sort(config_file_data.client_pair_main_exchanges)
|
|
188
|
+
config_file_data.clients_reporter_interval = sort(config_file_data.clients_reporter_interval)
|
|
189
|
+
config_file_data.client_not_include_exchanges = sort(config_file_data.client_not_include_exchanges)
|
|
190
|
+
config_file_data.client_levels = sort(config_file_data.client_levels)
|
|
191
|
+
config_file_data.client_price_index_curs = sort(config_file_data.client_price_index_curs)
|
|
192
|
+
config_file_data.client_telegram_ids = sort(config_file_data.client_telegram_ids)
|
|
193
|
+
|
|
194
|
+
write_config_file(config_file_data, config_file_path)
|
|
195
|
+
.then(() => {
|
|
196
|
+
console.log(`Client '${client_name}' has been added successfully.`)
|
|
197
|
+
})
|
|
198
|
+
.catch((err) => {
|
|
199
|
+
console.error(`Error writing to config file: ${err}`)
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
.catch((err) => {
|
|
204
|
+
console.error(`Error reading config file: ${err}`)
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function update_config_archive(config_file_data, client_name) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
read_config_file(config_archive_file_path)
|
|
211
|
+
.then((config_archive_data) => {
|
|
212
|
+
try {
|
|
213
|
+
config_archive_data = JSON.parse(config_archive_data)
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error(`Error parsing config archive data: ${error}`)
|
|
216
|
+
reject(error)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
config_archive_data.client_exchange_pairs[client_name] = config_file_data.client_exchange_pairs[client_name]
|
|
220
|
+
config_archive_data.client_pair_main_exchanges[client_name] = config_file_data.client_pair_main_exchanges[client_name]
|
|
221
|
+
config_archive_data.clients_reporter_interval[client_name] = config_file_data.clients_reporter_interval[client_name]
|
|
222
|
+
config_archive_data.client_not_include_exchanges[client_name] = config_file_data.client_not_include_exchanges[client_name]
|
|
223
|
+
config_archive_data.client_levels[client_name] = config_file_data.client_levels[client_name]
|
|
224
|
+
config_archive_data.client_price_index_curs[client_name] = config_file_data.client_price_index_curs[client_name]
|
|
225
|
+
config_archive_data.client_telegram_ids[client_name] = config_file_data.client_telegram_ids[client_name]
|
|
226
|
+
|
|
227
|
+
if (!config_archive_data.client_enabled) {
|
|
228
|
+
config_archive_data.client_enabled = {}
|
|
229
|
+
}
|
|
230
|
+
for (let key in config_file_data.client_enabled) {
|
|
231
|
+
if (config_file_data.client_enabled.hasOwnProperty(key)) {
|
|
232
|
+
if (!config_archive_data.client_enabled[key]) {
|
|
233
|
+
config_archive_data.client_enabled[key] = {}
|
|
234
|
+
}
|
|
235
|
+
config_archive_data.client_enabled[key][client_name] = config_file_data.client_enabled[key][client_name]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
config_archive_data.client_exchange_pairs = sort(config_archive_data.client_exchange_pairs)
|
|
240
|
+
config_archive_data.client_pair_main_exchanges = sort(config_archive_data.client_pair_main_exchanges)
|
|
241
|
+
config_archive_data.clients_reporter_interval = sort(config_archive_data.clients_reporter_interval)
|
|
242
|
+
config_archive_data.client_not_include_exchanges = sort(config_archive_data.client_not_include_exchanges)
|
|
243
|
+
config_archive_data.client_levels = sort(config_archive_data.client_levels)
|
|
244
|
+
config_archive_data.client_price_index_curs = sort(config_archive_data.client_price_index_curs)
|
|
245
|
+
config_archive_data.client_telegram_ids = sort(config_archive_data.client_telegram_ids)
|
|
246
|
+
|
|
247
|
+
for (let key in config_archive_data.client_enabled) {
|
|
248
|
+
if (config_archive_data.client_enabled.hasOwnProperty(key)) {
|
|
249
|
+
config_archive_data.client_enabled[key] = sort(config_archive_data.client_enabled[key])
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
write_config_file(config_archive_data, config_archive_file_path)
|
|
254
|
+
.then(() => {
|
|
255
|
+
resolve()
|
|
256
|
+
})
|
|
257
|
+
.catch((err) => {
|
|
258
|
+
console.error(`Error writing to config file: ${err}`)
|
|
259
|
+
reject(err)
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
.catch((err) => {
|
|
263
|
+
console.error(`Error reading config archive file: ${err}`)
|
|
264
|
+
reject(err)
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function sort(obj) {
|
|
270
|
+
return Object.keys(obj)
|
|
271
|
+
.sort()
|
|
272
|
+
.reduce((result, key) => {
|
|
273
|
+
result[key] = obj[key]
|
|
274
|
+
return result
|
|
275
|
+
}, {})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
process_config()
|