Skip to content

Commit

Permalink
kraken fetchOrderBook parseBidAsk timestamp fix #6749
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Apr 8, 2020
1 parent 3d49dfa commit 30fe23f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion js/kraken.js
Expand Up @@ -441,6 +441,13 @@ module.exports = class kraken extends Exchange {
};
}

parseBidAsk (bidask, priceKey = 0, amountKey = 1) {
const price = this.safeFloat (bidask, priceKey);
const amount = this.safeFloat (bidask, amountKey);
const timestamp = this.safeInteger (bidask, 2);
return [ price, amount, timestamp ];
}

async fetchOrderBook (symbol, limit = undefined, params = {}) {
await this.loadMarkets ();
const market = this.market (symbol);
Expand All @@ -454,7 +461,27 @@ module.exports = class kraken extends Exchange {
request['count'] = limit; // 100
}
const response = await this.publicGetDepth (this.extend (request, params));
const orderbook = response['result'][market['id']];
//
// {
// "error":[],
// "result":{
// "XETHXXBT":{
// "asks":[
// ["0.023480","4.000",1586321307],
// ["0.023490","50.095",1586321306],
// ["0.023500","28.535",1586321302],
// ],
// "bids":[
// ["0.023470","59.580",1586321307],
// ["0.023460","20.000",1586321301],
// ["0.023440","67.832",1586321306],
// ]
// }
// }
// }
//
const result = this.safeValue (response, 'result', {});
const orderbook = this.safeValue (result, market['id']);
return this.parseOrderBook (orderbook);
}

Expand Down

0 comments on commit 30fe23f

Please sign in to comment.