Skip to content

Commit

Permalink
1.10.1068
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Feb 9, 2018
1 parent 686a51b commit d2b2d31
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 158 deletions.
89 changes: 48 additions & 41 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.1067'
const version = '1.10.1068'

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.1067",
"version": "1.10.1068",
"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.1067';
$version = '1.10.1068';

abstract class Exchange {

Expand Down
24 changes: 15 additions & 9 deletions php/bibox.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,23 @@ public function fetch_deposit_address ($code, $params = array ()) {
public function withdraw ($code, $amount, $address, $tag = null, $params = array ()) {
$this->load_markets();
$currency = $this->currency ($code);
$request = array (
'cmd' => 'transfer/transferOut',
'body' => array_merge (array (
'coin_symbol' => $currency,
'amount' => $amount,
'addr' => $address,
), $params),
if ($this->password === null)
if (!(is_array ($params) && array_key_exists ('trade_pwd', $params)))
throw new ExchangeError ($this->id . ' withdraw() requires $this->password set on the exchange instance or a trade_pwd parameter');
if (!(is_array ($params) && array_key_exists ('totp_code', $params)))
throw new ExchangeError ($this->id . ' withdraw() requires a totp_code parameter for 2FA authentication');
$body = array (
'trade_pwd' => $this->password,
'coin_symbol' => $currency['id'],
'amount' => $amount,
'addr' => $address,
);
if ($tag !== null)
$request['body']['address_remark'] = $tag;
$response = $this->privatePostTransfer ($request);
$body['address_remark'] = $tag;
$response = $this->privatePostTransfer (array (
'cmd' => 'transfer/transferOut',
'body' => array_merge ($body, $params),
));
return array (
'info' => $response,
'id' => null,
Expand Down
59 changes: 30 additions & 29 deletions php/poloniex.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public function fetch_order ($id, $symbol = null, $params = array ()) {
if ($orders[$i]['id'] === $id)
return $orders[$i];
}
throw new OrderNotCached ($this->id . ' order $id ' . (string) $id . ' not found in cache');
throw new OrderNotCached ($this->id . ' order $id ' . (string) $id . ' is not in "open" state and not found in cache');
}

public function filter_orders_by_status ($orders, $status) {
Expand Down Expand Up @@ -682,15 +682,25 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
$response = $this->privatePostCancelOrder (array_merge (array (
'orderNumber' => $id,
), $params));
if (is_array ($this->orders) && array_key_exists ($id, $this->orders))
$this->orders[$id]['status'] = 'canceled';
} catch (Exception $e) {
if ($this->last_http_response) {
if (mb_strpos ($this->last_http_response, 'Invalid order') !== false)
throw new OrderNotFound ($this->id . ' cancelOrder() error => ' . $this->last_http_response);
if ($e instanceof CancelPending) {
// A request to cancel the order has been sent already.
// If we then attempt to cancel the order the second time
// before the first request is processed the exchange will
// throw a CancelPending exception. Poloniex won't show the
// order in the list of active (open) orders and the cached
// order will be marked as 'closed' (see #1801 for details).
// To avoid that we proactively mark the order as 'canceled'
// here. If for some reason the order does not get canceled
// and still appears in the active list then the order cache
// will eventually get back in sync on a call to `fetchOrder`.
if (is_array ($this->orders) && array_key_exists ($id, $this->orders))
$this->orders[$id]['status'] = 'canceled';
}
throw $e;
}
if (is_array ($this->orders) && array_key_exists ($id, $this->orders))
$this->orders[$id]['status'] = 'canceled';
return $response;
}

Expand Down Expand Up @@ -783,31 +793,22 @@ public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
if ($body[0] === '{') {
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('error', $response)) {
$error = $this->id . ' ' . $body;
if ($response['error'] === 'Invalid order number, or you are not the person who placed the order.') {
throw new OrderNotFound ($error);
} else if (mb_strpos ($response['error'], 'Total must be at least') !== false) {
throw new InvalidOrder ($error);
} else if (mb_strpos ($response['error'], 'Not enough') !== false) {
throw new InsufficientFunds ($error);
} else if (mb_strpos ($response['error'], 'Nonce must be greater') !== false) {
throw new ExchangeNotAvailable ($error);
} else if (mb_strpos ($response['error'], 'You have already called cancelOrder or moveOrder on this order.') !== false) {
throw new CancelPending ($error);
$error = $response['error'];
$feedback = $this->id . ' ' . $this->json ($response);
if ($error === 'Invalid order number, or you are not the person who placed the order.') {
throw new OrderNotFound ($feedback);
} else if (mb_strpos ($error, 'Total must be at least') !== false) {
throw new InvalidOrder ($feedback);
} else if (mb_strpos ($error, 'Not enough') !== false) {
throw new InsufficientFunds ($feedback);
} else if (mb_strpos ($error, 'Nonce must be greater') !== false) {
throw new ExchangeNotAvailable ($feedback);
} else if (mb_strpos ($error, 'You have already called cancelOrder or moveOrder on this order.') !== false) {
throw new CancelPending ($feedback);
} else {
throw new ExchangeError ($this->id . ' => unknown $error => ' . $this->json ($response));
}
}
}
}

public function request ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$response = $this->fetch2 ($path, $api, $method, $params, $headers, $body);
if (is_array ($response) && array_key_exists ('error', $response)) {
$error = $this->id . ' ' . $this->json ($response);
$failed = mb_strpos ($response['error'], 'Not enough') !== false;
if ($failed)
throw new InsufficientFunds ($error);
throw new ExchangeError ($error);
}
return $response;
}
}
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.1067'
__version__ = '1.10.1068'

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

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.1067'
__version__ = '1.10.1068'

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

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.1067'
__version__ = '1.10.1068'

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

Expand Down
24 changes: 15 additions & 9 deletions python/ccxt/async/bibox.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,23 @@ async def fetch_deposit_address(self, code, params={}):
async def withdraw(self, code, amount, address, tag=None, params={}):
await self.load_markets()
currency = self.currency(code)
request = {
'cmd': 'transfer/transferOut',
'body': self.extend({
'coin_symbol': currency,
'amount': amount,
'addr': address,
}, params),
if self.password is None:
if not('trade_pwd' in list(params.keys())):
raise ExchangeError(self.id + ' withdraw() requires self.password set on the exchange instance or a trade_pwd parameter')
if not('totp_code' in list(params.keys())):
raise ExchangeError(self.id + ' withdraw() requires a totp_code parameter for 2FA authentication')
body = {
'trade_pwd': self.password,
'coin_symbol': currency['id'],
'amount': amount,
'addr': address,
}
if tag is not None:
request['body']['address_remark'] = tag
response = await self.privatePostTransfer(request)
body['address_remark'] = tag
response = await self.privatePostTransfer({
'cmd': 'transfer/transferOut',
'body': self.extend(body, params),
})
return {
'info': response,
'id': None,
Expand Down
57 changes: 30 additions & 27 deletions python/ccxt/async/poloniex.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ async def fetch_order(self, id, symbol=None, params={}):
for i in range(0, len(orders)):
if orders[i]['id'] == id:
return orders[i]
raise OrderNotCached(self.id + ' order id ' + str(id) + ' not found in cache')
raise OrderNotCached(self.id + ' order id ' + str(id) + ' is not in "open" state and not found in cache')

def filter_orders_by_status(self, orders, status):
result = []
Expand Down Expand Up @@ -634,13 +634,23 @@ async def cancel_order(self, id, symbol=None, params={}):
response = await self.privatePostCancelOrder(self.extend({
'orderNumber': id,
}, params))
if id in self.orders:
self.orders[id]['status'] = 'canceled'
except Exception as e:
if self.last_http_response:
if self.last_http_response.find('Invalid order') >= 0:
raise OrderNotFound(self.id + ' cancelOrder() error: ' + self.last_http_response)
if isinstance(e, CancelPending):
# A request to cancel the order has been sent already.
# If we then attempt to cancel the order the second time
# before the first request is processed the exchange will
# raise a CancelPending exception. Poloniex won't show the
# order in the list of active(open) orders and the cached
# order will be marked as 'closed'(see #1801 for details).
# To avoid that we proactively mark the order as 'canceled'
# here. If for some reason the order does not get canceled
# and still appears in the active list then the order cache
# will eventually get back in sync on a call to `fetchOrder`.
if id in self.orders:
self.orders[id]['status'] = 'canceled'
raise e
if id in self.orders:
self.orders[id]['status'] = 'canceled'
return response

async def fetch_order_status(self, id, symbol=None):
Expand Down Expand Up @@ -724,24 +734,17 @@ def handle_errors(self, code, reason, url, method, headers, body):
if body[0] == '{':
response = json.loads(body)
if 'error' in response:
error = self.id + ' ' + body
if response['error'] == 'Invalid order number, or you are not the person who placed the order.':
raise OrderNotFound(error)
elif response['error'].find('Total must be at least') >= 0:
raise InvalidOrder(error)
elif response['error'].find('Not enough') >= 0:
raise InsufficientFunds(error)
elif response['error'].find('Nonce must be greater') >= 0:
raise ExchangeNotAvailable(error)
elif response['error'].find('You have already called cancelOrder or moveOrder on self order.') >= 0:
raise CancelPending(error)

async def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
response = await self.fetch2(path, api, method, params, headers, body)
if 'error' in response:
error = self.id + ' ' + self.json(response)
failed = response['error'].find('Not enough') >= 0
if failed:
raise InsufficientFunds(error)
raise ExchangeError(error)
return response
error = response['error']
feedback = self.id + ' ' + self.json(response)
if error == 'Invalid order number, or you are not the person who placed the order.':
raise OrderNotFound(feedback)
elif error.find('Total must be at least') >= 0:
raise InvalidOrder(feedback)
elif error.find('Not enough') >= 0:
raise InsufficientFunds(feedback)
elif error.find('Nonce must be greater') >= 0:
raise ExchangeNotAvailable(feedback)
elif error.find('You have already called cancelOrder or moveOrder on self order.') >= 0:
raise CancelPending(feedback)
else:
raise ExchangeError(self.id + ': unknown error: ' + self.json(response))
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.1067'
__version__ = '1.10.1068'

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

Expand Down
24 changes: 15 additions & 9 deletions python/ccxt/bibox.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,23 @@ def fetch_deposit_address(self, code, params={}):
def withdraw(self, code, amount, address, tag=None, params={}):
self.load_markets()
currency = self.currency(code)
request = {
'cmd': 'transfer/transferOut',
'body': self.extend({
'coin_symbol': currency,
'amount': amount,
'addr': address,
}, params),
if self.password is None:
if not('trade_pwd' in list(params.keys())):
raise ExchangeError(self.id + ' withdraw() requires self.password set on the exchange instance or a trade_pwd parameter')
if not('totp_code' in list(params.keys())):
raise ExchangeError(self.id + ' withdraw() requires a totp_code parameter for 2FA authentication')
body = {
'trade_pwd': self.password,
'coin_symbol': currency['id'],
'amount': amount,
'addr': address,
}
if tag is not None:
request['body']['address_remark'] = tag
response = self.privatePostTransfer(request)
body['address_remark'] = tag
response = self.privatePostTransfer({
'cmd': 'transfer/transferOut',
'body': self.extend(body, params),
})
return {
'info': response,
'id': None,
Expand Down
Loading

0 comments on commit d2b2d31

Please sign in to comment.