Skip to content

Commit

Permalink
1.14.111
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed May 31, 2018
1 parent e738f3f commit a9b5523
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 56 deletions.
39 changes: 24 additions & 15 deletions build/ccxt.browser.js

Large diffs are not rendered by default.

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

const version = '1.14.110'
const version = '1.14.111'

Exchange.ccxtVersion = version

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.14.110",
"version": "1.14.111",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 100+ exchanges",
"main": "./ccxt.js",
"unpkg": "build/ccxt.browser.js",
Expand Down
2 changes: 1 addition & 1 deletion php/Exchange.php
Expand Up @@ -30,7 +30,7 @@

namespace ccxt;

$version = '1.14.110';
$version = '1.14.111';

// rounding mode
const TRUNCATE = 0;
Expand Down
33 changes: 21 additions & 12 deletions php/gatecoin.php
Expand Up @@ -199,6 +199,9 @@ public function describe () {
),
'exceptions' => array (
'1005' => '\\ccxt\\InsufficientFunds',
'1008' => '\\ccxt\\OrderNotFound',
'1057' => '\\ccxt\\InvalidOrder',
'1044' => '\\ccxt\\OrderNotFound', // already canceled
),
));
}
Expand Down Expand Up @@ -448,19 +451,27 @@ public function create_order ($symbol, $type, $side, $amount, $price = null, $pa
throw new AuthenticationError ($this->id . ' two-factor authentication requires a missing ValidationCode parameter');
}
$response = $this->privatePostTradeOrders (array_merge ($order, $params));
// At this point $response.responseStatus.message has been verified
// in handleErrors() to be == 'OK', so we assume the $order has
// indeed been opened.
return array (
'info' => $response,
'id' => $response['clOrderId'],
'status' => 'open',
'id' => $this->safe_string($response, 'clOrderId'), // $response['clOrderId'],
);
}

public function cancel_order ($id, $symbol = null, $params = array ()) {
$this->load_markets();
return $this->privateDeleteTradeOrdersOrderID (array ( 'OrderID' => $id ));
$response = $this->privateDeleteTradeOrdersOrderID (array ( 'OrderID' => $id ));
return $response;
}

public function parse_order_status ($status) {
$statuses = array (
'1' => 'open', // New
'2' => 'open', // Filling
'4' => 'canceled',
'6' => 'closed',
);
if (is_array ($statuses) && array_key_exists ($status, $statuses))
Expand Down Expand Up @@ -596,15 +607,6 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
return array ( 'url' => $url, 'method' => $method, 'body' => $body, 'headers' => $headers );
}

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 ('responseStatus', $response))
if (is_array ($response['responseStatus']) && array_key_exists ('message', $response['responseStatus']))
if ($response['responseStatus']['message'] === 'OK')
return $response;
throw new ExchangeError ($this->id . ' ' . $this->json ($response));
}

public function withdraw ($code, $amount, $address, $tag = null, $params = array ()) {
$this->check_address($address);
$this->load_markets();
Expand Down Expand Up @@ -680,17 +682,24 @@ public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
return; // fallback to default error handler
if (strlen ($body) < 2)
return; // fallback to default error handler
if (mb_strpos ($body, 'You are not authorized') !== false) {
throw new PermissionDenied ($body);
}
if ($body[0] === '{') {
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('responseStatus', $response)) {
$errorCode = $this->safe_string($response['responseStatus'], 'errorCode');
$message = $this->safe_string($response['responseStatus'], 'message');
$feedback = $this->id . ' ' . $body;
if ($errorCode !== null) {
$feedback = $this->id . ' ' . $body;
$exceptions = $this->exceptions;
if (is_array ($exceptions) && array_key_exists ($errorCode, $exceptions)) {
throw new $exceptions[$errorCode] ($feedback);
}
throw new ExchangeError ($feedback);
// Sometimes there isn't 'errorCode' but 'message' is present and is not 'OK'
} else if ($message !== null && $message !== 'OK') {
throw new ExchangeError ($feedback);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Expand Up @@ -22,7 +22,7 @@

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

__version__ = '1.14.110'
__version__ = '1.14.111'

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

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/__init__.py
Expand Up @@ -4,7 +4,7 @@

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

__version__ = '1.14.110'
__version__ = '1.14.111'

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

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/base/exchange.py
Expand Up @@ -2,7 +2,7 @@

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

__version__ = '1.14.110'
__version__ = '1.14.111'

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

Expand Down
34 changes: 23 additions & 11 deletions python/ccxt/async/gatecoin.py
Expand Up @@ -16,8 +16,11 @@
import json
from ccxt.base.errors import ExchangeError
from ccxt.base.errors import AuthenticationError
from ccxt.base.errors import PermissionDenied
from ccxt.base.errors import InsufficientFunds
from ccxt.base.errors import InvalidAddress
from ccxt.base.errors import InvalidOrder
from ccxt.base.errors import OrderNotFound


class gatecoin (Exchange):
Expand Down Expand Up @@ -212,6 +215,9 @@ def describe(self):
},
'exceptions': {
'1005': InsufficientFunds,
'1008': OrderNotFound,
'1057': InvalidOrder,
'1044': OrderNotFound, # already canceled
},
})

Expand Down Expand Up @@ -441,17 +447,25 @@ async def create_order(self, symbol, type, side, amount, price=None, params={}):
else:
raise AuthenticationError(self.id + ' two-factor authentication requires a missing ValidationCode parameter')
response = await self.privatePostTradeOrders(self.extend(order, params))
# At self point response.responseStatus.message has been verified
# in handleErrors() to be == 'OK', so we assume the order has
# indeed been opened.
return {
'info': response,
'id': response['clOrderId'],
'status': 'open',
'id': self.safe_string(response, 'clOrderId'), # response['clOrderId'],
}

async def cancel_order(self, id, symbol=None, params={}):
await self.load_markets()
return await self.privateDeleteTradeOrdersOrderID({'OrderID': id})
response = await self.privateDeleteTradeOrdersOrderID({'OrderID': id})
return response

def parse_order_status(self, status):
statuses = {
'1': 'open', # New
'2': 'open', # Filling
'4': 'canceled',
'6': 'closed',
}
if status in statuses:
Expand Down Expand Up @@ -571,14 +585,6 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
body = self.json(self.extend({'nonce': nonce}, params))
return {'url': url, 'method': method, 'body': body, 'headers': headers}

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 'responseStatus' in response:
if 'message' in response['responseStatus']:
if response['responseStatus']['message'] == 'OK':
return response
raise ExchangeError(self.id + ' ' + self.json(response))

async def withdraw(self, code, amount, address, tag=None, params={}):
self.check_address(address)
await self.load_markets()
Expand Down Expand Up @@ -650,13 +656,19 @@ def handle_errors(self, code, reason, url, method, headers, body):
return # fallback to default error handler
if len(body) < 2:
return # fallback to default error handler
if body.find('You are not authorized') >= 0:
raise PermissionDenied(body)
if body[0] == '{':
response = json.loads(body)
if 'responseStatus' in response:
errorCode = self.safe_string(response['responseStatus'], 'errorCode')
message = self.safe_string(response['responseStatus'], 'message')
feedback = self.id + ' ' + body
if errorCode is not None:
feedback = self.id + ' ' + body
exceptions = self.exceptions
if errorCode in exceptions:
raise exceptions[errorCode](feedback)
raise ExchangeError(feedback)
# Sometimes there isn't 'errorCode' but 'message' is present and is not 'OK'
elif message is not None and message != 'OK':
raise ExchangeError(feedback)
2 changes: 1 addition & 1 deletion python/ccxt/base/exchange.py
Expand Up @@ -4,7 +4,7 @@

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

__version__ = '1.14.110'
__version__ = '1.14.111'

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

Expand Down
34 changes: 23 additions & 11 deletions python/ccxt/gatecoin.py
Expand Up @@ -16,8 +16,11 @@
import json
from ccxt.base.errors import ExchangeError
from ccxt.base.errors import AuthenticationError
from ccxt.base.errors import PermissionDenied
from ccxt.base.errors import InsufficientFunds
from ccxt.base.errors import InvalidAddress
from ccxt.base.errors import InvalidOrder
from ccxt.base.errors import OrderNotFound


class gatecoin (Exchange):
Expand Down Expand Up @@ -212,6 +215,9 @@ def describe(self):
},
'exceptions': {
'1005': InsufficientFunds,
'1008': OrderNotFound,
'1057': InvalidOrder,
'1044': OrderNotFound, # already canceled
},
})

Expand Down Expand Up @@ -441,17 +447,25 @@ def create_order(self, symbol, type, side, amount, price=None, params={}):
else:
raise AuthenticationError(self.id + ' two-factor authentication requires a missing ValidationCode parameter')
response = self.privatePostTradeOrders(self.extend(order, params))
# At self point response.responseStatus.message has been verified
# in handleErrors() to be == 'OK', so we assume the order has
# indeed been opened.
return {
'info': response,
'id': response['clOrderId'],
'status': 'open',
'id': self.safe_string(response, 'clOrderId'), # response['clOrderId'],
}

def cancel_order(self, id, symbol=None, params={}):
self.load_markets()
return self.privateDeleteTradeOrdersOrderID({'OrderID': id})
response = self.privateDeleteTradeOrdersOrderID({'OrderID': id})
return response

def parse_order_status(self, status):
statuses = {
'1': 'open', # New
'2': 'open', # Filling
'4': 'canceled',
'6': 'closed',
}
if status in statuses:
Expand Down Expand Up @@ -571,14 +585,6 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
body = self.json(self.extend({'nonce': nonce}, params))
return {'url': url, 'method': method, 'body': body, 'headers': headers}

def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
response = self.fetch2(path, api, method, params, headers, body)
if 'responseStatus' in response:
if 'message' in response['responseStatus']:
if response['responseStatus']['message'] == 'OK':
return response
raise ExchangeError(self.id + ' ' + self.json(response))

def withdraw(self, code, amount, address, tag=None, params={}):
self.check_address(address)
self.load_markets()
Expand Down Expand Up @@ -650,13 +656,19 @@ def handle_errors(self, code, reason, url, method, headers, body):
return # fallback to default error handler
if len(body) < 2:
return # fallback to default error handler
if body.find('You are not authorized') >= 0:
raise PermissionDenied(body)
if body[0] == '{':
response = json.loads(body)
if 'responseStatus' in response:
errorCode = self.safe_string(response['responseStatus'], 'errorCode')
message = self.safe_string(response['responseStatus'], 'message')
feedback = self.id + ' ' + body
if errorCode is not None:
feedback = self.id + ' ' + body
exceptions = self.exceptions
if errorCode in exceptions:
raise exceptions[errorCode](feedback)
raise ExchangeError(feedback)
# Sometimes there isn't 'errorCode' but 'message' is present and is not 'OK'
elif message is not None and message != 'OK':
raise ExchangeError(feedback)

0 comments on commit a9b5523

Please sign in to comment.