Skip to content

Commit

Permalink
1.10.321
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Dec 8, 2017
1 parent 4a07245 commit 390154a
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 29 deletions.
99 changes: 97 additions & 2 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 errors = require ('./js/base/errors')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.10.320'
const version = '1.10.321'

Exchange.ccxtVersion = version

Expand Down
2 changes: 1 addition & 1 deletion ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace ccxt;

$version = '1.10.320';
$version = '1.10.321';

const CLASSES_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR;

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.320",
"version": "1.10.321",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 90+ exchanges",
"main": "./ccxt.js",
"unpkg": "build/ccxt.browser.js",
Expand Down
95 changes: 95 additions & 0 deletions php/huobipro.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,101 @@ public function fetch_balance ($params = array ()) {
return $this->parse_balance($result);
}

public function fetch_orders ($symbol = null, $since = null, $limit = null, $params = array ()) {
if (!$symbol)
throw new ExchangeError ($this->id . ' fetchOrders() requires a $symbol parameter');
$this->load_markets ();
market = $this->market ($symbol);
if (array_key_exists ('type', $params)) {
status = $params['type'];
} else if (array_key_exists ('status', $params)) {
status = $params['status']
} else {
throw new ExchangeError ($this->id . ' fetchOrders() requires type param or status param for spot market ' . $symbol . '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)')
}
if ((status == 0) || (status == 'open')) {
status = 'submitted,partial-filled';
} else if ((status == 1) || (status == 'closed')) {
status = 'filled,partial-canceled'
} else {
throw new ExchangeError ($this->id . ' fetchOrders() wrong type param or status param for spot market ' . $symbol . '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)');
}
$response = $this->privateGetOrderOrders (array_merge (array (
'symbol' => market['id'],
'states' => status,
)));
return $this->parse_orders($response['data'], market);
}

public function fetch_open_orders ($symbol = null, $since = null, $limit = null, $params = array ()) {
$open = 0; // 0 for unfilled orders, 1 for filled orders
return $this->fetch_orders($symbol, null, null, array_merge (array (
'status' => $open,
), $params));
}

public function parse_order_status ($status) {
if ($status == 'partial-filled') {
return 'partial';
} else if ($status == 'filled') {
return 'closed';
} else if ($status == 'canceled') {
return 'canceled';
} else if ($status == 'submitted') {
return 'open';
}
return $status;
}

public function parse_order ($order, $market = null) {
$side = null;
$type = null;
if (array_key_exists ('type', $order)) {
order_type = explode ('-', $order['type']);
$side = order_type[0];
$type = order_type[1];
status = $this->parse_order_status($order['state']);
}
$symbol = null;
if (!$market) {
if (array_key_exists ('symbol', $order)) {
if (array_key_exists ($order['symbol'], $this->markets_by_id)) {
$marketId = $order['symbol'];
$market = $this->markets_by_id[$marketId];
}
}
}
if ($market)
$symbol = $market['symbol'];
$timestamp = $order['created-at'];
$amount = floatval ($order['amount']);
$filled = floatval ($order['field-amount']);
$remaining = $amount - $filled;
$price = floatval ($order['price']);
$cost = floatval ($order['field-cash-amount']);
$average = 0;
if ($filled)
$average = floatval ($cost / $filled);
$result = array (
'info' => $order,
'id' => $order['id'],
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'symbol' => $symbol,
'type' => $type,
'side' => $side,
'price' => $price,
'average' => $average,
'cost' => $cost,
'amount' => $amount,
'filled' => $filled,
'remaining' => $remaining,
'status' => status,
'fee' => null,
);
return $result;
}

public function create_order ($symbol, $type, $side, $amount, $price = null, $params = array ()) {
$this->load_markets();
$this->load_accounts ();
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.320'
__version__ = '1.10.321'

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

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.320'
__version__ = '1.10.321'

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

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.320'
__version__ = '1.10.321'

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

Expand Down
84 changes: 84 additions & 0 deletions python/ccxt/async/huobipro.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,90 @@ async def fetch_balance(self, params={}):
result[currency] = account
return self.parse_balance(result)

async def fetch_orders(self, symbol=None, since=None, limit=None, params={}):
if not symbol:
raise ExchangeError(self.id + ' fetchOrders() requires a symbol parameter')
self.load_markets()
market = self.market(symbol)
if 'type' in params:
status = params['type']
elif 'status' in params:
status = params['status']
else:
raise ExchangeError(self.id + ' fetchOrders() requires type param or status param for spot market ' + symbol + '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)')
if (status == 0) or (status == 'open'):
status = 'submitted,partial-filled'
elif (status == 1) or (status == 'closed'):
status = 'filled,partial-canceled'
else:
raise ExchangeError(self.id + ' fetchOrders() wrong type param or status param for spot market ' + symbol + '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)')
response = await self.privateGetOrderOrders(self.extend({
'symbol': market['id'],
'states': status,
}))
return self.parse_orders(response['data'], market)

async def fetch_open_orders(self, symbol=None, since=None, limit=None, params={}):
open = 0 # 0 for unfilled orders, 1 for filled orders
return self.fetch_orders(symbol, None, None, self.extend({
'status': open,
}, params))

def parse_order_status(self, status):
if status == 'partial-filled':
return 'partial'
elif status == 'filled':
return 'closed'
elif status == 'canceled':
return 'canceled'
elif status == 'submitted':
return 'open'
return status

def parse_order(self, order, market=None):
side = None
type = None
if 'type' in order:
order_type = order['type'].split('-')
side = order_type[0]
type = order_type[1]
status = self.parse_order_status(order['state'])
symbol = None
if not market:
if 'symbol' in order:
if order['symbol'] in self.markets_by_id:
marketId = order['symbol']
market = self.markets_by_id[marketId]
if market:
symbol = market['symbol']
timestamp = order['created-at']
amount = float(order['amount'])
filled = float(order['field-amount'])
remaining = amount - filled
price = float(order['price'])
cost = float(order['field-cash-amount'])
average = 0
if filled:
average = float(cost / filled)
result = {
'info': order,
'id': order['id'],
'timestamp': timestamp,
'datetime': self.iso8601(timestamp),
'symbol': symbol,
'type': type,
'side': side,
'price': price,
'average': average,
'cost': cost,
'amount': amount,
'filled': filled,
'remaining': remaining,
'status': status,
'fee': None,
}
return result

async def create_order(self, symbol, type, side, amount, price=None, params={}):
await self.load_markets()
await self.load_accounts()
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.320'
__version__ = '1.10.321'

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

Expand Down
42 changes: 22 additions & 20 deletions python/ccxt/huobipro.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,27 +279,27 @@ def fetch_balance(self, params={}):
account['total'] = self.sum(account['free'], account['used'])
result[currency] = account
return self.parse_balance(result)

def fetch_orders(self, symbol=None, since=None, limit=None, params={}):
if not symbol:
raise ExchangeError(self.id + 'fetchOrders requires a symbol parameter')
raise ExchangeError(self.id + ' fetchOrders() requires a symbol parameter')
self.load_markets()
market = self.market(symbol)

if 'type' in params:
status = params['type']
elif 'status' in params:
status = params['status']
else:
raise ExchangeError(self.id + ' fetchOrders() requires type param or status param for spot market ' + symbol + '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)')
if status in [0,'open']:
status='submitted,partial-filled'
elif status in [1,'closed']:
status='filled,partial-canceled'
if (status == 0) or (status == 'open'):
status = 'submitted,partial-filled'
elif (status == 1) or (status == 'closed'):
status = 'filled,partial-canceled'
else:
raise ExchangeError(self.id + ' fetchOrders() wrong type param or status param for spot market ' + symbol + '(0 or "open" for unfilled or partial filled orders, 1 or "closed" for filled orders)')
response = self.privateGetOrderOrders(self.extend({
'symbol': market['id'],'states':status,
'symbol': market['id'],
'states': status,
}))
return self.parse_orders(response['data'], market)

Expand All @@ -316,33 +316,35 @@ def parse_order_status(self, status):
return 'closed'
elif status == 'canceled':
return 'canceled'
else:
if status == 'submitted':
return 'open'
return status
elif status == 'submitted':
return 'open'
return status

def parse_order(self, order, market=None):
side = None
type = None
if 'type' in order:
order_type=order['type'].split('-')
side=order_type[0]
type=order_type[1]
order_type = order['type'].split('-')
side = order_type[0]
type = order_type[1]
status = self.parse_order_status(order['state'])
symbol = None
if not market:
if 'symbol' in order:
if order['symbol'] in self.markets_by_id:
market = self.markets_by_id[order['symbol']]
marketId = order['symbol']
market = self.markets_by_id[marketId]
if market:
symbol = market['symbol']

timestamp = order['created-at']
amount = float(order['amount'])
filled = float(order['field-amount'])
remaining = amount - filled
price = float(order['price'])
cost = float(order['field-cash-amount'])
average = 0 if filled==0 else float(cost/filled)
average = 0
if filled:
average = float(cost / filled)
result = {
'info': order,
'id': order['id'],
Expand All @@ -351,7 +353,7 @@ def parse_order(self, order, market=None):
'symbol': symbol,
'type': type,
'side': side,
'price': order['price'],
'price': price,
'average': average,
'cost': cost,
'amount': amount,
Expand All @@ -361,7 +363,7 @@ def parse_order(self, order, market=None):
'fee': None,
}
return result

def create_order(self, symbol, type, side, amount, price=None, params={}):
self.load_markets()
self.load_accounts()
Expand Down

0 comments on commit 390154a

Please sign in to comment.