Skip to content

Commit

Permalink
1.10.883
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Jan 28, 2018
1 parent 94be556 commit 4897088
Show file tree
Hide file tree
Showing 14 changed files with 272 additions and 65 deletions.
89 changes: 70 additions & 19 deletions build/ccxt.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.10.882'
const version = '1.10.883'

Exchange.ccxtVersion = version

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.10.882",
"version": "1.10.883",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 90+ exchanges",
"main": "./ccxt.js",
"unpkg": "build/ccxt.browser.js",
Expand Down
2 changes: 1 addition & 1 deletion php/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace ccxt;

$version = '1.10.882';
$version = '1.10.883';

abstract class Exchange {

Expand Down
68 changes: 58 additions & 10 deletions php/hitbtc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function describe () {
'version' => '1',
'has' => array (
'CORS' => false,
'fetchTrades' => true,
'fetchOrder' => true,
'fetchOpenOrders' => true,
'fetchClosedOrders' => true,
Expand Down Expand Up @@ -478,16 +479,15 @@ public function describe () {
}

public function common_currency_code ($currency) {
if ($currency === 'XBT')
return 'BTC';
if ($currency === 'DRK')
return 'DASH';
if ($currency === 'CAT')
return 'BitClave';
if ($currency === 'USD')
return 'USDT';
if ($currency === 'EMGO')
return 'MGO';
$currencies = array (
'XBT' => 'BTC',
'DRK' => 'DASH',
'CAT' => 'BitClave',
'USD' => 'USDT',
'EMGO' => 'MGO',
);
if (is_array ($currencies) && array_key_exists ($currency, $currencies))
return $currencies[$currency];
return $currency;
}

Expand Down Expand Up @@ -624,6 +624,12 @@ public function fetch_ticker ($symbol, $params = array ()) {
}

public function parse_trade ($trade, $market = null) {
if (gettype ($trade) === 'array' && count (array_filter (array_keys ($trade), 'is_string')) == 0)
return $this->parse_public_trade ($trade, $market);
return $this->parse_order_trade ($trade, $market);
}

public function parse_public_trade ($trade, $market = null) {
$symbol = null;
if ($market)
$symbol = $market['symbol'];
Expand All @@ -640,6 +646,37 @@ public function parse_trade ($trade, $market = null) {
);
}

public function parse_order_trade ($trade, $market = null) {
$symbol = null;
if ($market)
$symbol = $market['symbol'];
$amount = floatval ($trade['execQuantity']);
if ($market)
$amount *= $market['lot'];
$price = floatval ($trade['execPrice']);
$cost = $price * $amount;
$fee = array (
'cost' => floatval ($trade['fee']),
'currency' => null,
'rate' => null,
);
$timestamp = $trade['timestamp'];
return array (
'info' => $trade,
'id' => $trade['tradeId'],
'order' => $trade['clientOrderId'],
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'symbol' => $symbol,
'type' => null,
'side' => $trade['side'],
'price' => $price,
'amount' => $amount,
'cost' => $cost,
'fee' => $fee,
);
}

public function fetch_trades ($symbol, $since = null, $limit = null, $params = array ()) {
$this->load_markets();
$market = $this->market ($symbol);
Expand Down Expand Up @@ -807,6 +844,17 @@ public function fetch_closed_orders ($symbol = null, $since = null, $limit = nul
return $this->parse_orders($response['orders'], $market, $since, $limit);
}

public function fetch_order_trades ($id, $symbol = null, $since = null, $limit = null, $params = array ()) {
$this->load_markets();
$market = null;
if ($symbol !== null)
$market = $this->market ($symbol);
$response = $this->tradingGetTradesByOrder (array_merge (array (
'clientOrderId' => $id,
), $params));
return $this->parse_trades($response['trades'], $market, $since, $limit);
}

public function withdraw ($code, $amount, $address, $tag = null, $params = array ()) {
$this->load_markets();
$currency = $this->currency ($code);
Expand Down
12 changes: 9 additions & 3 deletions php/hitbtc2.php
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,21 @@ public function fetch_my_trades ($symbol = null, $since = null, $limit = null, $
return $this->parse_trades($response, $market, $since, $limit);
}

public function fetch_order_trades ($id, $symbol = null, $params = array ()) {
public function fetch_order_trades ($id, $symbol = null, $since = null, $limit = null, $params = array ()) {
// The $id needed here is the exchange's $id, and not the clientOrderID, which is
// the $id that is stored in the unified api order $id. In order the get the exchange's $id,
// you need to grab it from order['info']['id']
$this->load_markets();
$trades = $this->privateGetHistoryOrderIdTrades (array_merge (array (
$market = null;
if ($symbol !== null)
$market = $this->market ($symbol);
$response = $this->privateGetHistoryOrderIdTrades (array_merge (array (
'id' => $id,
), $params));
return $this->parse_trades($trades);
$numOrders = is_array ($response) ? count ($response) : 0;
if ($numOrders > 0)
return $this->parse_trades($response, $market, $since, $limit);
throw new OrderNotFound ($this->id . ' order ' . $id . ' not found, ' . $this->id . '.fetchOrderTrades() requires an exchange-specific order $id, you need to grab it from order["info"]["$id"]');
}

public function create_deposit_address ($code, $params = array ()) {
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# ----------------------------------------------------------------------------

__version__ = '1.10.882'
__version__ = '1.10.883'

# ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.882'
__version__ = '1.10.883'

# -----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.882'
__version__ = '1.10.883'

# -----------------------------------------------------------------------------

Expand Down
65 changes: 55 additions & 10 deletions python/ccxt/async/hitbtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def describe(self):
'version': '1',
'has': {
'CORS': False,
'fetchTrades': True,
'fetchOrder': True,
'fetchOpenOrders': True,
'fetchClosedOrders': True,
Expand Down Expand Up @@ -482,16 +483,15 @@ def describe(self):
})

def common_currency_code(self, currency):
if currency == 'XBT':
return 'BTC'
if currency == 'DRK':
return 'DASH'
if currency == 'CAT':
return 'BitClave'
if currency == 'USD':
return 'USDT'
if currency == 'EMGO':
return 'MGO'
currencies = {
'XBT': 'BTC',
'DRK': 'DASH',
'CAT': 'BitClave',
'USD': 'USDT',
'EMGO': 'MGO',
}
if currency in currencies:
return currencies[currency]
return currency

async def fetch_markets(self):
Expand Down Expand Up @@ -618,6 +618,11 @@ async def fetch_ticker(self, symbol, params={}):
return self.parse_ticker(ticker, market)

def parse_trade(self, trade, market=None):
if isinstance(trade, list):
return self.parse_public_trade(trade, market)
return self.parse_order_trade(trade, market)

def parse_public_trade(self, trade, market=None):
symbol = None
if market:
symbol = market['symbol']
Expand All @@ -633,6 +638,36 @@ def parse_trade(self, trade, market=None):
'amount': float(trade[2]),
}

def parse_order_trade(self, trade, market=None):
symbol = None
if market:
symbol = market['symbol']
amount = float(trade['execQuantity'])
if market:
amount *= market['lot']
price = float(trade['execPrice'])
cost = price * amount
fee = {
'cost': float(trade['fee']),
'currency': None,
'rate': None,
}
timestamp = trade['timestamp']
return {
'info': trade,
'id': trade['tradeId'],
'order': trade['clientOrderId'],
'timestamp': timestamp,
'datetime': self.iso8601(timestamp),
'symbol': symbol,
'type': None,
'side': trade['side'],
'price': price,
'amount': amount,
'cost': cost,
'fee': fee,
}

async def fetch_trades(self, symbol, since=None, limit=None, params={}):
await self.load_markets()
market = self.market(symbol)
Expand Down Expand Up @@ -785,6 +820,16 @@ async def fetch_closed_orders(self, symbol=None, since=None, limit=None, params=
response = await self.tradingGetOrdersRecent(self.extend(request, params))
return self.parse_orders(response['orders'], market, since, limit)

async def fetch_order_trades(self, id, symbol=None, since=None, limit=None, params={}):
await self.load_markets()
market = None
if symbol is not None:
market = self.market(symbol)
response = await self.tradingGetTradesByOrder(self.extend({
'clientOrderId': id,
}, params))
return self.parse_trades(response['trades'], market, since, limit)

async def withdraw(self, code, amount, address, tag=None, params={}):
await self.load_markets()
currency = self.currency(code)
Expand Down
12 changes: 9 additions & 3 deletions python/ccxt/async/hitbtc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,21 @@ async def fetch_my_trades(self, symbol=None, since=None, limit=None, params={}):
response = await self.privateGetHistoryTrades(self.extend(request, params))
return self.parse_trades(response, market, since, limit)

async def fetch_order_trades(self, id, symbol=None, params={}):
async def fetch_order_trades(self, id, symbol=None, since=None, limit=None, params={}):
# The id needed here is the exchange's id, and not the clientOrderID, which is
# the id that is stored in the unified api order id. In order the get the exchange's id,
# you need to grab it from order['info']['id']
await self.load_markets()
trades = await self.privateGetHistoryOrderIdTrades(self.extend({
market = None
if symbol is not None:
market = self.market(symbol)
response = await self.privateGetHistoryOrderIdTrades(self.extend({
'id': id,
}, params))
return self.parse_trades(trades)
numOrders = len(response)
if numOrders > 0:
return self.parse_trades(response, market, since, limit)
raise OrderNotFound(self.id + ' order ' + id + ' not found, ' + self.id + '.fetchOrderTrades() requires an exchange-specific order id, you need to grab it from order["info"]["id"]')

async def create_deposit_address(self, code, params={}):
await self.load_markets()
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.882'
__version__ = '1.10.883'

# -----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 4897088

Please sign in to comment.