From 0b793d42cf0632cfb7152ab06d327f66d732b1bb Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 9 Dec 2019 17:25:47 +0000 Subject: [PATCH] 1.20.57 [ci skip] --- README.md | 6 +- ccxt.js | 2 +- dist/ccxt.browser.js | 88 ++++++++++++++++++++-- doc/README.rst | 6 +- doc/install.rst | 6 +- package-lock.json | 2 +- package.json | 2 +- php/base/Exchange.php | 4 +- php/bytetrade.php | 84 ++++++++++++++++++++- python/README.rst | 6 +- python/ccxt/__init__.py | 2 +- python/ccxt/async_support/__init__.py | 2 +- python/ccxt/async_support/base/exchange.py | 2 +- python/ccxt/async_support/bytetrade.py | 78 ++++++++++++++++++- python/ccxt/base/exchange.py | 2 +- python/ccxt/bytetrade.py | 78 ++++++++++++++++++- wiki/Install.md | 6 +- 17 files changed, 334 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 4a4eb5816622..1453af51564d 100644 --- a/README.md +++ b/README.md @@ -226,13 +226,13 @@ console.log (ccxt.exchanges) // print all available exchanges All-in-one browser bundle (dependencies included), served from a CDN of your choice: -* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.20.56/dist/ccxt.browser.js -* unpkg: https://unpkg.com/ccxt@1.20.56/dist/ccxt.browser.js +* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.20.57/dist/ccxt.browser.js +* unpkg: https://unpkg.com/ccxt@1.20.57/dist/ccxt.browser.js CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers. ```HTML - + ``` Creates a global `ccxt` object: diff --git a/ccxt.js b/ccxt.js index b7fe22912748..181de139d325 100644 --- a/ccxt.js +++ b/ccxt.js @@ -35,7 +35,7 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.20.56' +const version = '1.20.57' Exchange.ccxtVersion = version diff --git a/dist/ccxt.browser.js b/dist/ccxt.browser.js index e26bba27bf01..b6bc6a4673ef 100644 --- a/dist/ccxt.browser.js +++ b/dist/ccxt.browser.js @@ -43,7 +43,7 @@ const Exchange = require ('./js/base/Exchange') //----------------------------------------------------------------------------- // this is updated by vss.js when building -const version = '1.20.56' +const version = '1.20.57' Exchange.ccxtVersion = version @@ -31608,7 +31608,7 @@ module.exports = class bw extends Exchange { // --------------------------------------------------------------------------- const Exchange = require ('./base/Exchange'); -const { ExchangeError, ArgumentsRequired, BadRequest, AuthenticationError, DDoSProtection } = require ('./base/errors'); +const { ExchangeError, ArgumentsRequired, BadRequest, AuthenticationError, DDoSProtection, BadResponse } = require ('./base/errors'); const { TRUNCATE, NO_PADDING, DECIMAL_PLACES } = require ('./base/functions/number'); // --------------------------------------------------------------------------- @@ -31911,7 +31911,43 @@ module.exports = class bytetrade extends Exchange { parseTicker (ticker, market = undefined) { const timestamp = this.safeInteger (ticker, 'timestamp'); - const symbol = this.findSymbol (this.safeString (ticker, 'symbol'), market); + // + // [ + // { + // "symbol":"68719476706", + // "name":"ETH/BTC", + // "base":"2", + // "quote":"32", + // "timestamp":1575905991933, + // "datetime":"2019-12-09T15:39:51.933Z", + // "high":"0", + // "low":"0", + // "open":"0", + // "close":"0", + // "last":"0", + // "change":"0", + // "percentage":"0", + // "baseVolume":"0", + // "quoteVolume":"0" + // } + // ] + // + let symbol = undefined; + const marketId = this.safeString (ticker, 'symbol'); + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + } else { + const baseId = this.safeString (ticker, 'base'); + const quoteId = this.safeString (ticker, 'quote'); + if ((baseId !== undefined) && (quoteId !== undefined)) { + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + symbol = base + '/' + quote; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } return { 'symbol': symbol, 'timestamp': timestamp, @@ -31943,8 +31979,33 @@ module.exports = class bytetrade extends Exchange { 'symbol': market['id'], }; const response = await this.marketGetTickers (this.extend (request, params)); - if (response.length > 0) { - return this.parseTicker (response[0], market); + // + // [ + // { + // "symbol":"68719476706", + // "name":"ETH/BTC", + // "base":"2", + // "quote":"32", + // "timestamp":1575905991933, + // "datetime":"2019-12-09T15:39:51.933Z", + // "high":"0", + // "low":"0", + // "open":"0", + // "close":"0", + // "last":"0", + // "change":"0", + // "percentage":"0", + // "baseVolume":"0", + // "quoteVolume":"0" + // } + // ] + // + if (Array.isArray (response)) { + const ticker = this.safeValue (response, 0); + if (ticker === undefined) { + throw BadResponse (this.id + ' fetchTicker() returned an empty response'); + } + return this.parseTicker (ticker, market); } return this.parseTicker (response, market); } @@ -32052,7 +32113,22 @@ module.exports = class bytetrade extends Exchange { parseOrder (order, market = undefined) { const status = this.safeString (order, 'status'); - const symbol = this.findSymbol (this.safeString (order, 'symbol'), market); + let symbol = undefined; + const marketId = this.safeString (order, 'symbol'); + if (marketId in this.markets_by_id) { + market = this.markets_by_id[marketId]; + } else { + const baseId = this.safeString (order, 'base'); + const quoteId = this.safeString (order, 'quote'); + if ((baseId !== undefined) && (quoteId !== undefined)) { + const base = this.safeCurrencyCode (baseId); + const quote = this.safeCurrencyCode (quoteId); + symbol = base + '/' + quote; + } + } + if ((symbol === undefined) && (market !== undefined)) { + symbol = market['symbol']; + } const timestamp = this.safeInteger (order, 'timestamp'); const datetime = this.safeString (order, 'datetime'); const lastTradeTimestamp = this.safeInteger (order, 'lastTradeTimestamp'); diff --git a/doc/README.rst b/doc/README.rst index d167888bde29..e68b4ddbf9ea 100644 --- a/doc/README.rst +++ b/doc/README.rst @@ -369,14 +369,14 @@ JavaScript (for use with the `` + Creates a global ``ccxt`` object: diff --git a/doc/install.rst b/doc/install.rst index d34f6047cfc7..6377efcf3e20 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -62,14 +62,14 @@ JavaScript (for use with the `` + Creates a global ``ccxt`` object: diff --git a/package-lock.json b/package-lock.json index 4b1343bf51e1..5ee9e03a1c50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ccxt", - "version": "1.20.56", + "version": "1.20.57", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7ce9f8339760..049f6ae96ba9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccxt", - "version": "1.20.56", + "version": "1.20.57", "description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges", "main": "./ccxt.js", "unpkg": "dist/ccxt.browser.js", diff --git a/php/base/Exchange.php b/php/base/Exchange.php index fa68bf33de83..cd0a0367fc8f 100644 --- a/php/base/Exchange.php +++ b/php/base/Exchange.php @@ -35,7 +35,7 @@ use Elliptic\EC; use BN\BN; -$version = '1.20.56'; +$version = '1.20.57'; // rounding mode const TRUNCATE = 0; @@ -54,7 +54,7 @@ class Exchange { - const VERSION = '1.20.56'; + const VERSION = '1.20.57'; public static $eth_units = array ( 'wei' => '1', diff --git a/php/bytetrade.php b/php/bytetrade.php index d1651dd887ee..fea2f4b27e5f 100644 --- a/php/bytetrade.php +++ b/php/bytetrade.php @@ -306,7 +306,43 @@ public function fetch_order_book ($symbol, $limit = null, $params = array ()) { public function parse_ticker ($ticker, $market = null) { $timestamp = $this->safe_integer($ticker, 'timestamp'); - $symbol = $this->find_symbol($this->safe_string($ticker, 'symbol'), $market); + // + // array ( + // { + // "$symbol":"68719476706", + // "name":"ETH/BTC", + // "$base":"2", + // "$quote":"32", + // "$timestamp":1575905991933, + // "datetime":"2019-12-09T15:39:51.933Z", + // "high":"0", + // "low":"0", + // "open":"0", + // "close":"0", + // "last":"0", + // "change":"0", + // "percentage":"0", + // "baseVolume":"0", + // "quoteVolume":"0" + // } + // ) + // + $symbol = null; + $marketId = $this->safe_string($ticker, 'symbol'); + if (is_array($this->markets_by_id) && array_key_exists($marketId, $this->markets_by_id)) { + $market = $this->markets_by_id[$marketId]; + } else { + $baseId = $this->safe_string($ticker, 'base'); + $quoteId = $this->safe_string($ticker, 'quote'); + if (($baseId !== null) && ($quoteId !== null)) { + $base = $this->safe_currency_code($baseId); + $quote = $this->safe_currency_code($quoteId); + $symbol = $base . '/' . $quote; + } + } + if (($symbol === null) && ($market !== null)) { + $symbol = $market['symbol']; + } return array ( 'symbol' => $symbol, 'timestamp' => $timestamp, @@ -338,8 +374,33 @@ public function fetch_ticker ($symbol, $params = array ()) { 'symbol' => $market['id'], ); $response = $this->marketGetTickers (array_merge ($request, $params)); - if (strlen ($response) > 0) { - return $this->parse_ticker($response[0], $market); + // + // array ( + // { + // "$symbol":"68719476706", + // "name":"ETH/BTC", + // "base":"2", + // "quote":"32", + // "timestamp":1575905991933, + // "datetime":"2019-12-09T15:39:51.933Z", + // "high":"0", + // "low":"0", + // "open":"0", + // "close":"0", + // "last":"0", + // "change":"0", + // "percentage":"0", + // "baseVolume":"0", + // "quoteVolume":"0" + // } + // ) + // + if (gettype ($response) === 'array' && count (array_filter (array_keys ($response), 'is_string')) == 0) { + $ticker = $this->safe_value($response, 0); + if ($ticker === null) { + throw BadResponse ($this->id . ' fetchTicker() returned an empty response'); + } + return $this->parse_ticker($ticker, $market); } return $this->parse_ticker($response, $market); } @@ -447,7 +508,22 @@ public function fetch_trades ($symbol, $since = null, $limit = null, $params = a public function parse_order ($order, $market = null) { $status = $this->safe_string($order, 'status'); - $symbol = $this->find_symbol($this->safe_string($order, 'symbol'), $market); + $symbol = null; + $marketId = $this->safe_string($order, 'symbol'); + if (is_array($this->markets_by_id) && array_key_exists($marketId, $this->markets_by_id)) { + $market = $this->markets_by_id[$marketId]; + } else { + $baseId = $this->safe_string($order, 'base'); + $quoteId = $this->safe_string($order, 'quote'); + if (($baseId !== null) && ($quoteId !== null)) { + $base = $this->safe_currency_code($baseId); + $quote = $this->safe_currency_code($quoteId); + $symbol = $base . '/' . $quote; + } + } + if (($symbol === null) && ($market !== null)) { + $symbol = $market['symbol']; + } $timestamp = $this->safe_integer($order, 'timestamp'); $datetime = $this->safe_string($order, 'datetime'); $lastTradeTimestamp = $this->safe_integer($order, 'lastTradeTimestamp'); diff --git a/python/README.rst b/python/README.rst index d7170663e378..93bff8ae9d5d 100644 --- a/python/README.rst +++ b/python/README.rst @@ -369,14 +369,14 @@ JavaScript (for use with the `` + Creates a global ``ccxt`` object: diff --git a/python/ccxt/__init__.py b/python/ccxt/__init__.py index 517219942326..82413a4a4045 100644 --- a/python/ccxt/__init__.py +++ b/python/ccxt/__init__.py @@ -22,7 +22,7 @@ # ---------------------------------------------------------------------------- -__version__ = '1.20.56' +__version__ = '1.20.57' # ---------------------------------------------------------------------------- diff --git a/python/ccxt/async_support/__init__.py b/python/ccxt/async_support/__init__.py index bfa9f122127c..ad2d0afc4173 100644 --- a/python/ccxt/async_support/__init__.py +++ b/python/ccxt/async_support/__init__.py @@ -4,7 +4,7 @@ # ----------------------------------------------------------------------------- -__version__ = '1.20.56' +__version__ = '1.20.57' # ----------------------------------------------------------------------------- diff --git a/python/ccxt/async_support/base/exchange.py b/python/ccxt/async_support/base/exchange.py index cfcefb74fa89..9be012c6e3a7 100644 --- a/python/ccxt/async_support/base/exchange.py +++ b/python/ccxt/async_support/base/exchange.py @@ -2,7 +2,7 @@ # ----------------------------------------------------------------------------- -__version__ = '1.20.56' +__version__ = '1.20.57' # ----------------------------------------------------------------------------- diff --git a/python/ccxt/async_support/bytetrade.py b/python/ccxt/async_support/bytetrade.py index 562eacdc597d..62ad2bdee721 100644 --- a/python/ccxt/async_support/bytetrade.py +++ b/python/ccxt/async_support/bytetrade.py @@ -10,6 +10,7 @@ from ccxt.base.errors import AuthenticationError from ccxt.base.errors import ArgumentsRequired from ccxt.base.errors import BadRequest +from ccxt.base.errors import BadResponse from ccxt.base.errors import DDoSProtection from ccxt.base.decimal_to_precision import TRUNCATE from ccxt.base.decimal_to_precision import DECIMAL_PLACES @@ -300,7 +301,40 @@ async def fetch_order_book(self, symbol, limit=None, params={}): def parse_ticker(self, ticker, market=None): timestamp = self.safe_integer(ticker, 'timestamp') - symbol = self.find_symbol(self.safe_string(ticker, 'symbol'), market) + # + # [ + # { + # "symbol":"68719476706", + # "name":"ETH/BTC", + # "base":"2", + # "quote":"32", + # "timestamp":1575905991933, + # "datetime":"2019-12-09T15:39:51.933Z", + # "high":"0", + # "low":"0", + # "open":"0", + # "close":"0", + # "last":"0", + # "change":"0", + # "percentage":"0", + # "baseVolume":"0", + # "quoteVolume":"0" + # } + # ] + # + symbol = None + marketId = self.safe_string(ticker, 'symbol') + if marketId in self.markets_by_id: + market = self.markets_by_id[marketId] + else: + baseId = self.safe_string(ticker, 'base') + quoteId = self.safe_string(ticker, 'quote') + if (baseId is not None) and (quoteId is not None): + base = self.safe_currency_code(baseId) + quote = self.safe_currency_code(quoteId) + symbol = base + '/' + quote + if (symbol is None) and (market is not None): + symbol = market['symbol'] return { 'symbol': symbol, 'timestamp': timestamp, @@ -331,8 +365,32 @@ async def fetch_ticker(self, symbol, params={}): 'symbol': market['id'], } response = await self.marketGetTickers(self.extend(request, params)) - if len(response) > 0: - return self.parse_ticker(response[0], market) + # + # [ + # { + # "symbol":"68719476706", + # "name":"ETH/BTC", + # "base":"2", + # "quote":"32", + # "timestamp":1575905991933, + # "datetime":"2019-12-09T15:39:51.933Z", + # "high":"0", + # "low":"0", + # "open":"0", + # "close":"0", + # "last":"0", + # "change":"0", + # "percentage":"0", + # "baseVolume":"0", + # "quoteVolume":"0" + # } + # ] + # + if isinstance(response, list): + ticker = self.safe_value(response, 0) + if ticker is None: + raise BadResponse(self.id + ' fetchTicker() returned an empty response') + return self.parse_ticker(ticker, market) return self.parse_ticker(response, market) def parse_tickers(self, rawTickers, symbols=None): @@ -424,7 +482,19 @@ async def fetch_trades(self, symbol, since=None, limit=None, params={}): def parse_order(self, order, market=None): status = self.safe_string(order, 'status') - symbol = self.find_symbol(self.safe_string(order, 'symbol'), market) + symbol = None + marketId = self.safe_string(order, 'symbol') + if marketId in self.markets_by_id: + market = self.markets_by_id[marketId] + else: + baseId = self.safe_string(order, 'base') + quoteId = self.safe_string(order, 'quote') + if (baseId is not None) and (quoteId is not None): + base = self.safe_currency_code(baseId) + quote = self.safe_currency_code(quoteId) + symbol = base + '/' + quote + if (symbol is None) and (market is not None): + symbol = market['symbol'] timestamp = self.safe_integer(order, 'timestamp') datetime = self.safe_string(order, 'datetime') lastTradeTimestamp = self.safe_integer(order, 'lastTradeTimestamp') diff --git a/python/ccxt/base/exchange.py b/python/ccxt/base/exchange.py index e9cea969b92f..9c32d1df2c8b 100644 --- a/python/ccxt/base/exchange.py +++ b/python/ccxt/base/exchange.py @@ -4,7 +4,7 @@ # ----------------------------------------------------------------------------- -__version__ = '1.20.56' +__version__ = '1.20.57' # ----------------------------------------------------------------------------- diff --git a/python/ccxt/bytetrade.py b/python/ccxt/bytetrade.py index 015ca9c6ae09..78a7b727f557 100644 --- a/python/ccxt/bytetrade.py +++ b/python/ccxt/bytetrade.py @@ -10,6 +10,7 @@ from ccxt.base.errors import AuthenticationError from ccxt.base.errors import ArgumentsRequired from ccxt.base.errors import BadRequest +from ccxt.base.errors import BadResponse from ccxt.base.errors import DDoSProtection from ccxt.base.decimal_to_precision import TRUNCATE from ccxt.base.decimal_to_precision import DECIMAL_PLACES @@ -300,7 +301,40 @@ def fetch_order_book(self, symbol, limit=None, params={}): def parse_ticker(self, ticker, market=None): timestamp = self.safe_integer(ticker, 'timestamp') - symbol = self.find_symbol(self.safe_string(ticker, 'symbol'), market) + # + # [ + # { + # "symbol":"68719476706", + # "name":"ETH/BTC", + # "base":"2", + # "quote":"32", + # "timestamp":1575905991933, + # "datetime":"2019-12-09T15:39:51.933Z", + # "high":"0", + # "low":"0", + # "open":"0", + # "close":"0", + # "last":"0", + # "change":"0", + # "percentage":"0", + # "baseVolume":"0", + # "quoteVolume":"0" + # } + # ] + # + symbol = None + marketId = self.safe_string(ticker, 'symbol') + if marketId in self.markets_by_id: + market = self.markets_by_id[marketId] + else: + baseId = self.safe_string(ticker, 'base') + quoteId = self.safe_string(ticker, 'quote') + if (baseId is not None) and (quoteId is not None): + base = self.safe_currency_code(baseId) + quote = self.safe_currency_code(quoteId) + symbol = base + '/' + quote + if (symbol is None) and (market is not None): + symbol = market['symbol'] return { 'symbol': symbol, 'timestamp': timestamp, @@ -331,8 +365,32 @@ def fetch_ticker(self, symbol, params={}): 'symbol': market['id'], } response = self.marketGetTickers(self.extend(request, params)) - if len(response) > 0: - return self.parse_ticker(response[0], market) + # + # [ + # { + # "symbol":"68719476706", + # "name":"ETH/BTC", + # "base":"2", + # "quote":"32", + # "timestamp":1575905991933, + # "datetime":"2019-12-09T15:39:51.933Z", + # "high":"0", + # "low":"0", + # "open":"0", + # "close":"0", + # "last":"0", + # "change":"0", + # "percentage":"0", + # "baseVolume":"0", + # "quoteVolume":"0" + # } + # ] + # + if isinstance(response, list): + ticker = self.safe_value(response, 0) + if ticker is None: + raise BadResponse(self.id + ' fetchTicker() returned an empty response') + return self.parse_ticker(ticker, market) return self.parse_ticker(response, market) def parse_tickers(self, rawTickers, symbols=None): @@ -424,7 +482,19 @@ def fetch_trades(self, symbol, since=None, limit=None, params={}): def parse_order(self, order, market=None): status = self.safe_string(order, 'status') - symbol = self.find_symbol(self.safe_string(order, 'symbol'), market) + symbol = None + marketId = self.safe_string(order, 'symbol') + if marketId in self.markets_by_id: + market = self.markets_by_id[marketId] + else: + baseId = self.safe_string(order, 'base') + quoteId = self.safe_string(order, 'quote') + if (baseId is not None) and (quoteId is not None): + base = self.safe_currency_code(baseId) + quote = self.safe_currency_code(quoteId) + symbol = base + '/' + quote + if (symbol is None) and (market is not None): + symbol = market['symbol'] timestamp = self.safe_integer(order, 'timestamp') datetime = self.safe_string(order, 'datetime') lastTradeTimestamp = self.safe_integer(order, 'lastTradeTimestamp') diff --git a/wiki/Install.md b/wiki/Install.md index 0d5eb8f2ad01..57974e0b7d73 100644 --- a/wiki/Install.md +++ b/wiki/Install.md @@ -58,13 +58,13 @@ If that does not help, please, follow here: https://github.com/nodejs/node-gyp#o All-in-one browser bundle (dependencies included), served from a CDN of your choice: -* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.20.56/dist/ccxt.browser.js -* unpkg: https://unpkg.com/ccxt@1.20.56/dist/ccxt.browser.js +* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.20.57/dist/ccxt.browser.js +* unpkg: https://unpkg.com/ccxt@1.20.57/dist/ccxt.browser.js You can obtain a live-updated version of the bundle by removing the version number from the URL (the `@a.b.c` thing) — however, we do not recommend to do that, as it may break your app eventually. Also, please keep in mind that we are not responsible for the correct operation of those CDN servers. ```HTML - + ``` Creates a global `ccxt` object: