Skip to content

Commit

Permalink
+ minor py fix ccxt#417
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 29, 2017
1 parent 7ea2ef3 commit e72d51d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
12 changes: 8 additions & 4 deletions build/ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
12 changes: 8 additions & 4 deletions ccxt/async/exchanges.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions ccxt/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand All @@ -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 [
Expand Down

0 comments on commit e72d51d

Please sign in to comment.