forked from askmike/gekko
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gekko-backtest.js
62 lines (43 loc) · 1.67 KB
/
gekko-backtest.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
55
56
57
58
59
60
61
62
/*
Gekko is a Bitcoin trading bot for Mt. Gox written
in node, it features multiple trading methods using
technical analysis.
Disclaimer:
USE AT YOUR OWN RISK!
The author of this project is NOT responsible for any damage or loss caused
by this software. There can be bugs and the bot may not perform as expected
or specified. Please consider testing it first with paper trading /
backtesting on historical data. Also look at the code to see what how
it's working.
*/
// helpers
var moment = require('moment');
var _ = require('lodash');
var util = require('./util');
var log = require('./log');
var async = require('async');
var Manager = require('./portfolioManager');
var config = util.getConfig();
// overwrite the watcher in case of normal setup
if(config.normal.enabled)
config.watch = config.normal;
// set backtesting reminder
config.backtest.enabled = true;
// set updated config
util.setConfig(config);
if(config.talib)
var Consultant = require('./methods/talib');
else
var Consultant = require('./methods/' + config.tradingMethod.toLowerCase().split(' ').join('-'));
log.info('I\'m gonna make you rich, Bud Fox.');
log.info('Let me show you some ' + config.tradingMethod + '.\n\n');
log.info('Preparing backtester to test strategy against historical data.');
// implement a trading method to create a consultant.
var consultant = new Consultant();
var Logger = require('./logger');
var logger = new Logger(_.extend(config.profitCalculator, config.watch));
consultant.on('advice', logger.inform);
if(config.profitCalculator.enabled)
consultant.on('advice', logger.trackProfits);
consultant.on('finish', logger.finish);
consultant.emit('prepare');