@icgio/clients-config 1.0.217 → 1.0.219

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.
@@ -1,2 +1,2 @@
1
- secretread.js:1d9c27ff4a86cc116725710486b74d4cc395c38f30cdb1962db597a6e07737b0
1
+ secretread.js:2f3e5496e95656c1ef0d386df618330eef19d2d8e039cdfc6439b6f8308214c2
2
2
  data-source.js:a88043810676f6017be94bbcc357f8f0d439890c6698cc0b02941b605e7dbd9a
@@ -108,6 +108,10 @@
108
108
  "ILMT": {
109
109
  "Mexc": ["ILMTUSDT"]
110
110
  },
111
+ "IONX": {
112
+ "Gate": ["IONXUSDT"],
113
+ "Mexc": ["IONXUSDT"]
114
+ },
111
115
  "JASMY": {
112
116
  "Bitmart": ["JASMYUSDT"]
113
117
  },
@@ -204,6 +208,9 @@
204
208
  "SBT": {
205
209
  "Mexc": ["SBTUSDT"]
206
210
  },
211
+ "SHRAP": {
212
+ "Lbank": ["SHRAPUSDT"]
213
+ },
207
214
  "SHROOMY": {
208
215
  "Bitmart": ["SHROOMYUSDT"],
209
216
  "Lbank": ["SHROOMYUSDT"],
@@ -304,6 +311,7 @@
304
311
  "GKB": [],
305
312
  "HMTT": [],
306
313
  "ILMT": [],
314
+ "IONX": [],
307
315
  "JASMY": [],
308
316
  "KOAVA": [],
309
317
  "LANLAN": [],
@@ -329,6 +337,7 @@
329
337
  "ROBIE": [],
330
338
  "RWX": [],
331
339
  "SBT": [],
340
+ "SHRAP": [],
332
341
  "SHROOMY": [],
333
342
  "SPONSTAR": [],
334
343
  "TAZZ": [],
@@ -438,6 +447,9 @@
438
447
  "ILMT": {
439
448
  "ILMTUSDT": ["Mexc"]
440
449
  },
450
+ "IONX": {
451
+ "IONXUSDT": ["Gate", "Mexc"]
452
+ },
441
453
  "JASMY": {
442
454
  "JASMYUSDT": ["Bitmart"]
443
455
  },
@@ -516,6 +528,9 @@
516
528
  "SBT": {
517
529
  "SBTUSDT": ["Mexc"]
518
530
  },
531
+ "SHRAP": {
532
+ "SHRAPUSDT": ["Lbank"]
533
+ },
519
534
  "SHROOMY": {
520
535
  "SHROOMYUSDT": ["Bitmart", "Lbank", "Mexc", "Xt"]
521
536
  },
@@ -730,6 +745,11 @@
730
745
  "trades": 1,
731
746
  "orderbook": 1
732
747
  },
748
+ "IONX": {
749
+ "balance": 1,
750
+ "trades": 1,
751
+ "orderbook": 1
752
+ },
733
753
  "JASMY": {
734
754
  "balance": 1,
735
755
  "trades": 1,
@@ -840,6 +860,11 @@
840
860
  "trades": 1,
841
861
  "orderbook": 1
842
862
  },
863
+ "SHRAP": {
864
+ "balance": 1,
865
+ "trades": 1,
866
+ "orderbook": 1
867
+ },
843
868
  "SHROOMY": {
844
869
  "balance": 1,
845
870
  "trades": 1,
@@ -974,6 +999,7 @@
974
999
  "RED": true,
975
1000
  "ROBIE": true,
976
1001
  "SBT": true,
1002
+ "SHRAP": true,
977
1003
  "SHROOMY": true,
978
1004
  "SPONSTAR": true,
979
1005
  "TAZZ": true,
@@ -991,6 +1017,7 @@
991
1017
  },
992
1018
  "balance_cur": {
993
1019
  "BONG": true,
1020
+ "IONX": true,
994
1021
  "XERT": true
995
1022
  },
996
1023
  "total_in_usd": {
@@ -1031,6 +1058,7 @@
1031
1058
  "GKB": true,
1032
1059
  "HMTT": true,
1033
1060
  "ILMT": true,
1061
+ "IONX": true,
1034
1062
  "JASMY": true,
1035
1063
  "LANLAN": true,
1036
1064
  "LORDS": true,
@@ -1051,6 +1079,7 @@
1051
1079
  "PUNK1210": true,
1052
1080
  "RED": true,
1053
1081
  "ROBIE": true,
1082
+ "SHRAP": true,
1054
1083
  "SHROOMY": true,
1055
1084
  "SPONSTAR": true,
1056
1085
  "TAZZ": true,
@@ -1109,6 +1138,7 @@
1109
1138
  "GKB": [2, 5, 10],
1110
1139
  "HMTT": [2, 5, 10],
1111
1140
  "ILMT": [1, 2, 5, 10, 20, 50, 100],
1141
+ "IONX": [1, 2, 5, 10, 20, 50, 100],
1112
1142
  "JASMY": [10, 50, 100],
1113
1143
  "KOAVA": [2, 5, 10],
1114
1144
  "LANLAN": [1, 2, 5, 10, 20, 50, 100],
@@ -1134,6 +1164,7 @@
1134
1164
  "ROBIE": [10, 50, 100],
1135
1165
  "RWX": [2, 5, 10],
1136
1166
  "SBT": [2, 5, 10],
1167
+ "SHRAP": [1, 2, 5, 10, 20, 50, 100],
1137
1168
  "SHROOMY": [10, 50, 100],
1138
1169
  "SPONSTAR": [10, 50, 100],
1139
1170
  "TAZZ": [10, 50, 100],
@@ -1184,6 +1215,7 @@
1184
1215
  "GKB": ["BTC", "ETH"],
1185
1216
  "HMTT": ["BTC", "ETH"],
1186
1217
  "ILMT": ["BTC", "ETH"],
1218
+ "IONX": ["BTC", "ETH"],
1187
1219
  "JASMY": ["BTC", "ETH"],
1188
1220
  "KOAVA": ["BTC", "ETH"],
1189
1221
  "LANLAN": ["BTC", "ETH"],
@@ -1209,6 +1241,7 @@
1209
1241
  "ROBIE": ["BTC", "ETH"],
1210
1242
  "RWX": ["BTC", "ETH"],
1211
1243
  "SBT": ["BTC", "ETH"],
1244
+ "SHRAP": ["BTC", "ETH"],
1212
1245
  "SHROOMY": ["BTC", "ETH"],
1213
1246
  "SPONSTAR": ["BTC", "ETH"],
1214
1247
  "TAZZ": ["BTC", "ETH"],
@@ -1260,6 +1293,7 @@
1260
1293
  "GKB": "-4213454386",
1261
1294
  "HMTT": "-1002035174196",
1262
1295
  "ILMT": "-4802252746",
1296
+ "IONX": "-1002085059560",
1263
1297
  "JASMY": "-1002118117567",
1264
1298
  "KOAVA": "-1002045767005",
1265
1299
  "LANLAN": "-4886059689",
@@ -1285,6 +1319,7 @@
1285
1319
  "ROBIE": "-1002255146718",
1286
1320
  "RWX": "-1002045767005",
1287
1321
  "SBT": "-4524273717",
1322
+ "SHRAP": "-1001996867582",
1288
1323
  "SHROOMY": "-4777465585",
1289
1324
  "SPONSTAR": "-4727729020",
1290
1325
  "TAZZ": "-4506672630",
@@ -1307,6 +1342,11 @@
1307
1342
  "ZUSHI": "-4279552239"
1308
1343
  },
1309
1344
  "balance_premium": {
1345
+ "IONX": {
1346
+ "mexc_1": {
1347
+ "IONX": 10000000
1348
+ }
1349
+ },
1310
1350
  "SPONSTAR": {
1311
1351
  "mexc_1": {
1312
1352
  "USDT": 10000
@@ -1336,6 +1376,7 @@
1336
1376
  "ELON": "icg",
1337
1377
  "EPEP": "icg",
1338
1378
  "ILMT": "icg",
1379
+ "IONX": "icg",
1339
1380
  "JASMY": "icg",
1340
1381
  "LANLAN": "icg",
1341
1382
  "LORDS": "icg",
@@ -1344,6 +1385,7 @@
1344
1385
  "PACT": "icg",
1345
1386
  "POLY": "icg",
1346
1387
  "ROBIE": "liquidity",
1388
+ "SHRAP": "icg",
1347
1389
  "SHROOMY": "icg",
1348
1390
  "SPONSTAR": "icg",
1349
1391
  "TAZZ": "icg",
@@ -1407,6 +1449,10 @@
1407
1449
  "username": "ilmt@icg.io",
1408
1450
  "password": "b8X06ltUjvpF0Pt"
1409
1451
  },
1452
+ "IONX": {
1453
+ "username": "ionx@icg.io",
1454
+ "password": "gW5vZbXQp3BseNH"
1455
+ },
1410
1456
  "JASMY": {
1411
1457
  "username": "jasmy@icg.io",
1412
1458
  "password": "2p5saQCm8n43y14"
@@ -1435,6 +1481,10 @@
1435
1481
  "username": "robie@icg.io",
1436
1482
  "password": "BcdJaoPYVZqtVgp"
1437
1483
  },
1484
+ "SHRAP": {
1485
+ "username": "shrap@icg.io",
1486
+ "password": "0C6RlEOsWQ0MK2G"
1487
+ },
1438
1488
  "SHROOMY": {
1439
1489
  "username": "shroomy@icg.io",
1440
1490
  "password": "Imp41y4UBXqhMrw"
package/config.json CHANGED
@@ -24,14 +24,11 @@
24
24
  "HKBITEX-ETH": {
25
25
  "Hkbitex": ["ETHUSD", "ETHHKD"]
26
26
  },
27
- "IONX": {
28
- "Gate": ["IONXUSDT"],
29
- "Mexc": ["IONXUSDT"]
30
- },
31
27
  "JYAI": {
32
28
  "Bingx": ["JYAIUSDT"],
33
29
  "Bitmart": ["JYAIUSDT"],
34
30
  "Lbank": ["JYAIUSDT"],
31
+ "Mexc": ["JYAIUSDT"],
35
32
  "Xt": ["JYAIUSDT"]
36
33
  },
37
34
  "LST": {
@@ -55,9 +52,6 @@
55
52
  "SARA": {
56
53
  "Bitmart": ["SARAUSDT"]
57
54
  },
58
- "SHRAP": {
59
- "Lbank": ["SHRAPUSDT"]
60
- },
61
55
  "SLOR": {
62
56
  "Superex": ["SLORUSDT"]
63
57
  },
@@ -83,7 +77,6 @@
83
77
  "GO": [],
84
78
  "HKBITEX-BTC": [],
85
79
  "HKBITEX-ETH": [],
86
- "IONX": [],
87
80
  "JYAI": [],
88
81
  "LST": [],
89
82
  "LUCIC": [],
@@ -91,7 +84,6 @@
91
84
  "MIX": [],
92
85
  "OPUL": [],
93
86
  "SARA": [],
94
- "SHRAP": [],
95
87
  "SLOR": [],
96
88
  "SWFTC": ["Lbank"],
97
89
  "TACC": [],
@@ -121,11 +113,8 @@
121
113
  "ETHUSD": ["Hkbitex"],
122
114
  "ETHHKD": ["Hkbitex"]
123
115
  },
124
- "IONX": {
125
- "IONXUSDT": ["Gate", "Mexc"]
126
- },
127
116
  "JYAI": {
128
- "JYAIUSDT": ["Bingx", "Bitmart", "Lbank", "Xt"]
117
+ "JYAIUSDT": ["Bingx", "Bitmart", "Lbank", "Mexc", "Xt"]
129
118
  },
130
119
  "LST": {
131
120
  "LSTUSDT": ["Bitmart"]
@@ -145,9 +134,6 @@
145
134
  "SARA": {
146
135
  "SARAUSDT": ["Bitmart"]
147
136
  },
148
- "SHRAP": {
149
- "SHRAPUSDT": ["Lbank"]
150
- },
151
137
  "SLOR": {
152
138
  "SLORUSDT": ["Superex"]
153
139
  },
@@ -198,11 +184,6 @@
198
184
  "trades": 1,
199
185
  "orderbook": 1
200
186
  },
201
- "IONX": {
202
- "balance": 1,
203
- "trades": 1,
204
- "orderbook": 1
205
- },
206
187
  "JYAI": {
207
188
  "balance": 1,
208
189
  "trades": 1,
@@ -238,11 +219,6 @@
238
219
  "trades": 1,
239
220
  "orderbook": 1
240
221
  },
241
- "SHRAP": {
242
- "balance": 1,
243
- "trades": 1,
244
- "orderbook": 1
245
- },
246
222
  "SLOR": {
247
223
  "balance": 1,
248
224
  "trades": 1,
@@ -280,14 +256,12 @@
280
256
  "MIX": true,
281
257
  "OPUL": true,
282
258
  "SARA": true,
283
- "SHRAP": true,
284
259
  "SLOR": true,
285
260
  "SWFTC": true,
286
261
  "TACC": true,
287
262
  "TITAN": true
288
263
  },
289
264
  "balance_cur": {
290
- "IONX": true
291
265
  },
292
266
  "total_in_usd": {
293
267
  "SWFTC": true
@@ -301,7 +275,6 @@
301
275
  "GO": true,
302
276
  "HKBITEX-BTC": true,
303
277
  "HKBITEX-ETH": true,
304
- "IONX": true,
305
278
  "JYAI": true,
306
279
  "LST": true,
307
280
  "LUCIC": true,
@@ -309,7 +282,6 @@
309
282
  "MIX": true,
310
283
  "OPUL": true,
311
284
  "SARA": true,
312
- "SHRAP": true,
313
285
  "SLOR": true,
314
286
  "SWFTC": true,
315
287
  "TACC": true,
@@ -328,7 +300,6 @@
328
300
  "GO": [1, 2, 5, 10, 20, 50, 100],
329
301
  "HKBITEX-BTC": [1, 2, 5, 10, 20, 50, 100],
330
302
  "HKBITEX-ETH": [1, 2, 5, 10, 20, 50, 100],
331
- "IONX": [1, 2, 5, 10, 20, 50, 100],
332
303
  "JYAI": [1, 2, 5, 10, 20, 50, 100],
333
304
  "LST": [1, 2, 5, 10, 20, 50, 100],
334
305
  "LUCIC": [1, 2, 5, 10, 20, 50, 100],
@@ -336,7 +307,6 @@
336
307
  "MIX": [2, 5, 10],
337
308
  "OPUL": [1, 2, 5, 10, 20, 50, 100],
338
309
  "SARA": [1, 2, 5, 10, 20, 50, 100],
339
- "SHRAP": [1, 2, 5, 10, 20, 50, 100],
340
310
  "SLOR": [1, 2, 5, 10, 20, 50, 100],
341
311
  "SWFTC": [1, 2, 5, 10, 20, 50, 100],
342
312
  "TACC": [1, 2, 5, 10, 20, 50, 100],
@@ -350,7 +320,6 @@
350
320
  "GO": ["BTC", "ETH"],
351
321
  "HKBITEX-BTC": ["BTC", "ETH"],
352
322
  "HKBITEX-ETH": ["BTC", "ETH"],
353
- "IONX": ["BTC", "ETH"],
354
323
  "JYAI": ["BTC", "ETH"],
355
324
  "LST": ["BTC", "ETH"],
356
325
  "LUCIC": ["BTC", "ETH"],
@@ -358,7 +327,6 @@
358
327
  "MIX": ["BTC", "ETH"],
359
328
  "OPUL": ["BTC", "ETH"],
360
329
  "SARA": ["BTC", "ETH"],
361
- "SHRAP": ["BTC", "ETH"],
362
330
  "SLOR": ["BTC", "ETH"],
363
331
  "SWFTC": ["BTC", "ETH"],
364
332
  "TACC": ["BTC", "ETH"],
@@ -372,7 +340,6 @@
372
340
  "GO": "-4822577824",
373
341
  "HKBITEX-BTC": "-4837808085",
374
342
  "HKBITEX-ETH": "-4837808085",
375
- "IONX": "-1002085059560",
376
343
  "JYAI": "-4787448589",
377
344
  "LST": "-4626789465",
378
345
  "LUCIC": "-4701729001",
@@ -380,7 +347,6 @@
380
347
  "MIX": "-4941930380",
381
348
  "OPUL": "-4581926908",
382
349
  "SARA": "-4660700305",
383
- "SHRAP": "-1001996867582",
384
350
  "SLOR": "-4721907187",
385
351
  "SWFTC": "-1002067948127",
386
352
  "TACC": "-4874959768",
@@ -392,11 +358,6 @@
392
358
  "BVT": 35000
393
359
  }
394
360
  },
395
- "IONX": {
396
- "mexc_1": {
397
- "IONX": 10000000
398
- }
399
- },
400
361
  "SWFTC": {
401
362
  "coinbase_1": {
402
363
  "SWFTC": 5000000,
@@ -413,7 +374,6 @@
413
374
  "GO": "icg",
414
375
  "HKBITEX-BTC": "icg",
415
376
  "HKBITEX-ETH": "icg",
416
- "IONX": "icg",
417
377
  "JYAI": "icg",
418
378
  "LST": "icg",
419
379
  "LUCIC": "icg",
@@ -421,7 +381,6 @@
421
381
  "MIX": "icg",
422
382
  "OPUL": "icg",
423
383
  "SARA": "icg",
424
- "SHRAP": "icg",
425
384
  "SLOR": "icg",
426
385
  "SWFTC": "icg",
427
386
  "TACC": "icg",
@@ -460,10 +419,6 @@
460
419
  "username": "hkbitex-eth@icg.io",
461
420
  "password": "d4QOs7WIZcTt0bV"
462
421
  },
463
- "IONX": {
464
- "username": "ionx@icg.io",
465
- "password": "gW5vZbXQp3BseNH"
466
- },
467
422
  "JYAI": {
468
423
  "username": "jyai@icg.io",
469
424
  "password": "XWAxbFN5I5hitiO"
@@ -492,10 +447,6 @@
492
447
  "username": "sara@icg.io",
493
448
  "password": "5PNgIqLM0msiWNf"
494
449
  },
495
- "SHRAP": {
496
- "username": "shrap@icg.io",
497
- "password": "0C6RlEOsWQ0MK2G"
498
- },
499
450
  "SLOR": {
500
451
  "username": "slor@icg.io",
501
452
  "password": "NXcz0Ydm7Gognjv"
Binary file
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@icgio/clients-config",
3
- "version": "1.0.217",
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.219",
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
+ }
Binary file
@@ -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()