Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
temp fix simultaneous advice error
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyan committed Jul 24, 2018
1 parent 0d4c31f commit 4b5d09f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions strategies/DEBUG_toggle-advice.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var settings = {
wait: 0,
each: 6
each: 2
};

// -------

var _ = require('lodash');
var log = require('../core/log.js');
var moment = require('moment');
var lastAdvice = moment();

var i = 0;

Expand All @@ -22,14 +24,19 @@ var method = {
if(settings.wait > i)
return;

log.info('iteration:', i);

if(i % settings.each === 0) {
log.debug('trigger SHORT');
this.advice('short');
} else if(i % settings.each === settings.each / 2) {
log.debug('trigger LONG');
this.advice('long');
log.info('iteration:', i, 'candle time:', candle.start.utc().format("YYYY-MM-DD HH:mm:ss"));

if (moment().subtract(3, 's').isAfter(lastAdvice)) {
lastAdvice = moment();
if(i % settings.each === 0) {
log.debug('trigger SHORT');
this.advice('short');
} else if(i % settings.each === settings.each / 2) {
log.debug('trigger LONG');
this.advice('long');
}
} else {
log.debug('Skipping trigger');
}

// if(i % 2 === 0)
Expand All @@ -42,4 +49,4 @@ var method = {
}
};

module.exports = method;
module.exports = method;

0 comments on commit 4b5d09f

Please sign in to comment.