Skip to content

Commit

Permalink
bitmex added options[fetchTickerQuotes] fix #2928
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed May 24, 2018
1 parent 643b40c commit 86a10bd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions js/bitmex.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ module.exports = class bitmex extends Exchange {
'Invalid API Key.': AuthenticationError,
'Access Denied': PermissionDenied,
},
'options': {
'fetchTickerQuotes': true,
},
});
}

Expand Down Expand Up @@ -306,9 +309,15 @@ module.exports = class bitmex extends Exchange {
'count': 1,
'reverse': true,
}, params);
let quotes = await this.publicGetQuoteBucketed (request);
let quotesLength = quotes.length;
let quote = quotes[quotesLength - 1];
let bid = undefined;
let ask = undefined;
if (this.options['fetchTickerQuotes']) {
let quotes = await this.publicGetQuoteBucketed (request);
let quotesLength = quotes.length;
let quote = quotes[quotesLength - 1];
bid = this.safeFloat (quote, 'bidPrice');
ask = this.safeFloat (quote, 'askPrice');
}
let tickers = await this.publicGetTradeBucketed (request);
let ticker = tickers[0];
let timestamp = this.milliseconds ();
Expand All @@ -321,9 +330,9 @@ module.exports = class bitmex extends Exchange {
'datetime': this.iso8601 (timestamp),
'high': this.safeFloat (ticker, 'high'),
'low': this.safeFloat (ticker, 'low'),
'bid': this.safeFloat (quote, 'bidPrice'),
'bid': bid,
'bidVolume': undefined,
'ask': this.safeFloat (quote, 'askPrice'),
'ask': ask,
'askVolume': undefined,
'vwap': this.safeFloat (ticker, 'vwap'),
'open': open,
Expand Down

0 comments on commit 86a10bd

Please sign in to comment.