A wrapper for kraken-api which enables simultaneous requests to the kraken.com API via multiple API keypairs. Simultaneous requests using a single keypair can result in "Invalid nonce" errors.
npm install kraken-pool
const KrakenPool = require('kraken-pool');
The Kraken Pool API is effectively a superset of that of the kraken-api library.
The constructor accepts an array of key/secret arrays, and an options object:
var client = new KrakenPool([
[key0, secret0],
[key1, secret1],
[key2, secret2],
...
], options);
Note that kraken.com allows the creation of up to 16 keypairs.
The constructor also accepts the same arguments as that of the kraken-api library, for compatibility:
var client = new KrakenPool(key, secret, options);
For those who cannot decide whether to pass a single keypair or an array of keypairs:
var client = new KrakenPool([key, secret], options);
Once instantiated, a Kraken Pool object may be interacted with via the api
method. See the kraken-api documentation for details.
If all keypairs are in use when the api
method is called, the request is queued until one becomes available.
To access the number of available keypairs:
client.getAvailableClientCount();
Kraken Pool keeps track of the user's theoretical progress towards the API rate limit. See the Kraken API documentation for details regarding this limit and the call counter system.
The default countdown time is 3000 milliseconds. Tier 3 and 4 users should include a ratelimitCooldown
option of 2000 and 1000, respectively, when instantiating the Kraken Pool.
To access the counter value:
client.getRateLimitCounter();
The documentation states the following:
Ledger/trade history calls increase the counter by 2.
It is not clear whether this refers to the "Ledgers" route, the "QueryLedgers" route, or both. Therefore, the call counter takes a conservative approach and adds +2 for both routes, in addition to the "TradeHistory" route.