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

Commit

Permalink
Feature/backtest tweaks (#2667)
Browse files Browse the repository at this point in the history
* on no batches return empty set

* make sure we never pass Infinity as rate

* update bfx markets

* [GB] add polo outbid calculations

* update sqlite dep to 4.0.4

* on import catch kraken no trades

* only start measuring performance and portfolio after warmup is completed

* rewire relays to first relay warmup
  • Loading branch information
askmike committed Dec 2, 2018
1 parent f633e7b commit 0ec34c6
Show file tree
Hide file tree
Showing 10 changed files with 1,146 additions and 619 deletions.
9 changes: 5 additions & 4 deletions core/tools/dateRangeScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ var scan = function(done) {
iterator.to -= BATCH_SIZE * 60;
},
() => {

if(!_.size(batches))
util.die('Not enough data to work with (please manually set a valid `backtest.daterange`)..', true);
if(batches.length === 0) {
return done(null, [], reader);
}

// batches is now a list like
// [ {from: unix, to: unix } ]

var ranges = [ batches.shift() ];

_.each(batches, batch => {
Expand All @@ -112,6 +112,7 @@ var scan = function(done) {
// we have been counting chronologically reversed
// (backwards, from now into the past), flip definitions
ranges = ranges.reverse();

_.map(ranges, r => {
return {
from: r.to,
Expand Down
19 changes: 13 additions & 6 deletions exchange/orders/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ class StickyOrder extends BaseOrder {
this.initialLimit = params.initialLimit;

if(side === 'buy') {
if(params.limit)
if(params.limit) {
this.limit = this.roundPrice(params.limit);
else
} else {
this.noLimit = true;
this.limit = Infinity;
}
} else {
if(params.limit)
if(params.limit) {
this.limit = this.roundPrice(params.limit);
else
} else {
this.noLimit = true;
this.limit = -Infinity;
}
}

this.status = states.SUBMITTED;
Expand All @@ -76,6 +80,7 @@ class StickyOrder extends BaseOrder {
} else {
this.api.getTicker((err, ticker) => {
if(this.handleError(err)) {
console.log(new Date, 'error get ticker');
return;
}

Expand All @@ -98,7 +103,7 @@ class StickyOrder extends BaseOrder {

if(this.side === 'buy') {

if(ticker.bid >= this.limit) {
if(!this.noLimit && ticker.bid >= this.limit) {
return r(this.limit);
}

Expand All @@ -116,7 +121,7 @@ class StickyOrder extends BaseOrder {

} else if(this.side === 'sell') {

if(ticker.ask <= this.limit) {
if(!this.noLimit && ticker.ask <= this.limit) {
return r(this.limit);
}

Expand Down Expand Up @@ -283,6 +288,7 @@ class StickyOrder extends BaseOrder {

this.api.getTicker((err, ticker) => {
if(this.handleError(err)) {
console.log(new Date, 'getTicker error');
return;
}

Expand Down Expand Up @@ -499,6 +505,7 @@ class StickyOrder extends BaseOrder {

this.api.cancelOrder(this.id, (err, filled, data) => {
if(this.handleError(err)) {
console.log(new Date, 'error cancel');
return;
}

Expand Down
Loading

0 comments on commit 0ec34c6

Please sign in to comment.