-
Notifications
You must be signed in to change notification settings - Fork 3
/
gcg.js
54 lines (44 loc) · 1.69 KB
/
gcg.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
53
54
/**
* Main script of the project 'gekko config generator'.
*/
// import packages
const program = require("commander");
const tomlToJson = require("./lib/toml-to-json");
const configGenerator = require("./lib/config-generator");
const Logger = require("./lib/logger");
// constant variables
const pathToToml = "config/strategies";
const pathToConfigDir = "backtest-config";
// default arguments
let path = "./";
let exchange = "binance";
let currency = "USDT";
let asset = "BTC";
let logLevel = 3;
// parse command line arguments
program
.version("0.3.0")
.option("-p, --path <value>", "path to gekko")
.option("-e, --exchange <value>", "specify the exchange")
.option("-c, --currency <value>", "specify the currency")
.option("-a, --asset <value>", "specify the asset")
.option(
"-l, --loglevel <value>",
"set the log level, info/all(1), warning(2), error(3), nothing(4)"
)
.parse(process.argv);
if (typeof program.path !== "undefined") path = program.path;
if (typeof program.exchange !== "undefined") exchange = program.exchange;
if (typeof program.currency !== "undefined") currency = program.currency;
if (typeof program.asset !== "undefined") asset = program.asset;
if (typeof program.loglevel !== "undefined") logLevel = program.loglevel;
if (path.charAt(path.length - 1) !== "/") path += "/";
const options = `{"exchange": "${exchange}", "currency": "${currency}", "asset": "${asset}"}`;
// initialize logger
const log = new Logger(logLevel);
log.welcome();
// main function
tomlToJson(`${path}${pathToToml}`, log).forEach(json => {
configGenerator(json, options, `${path}${pathToConfigDir}`, log);
});
log.success(`successfully created config files in '${path}${pathToConfigDir}'`);