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

Fix Backtester #1661

Merged
merged 1 commit into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions commands/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = function (program, conf) {
var target_time, start_time
var mode = exchange.historyScan
var last_batch_id, last_batch_opts
var offset = exchange.offset
var markers, trades
if (!mode) {
console.error('cannot backfill ' + selector.normalized + ': exchange does not offer historical data')
Expand Down Expand Up @@ -74,6 +75,9 @@ module.exports = function (program, conf) {
if (marker.to) opts.from = marker.to + 1
else opts.from = exchange.getCursor(start_time)
}
if (offset) {
opts.offset = offset
}
last_batch_opts = opts
exchange.getTrades(opts, function (err, results) {
trades = results
Expand Down
11 changes: 9 additions & 2 deletions extensions/exchanges/poloniex/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = function container (conf) {
historyScan: 'backward',
makerFee: 0.15,
takerFee: 0.25,
offset: 43200,

getProducts: function () {
return require('./products.json')
Expand All @@ -59,11 +60,11 @@ module.exports = function container (conf) {
}
if (args.start && !args.end) {
// add 12 hours
args.end = args.start + 43200
args.end = args.start + opts.offset
}
else if (args.end && !args.start) {
// subtract 12 hours
args.start = args.end - 43200
args.start = args.end - opts.offset
}

client._public('returnTradeHistory', args, function (err, body) {
Expand All @@ -76,6 +77,12 @@ module.exports = function container (conf) {
console.error(body)
return retry('getTrades', func_args)
}

if (body.length >= 50000) {
func_args[0].offset = opts.offset / 2;
return retry('getTrades', func_args)
}

var trades = body.map(function (trade) {
return {
trade_id: trade.tradeID,
Expand Down