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

Commit

Permalink
catch another upstream error, fix timeout add order flow
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Sep 7, 2018
1 parent 667fad4 commit 9cfb331
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions exchange/wrappers/kraken.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Trader = function(config) {
});
this.pair = this.market.book;

this.interval = 1900;
this.interval = 3100;

this.kraken = new Kraken(
this.key,
Expand Down Expand Up @@ -51,7 +51,8 @@ const recoverableErrors = [
// the API call succeeded.
const unknownResultErrors = [
'Response code 502',
'Response code 504'
'Response code 504',
'Response code 522',
]

const includes = (str, list) => {
Expand Down Expand Up @@ -122,7 +123,7 @@ Trader.prototype.handleResponse = function(funcName, callback, nonMutating, payl
});

if(!order) {
console.log('broken add order, appears not created:', {payload, orders});
console.log('broken add order, appears not created:', {payload, orders: JSON.stringify(orders)});
return this.addOrder(tradeType, amount, price, callback);
}

Expand Down Expand Up @@ -283,12 +284,13 @@ Trader.prototype.addOrder = function(tradeType, amount, price, callback) {
let txid;

if(data.catched) {
// handled timeout, but order was created
txid = data.id;
} else if(_.isString(data)) {
// handled timeout, order was NOT created
txid = data;
} else {
if(!data.result) {
console.log('weird data:', data);
}

// normal flow
txid = data.result.txid[0];
}

Expand Down

0 comments on commit 9cfb331

Please sign in to comment.