forked from askmike/gekko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adviceLogger.js
35 lines (29 loc) · 945 Bytes
/
adviceLogger.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
var log = require('../core/log');
var moment = require('moment');
var _ = require('lodash');
var util = require('../core/util.js');
var config = util.getConfig();
var adviceLoggerConfig = config.adviceLogger;
var Actor = function() {
this.price = 'N/A';
this.marketTime = {format: function() {return 'N/A'}};
_.bindAll(this);
}
Actor.prototype.processCandle = function(candle, done) {
this.price = candle.close;
this.marketTime = candle.start;
done();
};
Actor.prototype.processAdvice = function(advice) {
if (adviceLoggerConfig.muteSoft && advice.recommendation == 'soft') return;
console.log()
log.info('We have new trading advice!');
log.info('\t Position:', advice.recommendation);
log.info('\t Market price:', this.price);
log.info('\t Based on market time:', this.marketTime.format('YYYY-MM-DD HH:mm:ss'));
console.log()
};
Actor.prototype.finalize = function(advice) {
// todo
};
module.exports = Actor;