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 28, 2018
2 parents e26074e + f653db0 commit 94be556
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 190 deletions.
104 changes: 53 additions & 51 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.878'
const version = '1.10.882'

Exchange.ccxtVersion = version

Expand Down
4 changes: 2 additions & 2 deletions js/bitfinex.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = class bitfinex extends Exchange {
'SAN': 0.1,
'DASH': 0.01,
'ETC': 0.01,
'XPR': 0.02,
'XRP': 0.02,
'YYW': 0.1,
'NEO': 0,
'ZEC': 0.1,
Expand All @@ -190,7 +190,7 @@ module.exports = class bitfinex extends Exchange {
'SAN': 0.1,
'DASH': 0.01,
'ETC': 0.01,
'XPR': 0.02,
'XRP': 0.02,
'YYW': 0.1,
'NEO': 0,
'ZEC': 0.1,
Expand Down
37 changes: 18 additions & 19 deletions js/lykke.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

// ---------------------------------------------------------------------------

Expand All @@ -7,7 +7,6 @@ const Exchange = require ('./base/Exchange');
// ---------------------------------------------------------------------------

module.exports = class lykke extends Exchange {

describe () {
return this.deepExtend (super.describe (), {
'id': 'lykke',
Expand Down Expand Up @@ -123,9 +122,9 @@ module.exports = class lykke extends Exchange {
'OrderAction': this.capitalize (side),
'Volume': amount,
};
if (type == 'market') {
query['Asset'] = (side == 'buy') ? market['base'] : market['quote'];
} else if (type == 'limit') {
if (type === 'market') {
query['Asset'] = (side === 'buy') ? market['base'] : market['quote'];
} else if (type === 'limit') {
query['Price'] = price;
}
let method = 'privatePostOrders' + this.capitalize (type);
Expand Down Expand Up @@ -213,23 +212,23 @@ module.exports = class lykke extends Exchange {
}

parseOrderStatus (status) {
if (status == 'Pending') {
if (status === 'Pending') {
return 'open';
} else if (status == 'InOrderBook') {
} else if (status === 'InOrderBook') {
return 'open';
} else if (status == 'Processing') {
} else if (status === 'Processing') {
return 'open';
} else if (status == 'Matched') {
} else if (status === 'Matched') {
return 'closed';
} else if (status == 'Cancelled') {
} else if (status === 'Cancelled') {
return 'canceled';
} else if (status == 'NotEnoughFunds') {
} else if (status === 'NotEnoughFunds') {
return 'NotEnoughFunds';
} else if (status == 'NoLiquidity') {
} else if (status === 'NoLiquidity') {
return 'NoLiquidity';
} else if (status == 'UnknownAsset') {
} else if (status === 'UnknownAsset') {
return 'UnknownAsset';
} else if (status == 'LeadToNegativeSpread') {
} else if (status === 'LeadToNegativeSpread') {
return 'LeadToNegativeSpread';
}
return status;
Expand Down Expand Up @@ -345,11 +344,11 @@ module.exports = class lykke extends Exchange {
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'][api] + '/' + this.implodeParams (path, params);
let query = this.omit (params, this.extractParams (path));
if (api == 'public') {
if (api === 'public') {
if (Object.keys (query).length)
url += '?' + this.urlencode (query);
} else if (api == 'private') {
if (method == 'GET')
} else if (api === 'private') {
if (method === 'GET')
if (Object.keys (query).length)
url += '?' + this.urlencode (query);
this.checkRequiredCredentials ();
Expand All @@ -358,10 +357,10 @@ module.exports = class lykke extends Exchange {
'Accept': 'application/json',
'Content-Type': 'application/json',
};
if (method == 'POST')
if (method === 'POST')
if (Object.keys (params).length)
body = this.json (params);
}
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
}
}
};
54 changes: 29 additions & 25 deletions js/wex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

// ---------------------------------------------------------------------------

Expand All @@ -8,7 +8,6 @@ const { ExchangeError, InsufficientFunds, OrderNotFound, DDoSProtection } = requ
// ---------------------------------------------------------------------------

module.exports = class wex extends liqui {

describe () {
return this.deepExtend (super.describe (), {
'id': 'wex',
Expand Down Expand Up @@ -76,6 +75,14 @@ module.exports = class wex extends liqui {
},
},
},
'exceptions': {
'messages': {
'bad status': OrderNotFound,
'Requests too often': DDoSProtection,
'not available': DDoSProtection,
'external service unavailable': DDoSProtection,
},
},
});
}

Expand Down Expand Up @@ -107,37 +114,34 @@ module.exports = class wex extends liqui {
}

handleErrors (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;
}
let response = JSON.parse (body);
if ('success' in response) {
if (!response['success']) {
let error = this.safeValue (response, 'error');
const error = this.safeString (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 (error.indexOf ('It is not enough') >= 0) {
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;
}
const feedback = this.id + ' ' + this.json (response);
const messages = this.exceptions.messages;
if (error in messages) {
throw new messages[error] (feedback);
}
if (error.indexOf ('It is not enough') >= 0) {
throw new InsufficientFunds (feedback);
} else {
throw new ExchangeError (feedback);
}
}
}
}
}

request (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
return this.fetch2 (path, api, method, params, headers, body);
}
}
};
5 changes: 2 additions & 3 deletions js/zb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { ExchangeError } = require ('./base/errors');
// ---------------------------------------------------------------------------

module.exports = class zb extends Exchange {

describe () {
return this.deepExtend (super.describe (), {
'id': 'zb',
Expand Down Expand Up @@ -345,7 +344,7 @@ module.exports = class zb extends Exchange {

sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'][api];
if (api == 'public') {
if (api === 'public') {
url += '/' + this.version + '/' + path;
if (Object.keys (params).length)
url += '?' + this.urlencode (params);
Expand Down Expand Up @@ -391,4 +390,4 @@ module.exports = class zb extends Exchange {
throw new ExchangeError (this.id + ' ' + this.json (response));
return response;
}
}
};
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.878",
"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.878';
$version = '1.10.882';

abstract class Exchange {

Expand Down
4 changes: 2 additions & 2 deletions php/bitfinex.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function describe () {
'SAN' => 0.1,
'DASH' => 0.01,
'ETC' => 0.01,
'XPR' => 0.02,
'XRP' => 0.02,
'YYW' => 0.1,
'NEO' => 0,
'ZEC' => 0.1,
Expand All @@ -185,7 +185,7 @@ public function describe () {
'SAN' => 0.1,
'DASH' => 0.01,
'ETC' => 0.01,
'XPR' => 0.02,
'XRP' => 0.02,
'YYW' => 0.1,
'NEO' => 0,
'ZEC' => 0.1,
Expand Down
32 changes: 16 additions & 16 deletions php/lykke.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public function create_order ($symbol, $type, $side, $amount, $price = null, $pa
'OrderAction' => $this->capitalize ($side),
'Volume' => $amount,
);
if ($type == 'market') {
$query['Asset'] = ($side == 'buy') ? $market['base'] : $market['quote'];
} else if ($type == 'limit') {
if ($type === 'market') {
$query['Asset'] = ($side === 'buy') ? $market['base'] : $market['quote'];
} else if ($type === 'limit') {
$query['Price'] = $price;
}
$method = 'privatePostOrders' . $this->capitalize ($type);
Expand Down Expand Up @@ -209,23 +209,23 @@ public function fetch_ticker ($symbol, $params = array ()) {
}

public function parse_order_status ($status) {
if ($status == 'Pending') {
if ($status === 'Pending') {
return 'open';
} else if ($status == 'InOrderBook') {
} else if ($status === 'InOrderBook') {
return 'open';
} else if ($status == 'Processing') {
} else if ($status === 'Processing') {
return 'open';
} else if ($status == 'Matched') {
} else if ($status === 'Matched') {
return 'closed';
} else if ($status == 'Cancelled') {
} else if ($status === 'Cancelled') {
return 'canceled';
} else if ($status == 'NotEnoughFunds') {
} else if ($status === 'NotEnoughFunds') {
return 'NotEnoughFunds';
} else if ($status == 'NoLiquidity') {
} else if ($status === 'NoLiquidity') {
return 'NoLiquidity';
} else if ($status == 'UnknownAsset') {
} else if ($status === 'UnknownAsset') {
return 'UnknownAsset';
} else if ($status == 'LeadToNegativeSpread') {
} else if ($status === 'LeadToNegativeSpread') {
return 'LeadToNegativeSpread';
}
return $status;
Expand Down Expand Up @@ -341,11 +341,11 @@ public function parse_bid_ask ($bidask, $priceKey = 0, $amountKey = 1) {
public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$url = $this->urls['api'][$api] . '/' . $this->implode_params($path, $params);
$query = $this->omit ($params, $this->extract_params($path));
if ($api == 'public') {
if ($api === 'public') {
if ($query)
$url .= '?' . $this->urlencode ($query);
} else if ($api == 'private') {
if ($method == 'GET')
} else if ($api === 'private') {
if ($method === 'GET')
if ($query)
$url .= '?' . $this->urlencode ($query);
$this->check_required_credentials();
Expand All @@ -354,7 +354,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
'Accept' => 'application/json',
'Content-Type' => 'application/json',
);
if ($method == 'POST')
if ($method === 'POST')
if ($params)
$body = $this->json ($params);
}
Expand Down
Loading

0 comments on commit 94be556

Please sign in to comment.