forked from Haehnchen/crypto-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (41 loc) · 1.46 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
50
51
52
'use strict';
let TradeCommand = require('./command/trade.js');
let ServerCommand = require('./command/server.js');
let Backfill = require('./command/backfill.js');
let program = require('commander');
// init
let services = require('./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();
let 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 'Not all options are given'
}
await services.boot();
let 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(function(options) {
let cmd = new ServerCommand(options.instance);
cmd.execute();
});
program.parse(process.argv);