Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ccxt-dev/ccxt
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Jan 15, 2018
2 parents 0af6fbd + c993007 commit cdda5bd
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 71 deletions.
33 changes: 16 additions & 17 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.716'
const version = '1.10.718'

Exchange.ccxtVersion = version

Expand Down
6 changes: 4 additions & 2 deletions .eslintrc → js/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
'use strict';

module.exports = {
"env": {
"node": true,
},
Expand Down Expand Up @@ -36,4 +38,4 @@
{"blankLine": "always", "prev":"*", "next": "cjs-export" },
],
}
}
};
42 changes: 42 additions & 0 deletions js/base/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

module.exports = {
"env": {
"node": true,
"es6": true,
"browser": true,
},
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "script",
},
"rules": {
"semi": "off",
"no-unused-vars": ["off"],
"quotes": ["off", "single"],
"func-call-spacing": ["error", "always"],
"one-var": "off",
"indent": "off",
"comma-style": "off",
"no-multi-spaces": "off",
"comma-dangle": "off",
"spaced-comment": "off",
"camelcase": "off",
"padded-blocks": "off",
"multiline-comment-style": "off",
"curly": "off",
"rest-spread-spacing": "off",
"no-multiple-empty-lines": "off",
"no-undef-init": "off",
"no-useless-return": "off",
"no-console": "off",
"operator-linebreak": "off",
"key-spacing": "off",
"brace-style": "off",
"padding-line-between-statements": ["off",
{"blankLine": "never", "prev":"*", "next": "*" },
{"blankLine": "always", "prev":"directive", "next": "*" },
{"blankLine": "always", "prev":"*", "next": "cjs-export" },
],
},
}
40 changes: 40 additions & 0 deletions js/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

module.exports = {
"env": {
"node": true,
},
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "script",
},
"rules": {
"semi": "off",
"no-unused-vars": ["off"],
"quotes": ["off", "single"],
"func-call-spacing": ["error", "always"],
"one-var": "off",
"indent": "off",
"comma-style": "off",
"no-multi-spaces": "off",
"comma-dangle": "off",
"spaced-comment": "off",
"camelcase": "off",
"padded-blocks": "off",
"multiline-comment-style": "off",
"curly": "off",
"rest-spread-spacing": "off",
"no-multiple-empty-lines": "off",
"no-undef-init": "off",
"no-useless-return": "off",
"no-console": "off",
"operator-linebreak": "off",
"key-spacing": "off",
"brace-style": "off",
"padding-line-between-statements": ["off",
{"blankLine": "never", "prev":"*", "next": "*" },
{"blankLine": "always", "prev":"directive", "next": "*" },
{"blankLine": "always", "prev":"*", "next": "cjs-export" },
],
},
}
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.716",
"version": "1.10.718",
"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.716';
$version = '1.10.718';

abstract class Exchange {

Expand Down
28 changes: 13 additions & 15 deletions php/okcoinusd.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ public function describe () {
'maker' => 0.002,
),
),
'exceptions' => array (
'1009' => '\\ccxt\\OrderNotFound',
'1003' => '\\ccxt\\InvalidOrder', // no order type (was left by previous author)
'1027' => '\\ccxt\\InvalidOrder', // createLimitBuyOrder(symbol, 0, 0) => Incorrect parameter may exceeded limits
'1002' => '\\ccxt\\InsufficientFunds', // The transaction amount exceed the balance
'10000' => '\\ccxt\\ExchangeError', // createLimitBuyOrder(symbol, null, null)
'10005' => '\\ccxt\\AuthenticationError', // bad apiKey
'10008' => '\\ccxt\\ExchangeError', // Illegal URL parameter
),
));
}

Expand Down Expand Up @@ -621,22 +630,11 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('error_code', $response)) {
$error = $this->safe_integer($response, 'error_code');
$error = $this->safe_string($response, 'error_code');
$message = $this->id . ' ' . $this->json ($response);
if ($error === 1009) {
throw new OrderNotFound ($message);
} else if ($error === 1002) {
throw new InsufficientFunds ($message); // amount exceeds the balance
} else if ($error === 1003) {
throw new InvalidOrder ($message); // no order type
} else if ($error === 1027) {
throw new InvalidOrder ($message); // createLimitBuyOrder(symbol, 0, 0) => Incorrect parameter may exceeded limits
} else if ($error === 10000) {
throw new ExchangeError ($message); // createLimitBuyOrder(symbol, null, null)
} else if ($error === 10005) {
throw new AuthenticationError ($message); // bad apiKey
} else if ($error === 10008) {
throw new ExchangeError ($message); // illegal URL parameter
if (is_array ($this->exceptions) && array_key_exists ($error, $this->exceptions)) {
$ExceptionClass = $this->exceptions[$error];
throw new $ExceptionClass ($message);
} else {
throw new ExchangeError ($message);
}
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.716'
__version__ = '1.10.718'

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

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.716'
__version__ = '1.10.718'

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

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.716'
__version__ = '1.10.718'

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

Expand Down
28 changes: 13 additions & 15 deletions python/ccxt/async/okcoinusd.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def describe(self):
'maker': 0.002,
},
},
'exceptions': {
'1009': OrderNotFound,
'1003': InvalidOrder, # no order type(was left by previous author)
'1027': InvalidOrder, # createLimitBuyOrder(symbol, 0, 0): Incorrect parameter may exceeded limits
'1002': InsufficientFunds, # The transaction amount exceed the balance
'10000': ExchangeError, # createLimitBuyOrder(symbol, None, None)
'10005': AuthenticationError, # bad apiKey
'10008': ExchangeError, # Illegal URL parameter
},
})

async def fetch_markets(self):
Expand Down Expand Up @@ -586,22 +595,11 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
def handle_errors(self, code, reason, url, method, headers, body):
response = json.loads(body)
if 'error_code' in response:
error = self.safe_integer(response, 'error_code')
error = self.safe_string(response, 'error_code')
message = self.id + ' ' + self.json(response)
if error == 1009:
raise OrderNotFound(message)
elif error == 1002:
raise InsufficientFunds(message) # amount exceeds the balance
elif error == 1003:
raise InvalidOrder(message) # no order type
elif error == 1027:
raise InvalidOrder(message) # createLimitBuyOrder(symbol, 0, 0): Incorrect parameter may exceeded limits
elif error == 10000:
raise ExchangeError(message) # createLimitBuyOrder(symbol, None, None)
elif error == 10005:
raise AuthenticationError(message) # bad apiKey
elif error == 10008:
raise ExchangeError(message) # illegal URL parameter
if error in self.exceptions:
ExceptionClass = self.exceptions[error]
raise ExceptionClass(message)
else:
raise ExchangeError(message)
if 'result' in response:
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.716'
__version__ = '1.10.718'

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

Expand Down
28 changes: 13 additions & 15 deletions python/ccxt/okcoinusd.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def describe(self):
'maker': 0.002,
},
},
'exceptions': {
'1009': OrderNotFound,
'1003': InvalidOrder, # no order type(was left by previous author)
'1027': InvalidOrder, # createLimitBuyOrder(symbol, 0, 0): Incorrect parameter may exceeded limits
'1002': InsufficientFunds, # The transaction amount exceed the balance
'10000': ExchangeError, # createLimitBuyOrder(symbol, None, None)
'10005': AuthenticationError, # bad apiKey
'10008': ExchangeError, # Illegal URL parameter
},
})

def fetch_markets(self):
Expand Down Expand Up @@ -586,22 +595,11 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
def handle_errors(self, code, reason, url, method, headers, body):
response = json.loads(body)
if 'error_code' in response:
error = self.safe_integer(response, 'error_code')
error = self.safe_string(response, 'error_code')
message = self.id + ' ' + self.json(response)
if error == 1009:
raise OrderNotFound(message)
elif error == 1002:
raise InsufficientFunds(message) # amount exceeds the balance
elif error == 1003:
raise InvalidOrder(message) # no order type
elif error == 1027:
raise InvalidOrder(message) # createLimitBuyOrder(symbol, 0, 0): Incorrect parameter may exceeded limits
elif error == 10000:
raise ExchangeError(message) # createLimitBuyOrder(symbol, None, None)
elif error == 10005:
raise AuthenticationError(message) # bad apiKey
elif error == 10008:
raise ExchangeError(message) # illegal URL parameter
if error in self.exceptions:
ExceptionClass = self.exceptions[error]
raise ExceptionClass(message)
else:
raise ExchangeError(message)
if 'result' in response:
Expand Down

0 comments on commit cdda5bd

Please sign in to comment.