forked from Haehnchen/crypto-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (40 loc) · 1.42 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
47
48
49
const program = require('commander');
const TradeCommand = require('./src/command/trade.js');
const ServerCommand = require('./src/command/server.js');
const Backfill = require('./src/command/backfill.js');
// init
const services = require('./src/modules/services');
program
.command('trade')
.description('start crypto trading bot')
.option('-i, --instance <file>', 'Instance to start', 'instance.json')
.action(async options => {
await services.boot(__dirname);
const cmd = new TradeCommand(options.instance);
cmd.execute();
});
program
.command('backfill')
.description('process historical data collection')
.option('-e, --exchange <exchange>')
.option('-s, --symbol <symbol>')
.option('-p, --period <period>', '1m 5m, 15m, 1h', '15m')
.option('-d, --date <date>', 'days in past to collect start', '7')
.action(async options => {
if (!options.exchange || !options.symbol || !options.period || !options.date) {
throw new Error('Not all options are given');
}
await services.boot(__dirname);
const cmd = new Backfill();
await cmd.execute(options.exchange, options.symbol, options.period, options.date);
process.exit();
});
program
.command('server')
.description('')
.option('-i, --instance <file>', 'Instance to start', 'instance.json')
.action(options => {
const cmd = new ServerCommand(options.instance);
cmd.execute();
});
program.parse(process.argv);