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 Jun 2, 2018
2 parents 1d6822e + 6c6214e commit 0b3ac3d
Show file tree
Hide file tree
Showing 20 changed files with 417 additions and 161 deletions.
155 changes: 124 additions & 31 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.115'
const version = '1.14.118'

Exchange.ccxtVersion = version

Expand Down
2 changes: 1 addition & 1 deletion doc/README.rst
Expand Up @@ -573,7 +573,7 @@ Thank you!
:target: https://nodesecurity.io/orgs/ccxt/projects/856d3088-8b46-4515-9324-6b7cd2470522
.. |Gitter| image:: https://badges.gitter.im/ccxt-dev/ccxt.svg
:target: https://gitter.im/ccxt-dev/ccxt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
.. |Supported Exchanges| image:: https://img.shields.io/badge/exchanges-115-blue.svg
.. |Supported Exchanges| image:: https://img.shields.io/badge/exchanges-116-blue.svg
:target: https://github.com/ccxt/ccxt/wiki/Exchange-Markets
.. |Open Collective| image:: https://opencollective.com/ccxt/backers/badge.svg
:target: https://opencollective.com/ccxt
Expand Down
3 changes: 3 additions & 0 deletions js/bittrex.js
Expand Up @@ -616,6 +616,9 @@ module.exports = class bittrex extends Exchange {
}
throw e;
}
if (!response['result']) {
throw new OrderNotFound (this.id + ' order ' + id + ' not found');
}
return this.parseOrder (response['result']);
}

Expand Down
35 changes: 25 additions & 10 deletions js/coinfloor.js
Expand Up @@ -3,7 +3,7 @@
// ---------------------------------------------------------------------------

const Exchange = require ('./base/Exchange');
const { ExchangeError, NotSupported } = require ('./base/errors');
const { NotSupported } = require ('./base/errors');

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

Expand Down Expand Up @@ -66,18 +66,33 @@ module.exports = class coinfloor extends Exchange {
});
}

fetchBalance (params = {}) {
let symbol = undefined;
async fetchBalance (params = {}) {
let market = undefined;
if ('symbol' in params)
symbol = params['symbol'];
market = this.findMarket (params['symbol']);
if ('id' in params)
symbol = params['id'];
if (!symbol)
throw new ExchangeError (this.id + ' fetchBalance requires a symbol param');
// todo parse balance
return this.privatePostIdBalance ({
'id': this.marketId (symbol),
market = this.findMarket (params['id']);
if (!market)
throw new NotSupported (this.id + ' fetchBalance requires a symbol param');
let response = await this.privatePostIdBalance ({
'id': market['id'],
});
let result = {
'info': response,
};
// base/quote used for keys e.g. "xbt_reserved"
let keys = market['id'].toLowerCase ().split ('/');
result[market['base']] = {
'free': parseFloat (response[keys[0] + '_available']),
'used': parseFloat (response[keys[0] + '_reserved']),
'total': parseFloat (response[keys[0] + '_balance']),
};
result[market['quote']] = {
'free': parseFloat (response[keys[1] + '_available']),
'used': parseFloat (response[keys[1] + '_reserved']),
'total': parseFloat (response[keys[1] + '_balance']),
};
return this.parseBalance (result);
}

async fetchOrderBook (symbol, limit = undefined, params = {}) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.14.115",
"version": "1.14.118",
"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.115';
$version = '1.14.118';

// rounding mode
const TRUNCATE = 0;
Expand Down
101 changes: 82 additions & 19 deletions php/bit2c.php
Expand Up @@ -18,6 +18,7 @@ public function describe () {
'has' => array (
'CORS' => false,
'fetchOpenOrders' => true,
'fetchMyTrades' => true,
),
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/27766119-3593220e-5ece-11e7-8b3a-5a041f6bcc3f.jpg',
Expand Down Expand Up @@ -135,25 +136,6 @@ public function fetch_ticker ($symbol, $params = array ()) {
);
}

public function parse_trade ($trade, $market = null) {
$timestamp = intval ($trade['date']) * 1000;
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'id' => (string) $trade['tid'],
'info' => $trade,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'symbol' => $symbol,
'order' => null,
'type' => null,
'side' => null,
'price' => $trade['price'],
'amount' => $trade['amount'],
);
}

public function fetch_trades ($symbol, $since = null, $limit = null, $params = array ()) {
$market = $this->market ($symbol);
$response = $this->publicGetExchangesPairTrades (array_merge (array (
Expand Down Expand Up @@ -253,4 +235,85 @@ public function parse_order ($order, $market = null) {
'info' => $order,
);
}

public function fetch_my_trades ($symbol = null, $since = null, $limit = null, $params = array ()) {
$this->load_markets();
$market = null;
$method = 'privateGetOrderOrderhistory';
$request = array ();
if ($limit !== null)
$request['take'] = $limit;
$request['take'] = $limit;
if ($since !== null) {
$request['toTime'] = $this->ymd ($this->milliseconds (), '.');
$request['fromTime'] = $this->ymd ($since, '.');
}
if ($symbol !== null) {
$market = $this->market ($symbol);
$request['pair'] = $market['id'];
}
$response = $this->$method (array_merge ($request, $params));
return $this->parse_trades($response, $market, $since, $limit);
}

public function parse_trade ($trade, $market = null) {
$timestamp = null;
$id = null;
$price = null;
$amount = null;
$orderId = null;
$feeCost = null;
$side = null;
$reference = $this->safe_string($trade, 'reference');
if ($reference !== null) {
$timestamp = $this->safe_integer($trade, 'ticks') * 1000;
$price = $this->safe_float($trade, 'price');
$amount = $this->safe_float($trade, 'firstAmount');
$reference_parts = explode ('|', $reference); // $reference contains => 'pair|$orderId|tradeId'
if ($market === null) {
$marketId = $this->safe_string($trade, 'pair');
if (is_array ($this->markets_by_id[$marketId]) && array_key_exists ($marketId, $this->markets_by_id[$marketId])) {
$market = $this->markets_by_id[$marketId];
} else if (is_array ($this->markets_by_id) && array_key_exists ($reference_parts[0], $this->markets_by_id)) {
$market = $this->markets_by_id[$reference_parts[0]];
}
}
$orderId = $reference_parts[1];
$id = $reference_parts[2];
$side = $this->safe_integer($trade, 'action');
if ($side === 0) {
$side = 'buy';
} else if ($side === 1) {
$side = 'sell';
}
$feeCost = $this->safe_float($trade, 'feeAmount');
} else {
$timestamp = $this->safe_integer($trade, 'date') * 1000;
$id = $this->safe_integer($trade, 'tid');
$price = $this->safe_float($trade, 'price');
$amount = $this->safe_float($trade, 'amount');
}
$symbol = null;
if ($market !== null)
$symbol = $market['symbol'];
return array (
'info' => $trade,
'id' => $id,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'symbol' => $symbol,
'order' => $orderId,
'type' => null,
'side' => $side,
'takerOrMaker' => null,
'price' => $price,
'amount' => $amount,
'cost' => $price * $amount,
'fee' => array (
'cost' => $feeCost,
'currency' => 'NIS',
'rate' => null,
),
);
}
}
3 changes: 3 additions & 0 deletions php/bittrex.php
Expand Up @@ -617,6 +617,9 @@ public function fetch_order ($id, $symbol = null, $params = array ()) {
}
throw $e;
}
if (!$response['result']) {
throw new OrderNotFound ($this->id . ' order ' . $id . ' not found');
}
return $this->parse_order($response['result']);
}

Expand Down
31 changes: 23 additions & 8 deletions php/coinfloor.php
Expand Up @@ -68,17 +68,32 @@ public function describe () {
}

public function fetch_balance ($params = array ()) {
$symbol = null;
$market = null;
if (is_array ($params) && array_key_exists ('symbol', $params))
$symbol = $params['symbol'];
$market = $this->find_market($params['symbol']);
if (is_array ($params) && array_key_exists ('id', $params))
$symbol = $params['id'];
if (!$symbol)
throw new ExchangeError ($this->id . ' fetchBalance requires a $symbol param');
// todo parse balance
return $this->privatePostIdBalance (array (
'id' => $this->market_id($symbol),
$market = $this->find_market($params['id']);
if (!$market)
throw new NotSupported ($this->id . ' fetchBalance requires a symbol param');
$response = $this->privatePostIdBalance (array (
'id' => $market['id'],
));
$result = array (
'info' => $response,
);
// base/quote used for $keys e.g. "xbt_reserved"
$keys = strtolower (explode ('/', $market['id']));
$result[$market['base']] = array (
'free' => floatval ($response[$keys[0] . '_available']),
'used' => floatval ($response[$keys[0] . '_reserved']),
'total' => floatval ($response[$keys[0] . '_balance']),
);
$result[$market['quote']] = array (
'free' => floatval ($response[$keys[1] . '_available']),
'used' => floatval ($response[$keys[1] . '_reserved']),
'total' => floatval ($response[$keys[1] . '_balance']),
);
return $this->parse_balance($result);
}

public function fetch_order_book ($symbol, $limit = null, $params = array ()) {
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Expand Up @@ -22,7 +22,7 @@

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

__version__ = '1.14.115'
__version__ = '1.14.118'

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

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

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

__version__ = '1.14.115'
__version__ = '1.14.118'

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

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

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

__version__ = '1.14.115'
__version__ = '1.14.118'

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

Expand Down

0 comments on commit 0b3ac3d

Please sign in to comment.