diff --git a/build/ccxt.php b/build/ccxt.php index 3d1c3bc47d98..426517e77b83 100644 --- a/build/ccxt.php +++ b/build/ccxt.php @@ -14785,15 +14785,18 @@ public function fetch_ticker ($symbol, $params = array ()) { ); } - public function parse_trade ($trade, $market) { - $timestamp = $this->parse8601 (['time']); + public function parse_trade ($trade, $market = null) { + $timestamp = $this->parse8601 ($trade['time']); $side = ($trade['side'] == 'buy') ? 'sell' : 'buy'; + $symbol = null; + if ($market) + $symbol = $market['symbol']; return array ( 'id' => (string) $trade['trade_id'], 'info' => $trade, 'timestamp' => $timestamp, 'datetime' => $this->iso8601 ($timestamp), - 'symbol' => $market['symbol'], + 'symbol' => $symbol, 'type' => null, 'side' => $side, 'price' => floatval ($trade['price']), @@ -14803,9 +14806,10 @@ public function parse_trade ($trade, $market) { public function fetch_trades ($market, $params = array ()) { $this->load_markets (); - return $this->publicGetProductsIdTrades (array_merge (array ( + $response = $this->publicGetProductsIdTrades (array_merge (array ( 'id' => $this->market_id ($market), // fixes issue #2 ), $params)); + return $this->parse_trades ($response, $market); } public function parse_ohlcv ($ohlcv, $market = null, $timeframe = '1m', $since = null, $limit = null) { diff --git a/ccxt.js b/ccxt.js index dc40bd608bf6..a836d184d276 100644 --- a/ccxt.js +++ b/ccxt.js @@ -14415,10 +14415,11 @@ var gdax = { }; }, - async fetchTrades (market, params = {}) { + async fetchTrades (symbol, params = {}) { await this.loadMarkets (); + let market = this.market (symbol); let response = await this.publicGetProductsIdTrades (this.extend ({ - 'id': this.marketId (market), // fixes issue #2 + 'id': market['id'], // fixes issue #2 }, params)); return this.parseTrades (response, market); }, diff --git a/ccxt/async/exchanges.py b/ccxt/async/exchanges.py index 419dab265526..afa7352f472e 100644 --- a/ccxt/async/exchanges.py +++ b/ccxt/async/exchanges.py @@ -12665,15 +12665,18 @@ async def fetch_ticker(self, symbol, params={}): 'info': ticker, } - def parse_trade(self, trade, market): - timestamp = self.parse8601(['time']) + def parse_trade(self, trade, market=None): + timestamp = self.parse8601(trade['time']) side = 'sell' if (trade['side'] == 'buy') else 'buy' + symbol = None + if market: + symbol = market['symbol'] return { 'id': str(trade['trade_id']), 'info': trade, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), - 'symbol': market['symbol'], + 'symbol': symbol, 'type': None, 'side': side, 'price': float(trade['price']), @@ -12682,9 +12685,10 @@ def parse_trade(self, trade, market): async def fetch_trades(self, market, params={}): await self.load_markets() - return await self.publicGetProductsIdTrades(self.extend({ + response = await self.publicGetProductsIdTrades(self.extend({ 'id': self.market_id(market), # fixes issue #2 }, params)) + return self.parse_trades(response, market) def parse_ohlcv(self, ohlcv, market=None, timeframe='1m', since=None, limit=None): return [ diff --git a/ccxt/exchanges.py b/ccxt/exchanges.py index cda14aedc4d5..b6ba0ae7f56c 100644 --- a/ccxt/exchanges.py +++ b/ccxt/exchanges.py @@ -12760,15 +12760,18 @@ def fetch_ticker(self, symbol, params={}): 'info': ticker, } - def parse_trade(self, trade, market): - timestamp = self.parse8601(['time']) + def parse_trade(self, trade, market=None): + timestamp = self.parse8601(trade['time']) side = 'sell' if (trade['side'] == 'buy') else 'buy' + symbol = None + if market: + symbol = market['symbol'] return { 'id': str(trade['trade_id']), 'info': trade, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), - 'symbol': market['symbol'], + 'symbol': symbol, 'type': None, 'side': side, 'price': float(trade['price']), @@ -12777,9 +12780,10 @@ def parse_trade(self, trade, market): def fetch_trades(self, market, params={}): self.load_markets() - return self.publicGetProductsIdTrades(self.extend({ + response = self.publicGetProductsIdTrades(self.extend({ 'id': self.market_id(market), # fixes issue #2 }, params)) + return self.parse_trades(response, market) def parse_ohlcv(self, ohlcv, market=None, timeframe='1m', since=None, limit=None): return [