Bug Fixes
This commit is contained in:
1 parent
82bc086e92
commit
b1af6e078c
131 files changed
+8597
-1930
No files matched your search
+90
-16
@@ -3,7 +3,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const Exchange = require ('./base/Exchange');
|
||||
const { InsufficientFunds, ArgumentsRequired, ExchangeError, InvalidOrder, InvalidAddress, AuthenticationError, NotSupported, OrderNotFound } = require ('./base/errors');
|
||||
const { InsufficientFunds, ArgumentsRequired, ExchangeError, InvalidOrder, InvalidAddress, AuthenticationError, NotSupported, OrderNotFound, OnMaintenance, RateLimitExceeded } = require ('./base/errors');
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -152,12 +152,14 @@ module.exports = class coinbasepro extends Exchange {
|
||||
'invalid signature': AuthenticationError,
|
||||
'Invalid Passphrase': AuthenticationError,
|
||||
'Invalid order id': InvalidOrder,
|
||||
'Private rate limit exceeded': RateLimitExceeded,
|
||||
},
|
||||
'broad': {
|
||||
'Order already done': OrderNotFound,
|
||||
'order not found': OrderNotFound,
|
||||
'price too small': InvalidOrder,
|
||||
'price too precise': InvalidOrder,
|
||||
'under maintenance': OnMaintenance,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -295,29 +297,46 @@ module.exports = class coinbasepro extends Exchange {
|
||||
return orderbook;
|
||||
}
|
||||
|
||||
async fetchTicker (symbol, params = {}) {
|
||||
await this.loadMarkets ();
|
||||
const market = this.market (symbol);
|
||||
const request = {
|
||||
'id': market['id'],
|
||||
};
|
||||
const ticker = await this.publicGetProductsIdTicker (this.extend (request, params));
|
||||
parseTicker (ticker, market = undefined) {
|
||||
//
|
||||
// publicGetProductsIdTicker
|
||||
//
|
||||
// {
|
||||
// "trade_id":843439,
|
||||
// "price":"0.997999",
|
||||
// "size":"80.29769",
|
||||
// "time":"2020-01-28T02:13:33.012523Z",
|
||||
// "bid":"0.997094",
|
||||
// "ask":"0.998",
|
||||
// "volume":"1903188.03750000"
|
||||
// }
|
||||
//
|
||||
// publicGetProductsIdStats
|
||||
//
|
||||
// {
|
||||
// "open": "34.19000000",
|
||||
// "high": "95.70000000",
|
||||
// "low": "7.06000000",
|
||||
// "volume": "2.41000000"
|
||||
// }
|
||||
//
|
||||
const timestamp = this.parse8601 (this.safeValue (ticker, 'time'));
|
||||
const bid = this.safeFloat (ticker, 'bid');
|
||||
const ask = this.safeFloat (ticker, 'ask');
|
||||
const last = this.safeFloat (ticker, 'price');
|
||||
const symbol = (market === undefined) ? undefined : market['symbol'];
|
||||
return {
|
||||
'symbol': symbol,
|
||||
'timestamp': timestamp,
|
||||
'datetime': this.iso8601 (timestamp),
|
||||
'high': undefined,
|
||||
'low': undefined,
|
||||
'high': this.safeFloat (ticker, 'high'),
|
||||
'low': this.safeFloat (ticker, 'low'),
|
||||
'bid': bid,
|
||||
'bidVolume': undefined,
|
||||
'ask': ask,
|
||||
'askVolume': undefined,
|
||||
'vwap': undefined,
|
||||
'open': undefined,
|
||||
'open': this.safeFloat (ticker, 'open'),
|
||||
'close': last,
|
||||
'last': last,
|
||||
'previousClose': undefined,
|
||||
@@ -330,14 +349,69 @@ module.exports = class coinbasepro extends Exchange {
|
||||
};
|
||||
}
|
||||
|
||||
async fetchTicker (symbol, params = {}) {
|
||||
await this.loadMarkets ();
|
||||
const market = this.market (symbol);
|
||||
const request = {
|
||||
'id': market['id'],
|
||||
};
|
||||
// publicGetProductsIdTicker or publicGetProductsIdStats
|
||||
const method = this.safeString (this.options, 'fetchTickerMethod', 'publicGetProductsIdTicker');
|
||||
const response = await this[method] (this.extend (request, params));
|
||||
//
|
||||
// publicGetProductsIdTicker
|
||||
//
|
||||
// {
|
||||
// "trade_id":843439,
|
||||
// "price":"0.997999",
|
||||
// "size":"80.29769",
|
||||
// "time":"2020-01-28T02:13:33.012523Z",
|
||||
// "bid":"0.997094",
|
||||
// "ask":"0.998",
|
||||
// "volume":"1903188.03750000"
|
||||
// }
|
||||
//
|
||||
// publicGetProductsIdStats
|
||||
//
|
||||
// {
|
||||
// "open": "34.19000000",
|
||||
// "high": "95.70000000",
|
||||
// "low": "7.06000000",
|
||||
// "volume": "2.41000000"
|
||||
// }
|
||||
//
|
||||
return this.parseTicker (response, market);
|
||||
}
|
||||
|
||||
parseTrade (trade, market = undefined) {
|
||||
//
|
||||
// {
|
||||
// type: 'match',
|
||||
// trade_id: 82047307,
|
||||
// maker_order_id: '0f358725-2134-435e-be11-753912a326e0',
|
||||
// taker_order_id: '252b7002-87a3-425c-ac73-f5b9e23f3caf',
|
||||
// side: 'sell',
|
||||
// size: '0.00513192',
|
||||
// price: '9314.78',
|
||||
// product_id: 'BTC-USD',
|
||||
// sequence: 12038915443,
|
||||
// time: '2020-01-31T20:03:41.158814Z'
|
||||
// }
|
||||
//
|
||||
const timestamp = this.parse8601 (this.safeString2 (trade, 'time', 'created_at'));
|
||||
let symbol = undefined;
|
||||
if (market === undefined) {
|
||||
const marketId = this.safeString (trade, 'product_id');
|
||||
market = this.safeValue (this.markets_by_id, marketId);
|
||||
const marketId = this.safeString (trade, 'product_id');
|
||||
if (marketId !== undefined) {
|
||||
if (marketId in this.markets_by_id) {
|
||||
market = this.markets_by_id[marketId];
|
||||
} else {
|
||||
const [ baseId, quoteId ] = marketId.split ('-');
|
||||
const base = this.safeCurrencyCode (baseId);
|
||||
const quote = this.safeCurrencyCode (quoteId);
|
||||
symbol = base + '/' + quote;
|
||||
}
|
||||
}
|
||||
if (market) {
|
||||
if ((symbol === undefined) && (market !== undefined)) {
|
||||
symbol = market['symbol'];
|
||||
}
|
||||
let feeRate = undefined;
|
||||
@@ -861,7 +935,7 @@ module.exports = class coinbasepro extends Exchange {
|
||||
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
||||
if ((code === 400) || (code === 404)) {
|
||||
if (body[0] === '{') {
|
||||
const message = response['message'];
|
||||
const message = this.safeString (response, 'message');
|
||||
const feedback = this.id + ' ' + message;
|
||||
this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback);
|
||||
this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback);
|
||||
|
||||
Reference in new issue
Block a user