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

Commit

Permalink
Kraken: Rate limiting for backfilling and warning instead of error on…
Browse files Browse the repository at this point in the history
… API retries (#217)

* Kraken: Rate limiting for backfilling and warning instead of error on API retries

* Typo
  • Loading branch information
crubb authored and DeviaVir committed Jun 4, 2017
1 parent c3125b1 commit dad44bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions commands/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ module.exports = function container (get, set, clear) {
console.log('\ndownload complete!\n')
process.exit(0)
}
setImmediate(getNext)
if (exchange.backfillRateLimit) {
setTimeout(getNext, exchange.backfillRateLimit)
} else {
setImmediate(getNext)
}
})
})
}
Expand Down Expand Up @@ -201,4 +205,4 @@ module.exports = function container (get, set, clear) {
})
})
}
}
}
4 changes: 3 additions & 1 deletion extensions/kraken/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function container(get, set, clear) {
var timeout = 2500
}

console.error(('\nKraken API error - unable to call ' + method + ' (' + error + '), retrying in ' + timeout / 1000 + 's').red)
console.warn(('\nKraken API warning - unable to call ' + method + ' (' + error + '), retrying in ' + timeout / 1000 + 's').yellow)
setTimeout(function () {
exchange[method].apply(exchange, args)
}, timeout)
Expand All @@ -50,6 +50,8 @@ module.exports = function container(get, set, clear) {
name: 'kraken',
historyScan: 'forward',
makerFee: 0.16,
// The limit for the public API is not documented, 1750 ms between getTrades in backfilling seems to do the trick to omit warning messages.
backfillRateLimit: 1750,

getProducts: function () {
return require('./products.json')
Expand Down

0 comments on commit dad44bc

Please sign in to comment.