Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ccxt/ccxt
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 16, 2018
2 parents 3c705ce + e2b5e0d commit 2f000bd
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 105 deletions.
64 changes: 36 additions & 28 deletions build/ccxt.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.17.385'
const version = '1.17.386'

Exchange.ccxtVersion = version

Expand Down Expand Up @@ -2420,8 +2420,8 @@ module.exports = class Exchange {
return new Promise ((resolve, reject) => resolve (Object.values (this.markets)))
}

async fetchOrderStatus (id, market = undefined) {
let order = await this.fetchOrder (id, market);
async fetchOrderStatus (id, symbol = undefined, params = {}) {
let order = await this.fetchOrder (id, symbol, params);
return order['status'];
}

Expand Down Expand Up @@ -12303,7 +12303,7 @@ module.exports = class bitmarket extends Exchange {
// ---------------------------------------------------------------------------

const Exchange = require ('./base/Exchange');
const { ExchangeError, DDoSProtection, OrderNotFound, AuthenticationError, PermissionDenied } = require ('./base/errors');
const { ExchangeError, ExchangeNotAvailable, DDoSProtection, OrderNotFound, AuthenticationError, PermissionDenied } = require ('./base/errors');

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

Expand Down Expand Up @@ -12431,8 +12431,13 @@ module.exports = class bitmex extends Exchange {
},
},
'exceptions': {
'Invalid API Key.': AuthenticationError,
'Access Denied': PermissionDenied,
'exact': {
'Invalid API Key.': AuthenticationError,
'Access Denied': PermissionDenied,
},
'broad': {
'overloaded': ExchangeNotAvailable,
},
},
'options': {
'fetchTickerQuotes': false,
Expand Down Expand Up @@ -12869,19 +12874,18 @@ module.exports = class bitmex extends Exchange {
if (body) {
if (body[0] === '{') {
let response = JSON.parse (body);
if ('error' in response) {
if ('message' in response['error']) {
let feedback = this.id + ' ' + this.json (response);
let message = this.safeValue (response['error'], 'message');
let exceptions = this.exceptions;
if (message !== undefined) {
if (message in exceptions) {
throw new exceptions[message] (feedback);
}
}
throw new ExchangeError (feedback);
}
const message = this.safeString (response, 'error');
const feedback = this.id + ' ' + body;
const exact = this.exceptions['exact'];
if (code in exact) {
throw new exact[code] (feedback);
}
const broad = this.exceptions['broad'];
const broadKey = this.findBroadlyMatchedKey (broad, message);
if (broadKey !== undefined) {
throw new broad[broadKey] (feedback);
}
throw new ExchangeError (feedback); // unknown message
}
}
}
Expand Down Expand Up @@ -14351,6 +14355,7 @@ module.exports = class bitstamp extends Exchange {
'In Queue': 'open',
'Open': 'open',
'Finished': 'closed',
'Canceled': 'canceled',
};
return (status in statuses) ? statuses[status] : status;
}
Expand Down Expand Up @@ -14910,17 +14915,20 @@ module.exports = class bitstamp1 extends Exchange {
return await this.privatePostCancelOrder ({ 'id': id });
}

parseOrderStatus (order) {
if ((order['status'] === 'Queue') || (order['status'] === 'Open'))
return 'open';
if (order['status'] === 'Finished')
return 'closed';
return order['status'];
parseOrderStatus (status) {
let statuses = {
'In Queue': 'open',
'Open': 'open',
'Finished': 'closed',
'Canceled': 'canceled',
};
return (status in statuses) ? statuses[status] : status;
}

async fetchOrderStatus (id, symbol = undefined) {
async fetchOrderStatus (id, symbol = undefined, params = {}) {
await this.loadMarkets ();
let response = await this.privatePostOrderStatus ({ 'id': id });
let request = { 'id': id };
let response = await this.privatePostOrderStatus (this.extend (request, params));
return this.parseOrderStatus (response);
}

Expand Down Expand Up @@ -50894,9 +50902,9 @@ module.exports = class poloniex extends Exchange {
return response;
}

async fetchOrderStatus (id, symbol = undefined) {
async fetchOrderStatus (id, symbol = undefined, params = {}) {
await this.loadMarkets ();
let orders = await this.fetchOpenOrders (symbol);
let orders = await this.fetchOpenOrders (symbol, undefined, undefined, params);
let indexed = this.indexBy (orders, 'id');
return (id in indexed) ? 'open' : 'closed';
}
Expand Down
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.17.385'
const version = '1.17.386'

Exchange.ccxtVersion = version

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.17.385",
"version": "1.17.386",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 100+ exchanges",
"main": "./ccxt.js",
"unpkg": "build/ccxt.browser.js",
Expand Down
4 changes: 2 additions & 2 deletions php/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use kornrunner\Secp256k1;
use kornrunner\Solidity;

$version = '1.17.385';
$version = '1.17.386';

// rounding mode
const TRUNCATE = 0;
Expand All @@ -50,7 +50,7 @@

class Exchange {

const VERSION = '1.17.385';
const VERSION = '1.17.386';

public static $eth_units = array (
'wei' => '1',
Expand Down
32 changes: 18 additions & 14 deletions php/bitmex.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ public function describe () {
),
),
'exceptions' => array (
'Invalid API Key.' => '\\ccxt\\AuthenticationError',
'Access Denied' => '\\ccxt\\PermissionDenied',
'exact' => array (
'Invalid API Key.' => '\\ccxt\\AuthenticationError',
'Access Denied' => '\\ccxt\\PermissionDenied',
),
'broad' => array (
'overloaded' => '\\ccxt\\ExchangeNotAvailable',
),
),
'options' => array (
'fetchTickerQuotes' => false,
Expand Down Expand Up @@ -570,19 +575,18 @@ public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
if ($body) {
if ($body[0] === '{') {
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('error', $response)) {
if (is_array ($response['error']) && array_key_exists ('message', $response['error'])) {
$feedback = $this->id . ' ' . $this->json ($response);
$message = $this->safe_value($response['error'], 'message');
$exceptions = $this->exceptions;
if ($message !== null) {
if (is_array ($exceptions) && array_key_exists ($message, $exceptions)) {
throw new $exceptions[$message] ($feedback);
}
}
throw new ExchangeError ($feedback);
}
$message = $this->safe_string($response, 'error');
$feedback = $this->id . ' ' . $body;
$exact = $this->exceptions['exact'];
if (is_array ($exact) && array_key_exists ($code, $exact)) {
throw new $exact[$code] ($feedback);
}
$broad = $this->exceptions['broad'];
$broadKey = $this->findBroadlyMatchedKey ($broad, $message);
if ($broadKey !== null) {
throw new $broad[$broadKey] ($feedback);
}
throw new ExchangeError ($feedback); // unknown $message
}
}
}
Expand Down
1 change: 1 addition & 0 deletions php/bitstamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ public function parse_order_status ($status) {
'In Queue' => 'open',
'Open' => 'open',
'Finished' => 'closed',
'Canceled' => 'canceled',
);
return (is_array ($statuses) && array_key_exists ($status, $statuses)) ? $statuses[$status] : $status;
}
Expand Down
19 changes: 11 additions & 8 deletions php/bitstamp1.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,20 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
return $this->privatePostCancelOrder (array ( 'id' => $id ));
}

public function parse_order_status ($order) {
if (($order['status'] === 'Queue') || ($order['status'] === 'Open'))
return 'open';
if ($order['status'] === 'Finished')
return 'closed';
return $order['status'];
public function parse_order_status ($status) {
$statuses = array (
'In Queue' => 'open',
'Open' => 'open',
'Finished' => 'closed',
'Canceled' => 'canceled',
);
return (is_array ($statuses) && array_key_exists ($status, $statuses)) ? $statuses[$status] : $status;
}

public function fetch_order_status ($id, $symbol = null) {
public function fetch_order_status ($id, $symbol = null, $params = array ()) {
$this->load_markets();
$response = $this->privatePostOrderStatus (array ( 'id' => $id ));
$request = array ( 'id' => $id );
$response = $this->privatePostOrderStatus (array_merge ($request, $params));
return $this->parse_order_status($response);
}

Expand Down
4 changes: 2 additions & 2 deletions php/poloniex.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
return $response;
}

public function fetch_order_status ($id, $symbol = null) {
public function fetch_order_status ($id, $symbol = null, $params = array ()) {
$this->load_markets();
$orders = $this->fetch_open_orders($symbol);
$orders = $this->fetch_open_orders($symbol, null, null, $params);
$indexed = $this->index_by($orders, 'id');
return (is_array ($indexed) && array_key_exists ($id, $indexed)) ? 'open' : 'closed';
}
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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

__version__ = '1.17.385'
__version__ = '1.17.386'

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

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async_support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

__version__ = '1.17.385'
__version__ = '1.17.386'

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

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async_support/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

__version__ = '1.17.385'
__version__ = '1.17.386'

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

Expand Down
29 changes: 18 additions & 11 deletions python/ccxt/async_support/bitmex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ccxt.base.errors import PermissionDenied
from ccxt.base.errors import OrderNotFound
from ccxt.base.errors import DDoSProtection
from ccxt.base.errors import ExchangeNotAvailable


class bitmex (Exchange):
Expand Down Expand Up @@ -137,8 +138,13 @@ def describe(self):
},
},
'exceptions': {
'Invalid API Key.': AuthenticationError,
'Access Denied': PermissionDenied,
'exact': {
'Invalid API Key.': AuthenticationError,
'Access Denied': PermissionDenied,
},
'broad': {
'overloaded': ExchangeNotAvailable,
},
},
'options': {
'fetchTickerQuotes': False,
Expand Down Expand Up @@ -542,15 +548,16 @@ def handle_errors(self, code, reason, url, method, headers, body):
if body:
if body[0] == '{':
response = json.loads(body)
if 'error' in response:
if 'message' in response['error']:
feedback = self.id + ' ' + self.json(response)
message = self.safe_value(response['error'], 'message')
exceptions = self.exceptions
if message is not None:
if message in exceptions:
raise exceptions[message](feedback)
raise ExchangeError(feedback)
message = self.safe_string(response, 'error')
feedback = self.id + ' ' + body
exact = self.exceptions['exact']
if code in exact:
raise exact[code](feedback)
broad = self.exceptions['broad']
broadKey = self.findBroadlyMatchedKey(broad, message)
if broadKey is not None:
raise broad[broadKey](feedback)
raise ExchangeError(feedback) # unknown message

def nonce(self):
return self.milliseconds()
Expand Down
1 change: 1 addition & 0 deletions python/ccxt/async_support/bitstamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ def parse_order_status(self, status):
'In Queue': 'open',
'Open': 'open',
'Finished': 'closed',
'Canceled': 'canceled',
}
return statuses[status] if (status in list(statuses.keys())) else status

Expand Down
21 changes: 12 additions & 9 deletions python/ccxt/async_support/bitstamp1.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,19 @@ async def create_order(self, symbol, type, side, amount, price=None, params={}):
async def cancel_order(self, id, symbol=None, params={}):
return await self.privatePostCancelOrder({'id': id})

def parse_order_status(self, order):
if (order['status'] == 'Queue') or (order['status'] == 'Open'):
return 'open'
if order['status'] == 'Finished':
return 'closed'
return order['status']

async def fetch_order_status(self, id, symbol=None):
def parse_order_status(self, status):
statuses = {
'In Queue': 'open',
'Open': 'open',
'Finished': 'closed',
'Canceled': 'canceled',
}
return statuses[status] if (status in list(statuses.keys())) else status

async def fetch_order_status(self, id, symbol=None, params={}):
await self.load_markets()
response = await self.privatePostOrderStatus({'id': id})
request = {'id': id}
response = await self.privatePostOrderStatus(self.extend(request, params))
return self.parse_order_status(response)

async def fetch_my_trades(self, symbol=None, since=None, limit=None, params={}):
Expand Down
4 changes: 2 additions & 2 deletions python/ccxt/async_support/poloniex.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,9 @@ async def cancel_order(self, id, symbol=None, params={}):
self.orders[id]['status'] = 'canceled'
return response

async def fetch_order_status(self, id, symbol=None):
async def fetch_order_status(self, id, symbol=None, params={}):
await self.load_markets()
orders = await self.fetch_open_orders(symbol)
orders = await self.fetch_open_orders(symbol, None, None, params)
indexed = self.index_by(orders, 'id')
return 'open' if (id in list(indexed.keys())) else 'closed'

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.17.385'
__version__ = '1.17.386'

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

Expand Down
Loading

0 comments on commit 2f000bd

Please sign in to comment.