Skip to content

Commit

Permalink
1.10.882
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Jan 28, 2018
1 parent e03dd59 commit f653db0
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 94 deletions.
58 changes: 31 additions & 27 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.881'
const version = '1.10.882'

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

abstract class Exchange {

Expand Down
49 changes: 27 additions & 22 deletions php/wex.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public function describe () {
),
),
),
'exceptions' => array (
'messages' => array (
'bad status' => '\\ccxt\\OrderNotFound',
'Requests too often' => '\\ccxt\\DDoSProtection',
'not available' => '\\ccxt\\DDoSProtection',
'external service unavailable' => '\\ccxt\\DDoSProtection',
),
),
));
}

Expand Down Expand Up @@ -102,37 +110,34 @@ public function parse_ticker ($ticker, $market = null) {
}

public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
if ($code == 200) {
if ($body[0] != '{') {
// $response is not JSON
throw new ExchangeError ($this->id . ' returned a non-JSON reply => ' . $body);
if ($code === 200) {
if ($body[0] !== '{') {
// $response is not JSON -> resort to default $error handler
return;
}
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('success', $response)) {
if (!$response['success']) {
$error = $this->safe_value($response, 'error');
$error = $this->safe_string($response, 'error');
if (!$error) {
throw new ExchangeError ($this->id . ' returned a malformed $error => ' . $body);
} else if ($error == 'bad status') {
throw new OrderNotFound ($this->id . ' ' . $error);
} else if (mb_strpos ($error, 'It is not enough') !== false) {
throw new InsufficientFunds ($this->id . ' ' . $error);
} else if ($error == 'Requests too often') {
throw new DDoSProtection ($this->id . ' ' . $error);
} else if ($error == 'not available') {
throw new DDoSProtection ($this->id . ' ' . $error);
} else if ($error == 'external service unavailable') {
throw new DDoSProtection ($this->id . ' ' . $error);
// that's what fetchOpenOrders return if no open orders (fix for #489)
} else if ($error != 'no orders') {
throw new ExchangeError ($this->id . ' ' . $error);
}
if ($error === 'no orders') {
// returned by fetchOpenOrders if no open orders (fix for #489) -> not an $error
return;
}
$feedback = $this->id . ' ' . $this->json ($response);
$messages = $this->exceptions.messages;
if (is_array ($messages) && array_key_exists ($error, $messages)) {
throw new $messages[$error] ($feedback);
}
if (mb_strpos ($error, 'It is not enough') !== false) {
throw new InsufficientFunds ($feedback);
} else {
throw new ExchangeError ($feedback);
}
}
}
}
}

public function request ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
return $this->fetch2 ($path, $api, $method, $params, $headers, $body);
}
}
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.881'
__version__ = '1.10.882'

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

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.881'
__version__ = '1.10.882'

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

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.881'
__version__ = '1.10.882'

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

Expand Down
41 changes: 22 additions & 19 deletions python/ccxt/async/wex.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ def describe(self):
},
},
},
'exceptions': {
'messages': {
'bad status': OrderNotFound,
'Requests too often': DDoSProtection,
'not available': DDoSProtection,
'external service unavailable': DDoSProtection,
},
},
})

def parse_ticker(self, ticker, market=None):
Expand Down Expand Up @@ -108,27 +116,22 @@ def parse_ticker(self, ticker, market=None):
def handle_errors(self, code, reason, url, method, headers, body):
if code == 200:
if body[0] != '{':
# response is not JSON
raise ExchangeError(self.id + ' returned a non-JSON reply: ' + body)
# response is not JSON -> resort to default error handler
return
response = json.loads(body)
if 'success' in response:
if not response['success']:
error = self.safe_value(response, 'error')
error = self.safe_string(response, 'error')
if not error:
raise ExchangeError(self.id + ' returned a malformed error: ' + body)
elif error == 'bad status':
raise OrderNotFound(self.id + ' ' + error)
elif error.find('It is not enough') >= 0:
raise InsufficientFunds(self.id + ' ' + error)
elif error == 'Requests too often':
raise DDoSProtection(self.id + ' ' + error)
elif error == 'not available':
raise DDoSProtection(self.id + ' ' + error)
elif error == 'external service unavailable':
raise DDoSProtection(self.id + ' ' + error)
# that's what fetchOpenOrders return if no open orders(fix for #489)
elif error != 'no orders':
raise ExchangeError(self.id + ' ' + error)

def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
return self.fetch2(path, api, method, params, headers, body)
if error == 'no orders':
# returned by fetchOpenOrders if no open orders(fix for #489) -> not an error
return
feedback = self.id + ' ' + self.json(response)
messages = self.exceptions.messages
if error in messages:
raise messages[error](feedback)
if error.find('It is not enough') >= 0:
raise InsufficientFunds(feedback)
else:
raise ExchangeError(feedback)
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.881'
__version__ = '1.10.882'

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

Expand Down
41 changes: 22 additions & 19 deletions python/ccxt/wex.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ def describe(self):
},
},
},
'exceptions': {
'messages': {
'bad status': OrderNotFound,
'Requests too often': DDoSProtection,
'not available': DDoSProtection,
'external service unavailable': DDoSProtection,
},
},
})

def parse_ticker(self, ticker, market=None):
Expand Down Expand Up @@ -108,27 +116,22 @@ def parse_ticker(self, ticker, market=None):
def handle_errors(self, code, reason, url, method, headers, body):
if code == 200:
if body[0] != '{':
# response is not JSON
raise ExchangeError(self.id + ' returned a non-JSON reply: ' + body)
# response is not JSON -> resort to default error handler
return
response = json.loads(body)
if 'success' in response:
if not response['success']:
error = self.safe_value(response, 'error')
error = self.safe_string(response, 'error')
if not error:
raise ExchangeError(self.id + ' returned a malformed error: ' + body)
elif error == 'bad status':
raise OrderNotFound(self.id + ' ' + error)
elif error.find('It is not enough') >= 0:
raise InsufficientFunds(self.id + ' ' + error)
elif error == 'Requests too often':
raise DDoSProtection(self.id + ' ' + error)
elif error == 'not available':
raise DDoSProtection(self.id + ' ' + error)
elif error == 'external service unavailable':
raise DDoSProtection(self.id + ' ' + error)
# that's what fetchOpenOrders return if no open orders(fix for #489)
elif error != 'no orders':
raise ExchangeError(self.id + ' ' + error)

def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
return self.fetch2(path, api, method, params, headers, body)
if error == 'no orders':
# returned by fetchOpenOrders if no open orders(fix for #489) -> not an error
return
feedback = self.id + ' ' + self.json(response)
messages = self.exceptions.messages
if error in messages:
raise messages[error](feedback)
if error.find('It is not enough') >= 0:
raise InsufficientFunds(feedback)
else:
raise ExchangeError(feedback)

0 comments on commit f653db0

Please sign in to comment.