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 21, 2018
2 parents 2747bb8 + aa50fc1 commit 9c83260
Show file tree
Hide file tree
Showing 72 changed files with 169 additions and 284 deletions.
116 changes: 44 additions & 72 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.14.242'
const version = '1.14.243'

Exchange.ccxtVersion = version

Expand Down
5 changes: 3 additions & 2 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,8 @@ To get the list of available timeframes for your exchange see the ``timeframes``

Like with most other unified and implicit methods, the ``fetchOHLCV`` method accepts as its last argument an associative array (a dictionary) of extra ``params``, which is used to override default values that are sent in requests to the exchanges. The contents of ``params`` are exchange-specific, consult the exchanges’ API documentation for supported fields and values.

If ``since`` is not specified the ``fetchOHLCV`` method will return the time range as is the default from the exchange itself. This is not a bug. Some exchanges will return candles from the beginning of time, others will return most recent candles only, the exchanges’ default behaviour is expected. Thus, without specifying ``since`` the range of returned candles will be exchange-specific. One should pass the ``since`` argument to ensure getting precisely the history range needed.

OHLCV Structure
~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -2343,11 +2345,10 @@ Deposit
'currency': currency, // currency code
'address': address, // address in terms of requested currency
'tag': tag, // tag / memo / paymentId for particular currencies (XRP, XMR, ...)
'status': status, // 'ok' or other
'info': response, // raw unparsed data as returned from the exchange
}
With certain currencies, like AEON, BTS, GXS, NXT, SBD, STEEM, STR, XEM, XLM, XMR, XRP, an additional argument ``tag`` is usually required by exchanges. The tag is a memo or a message or a payment id that is attached to a withdrawal transaction. The tag is mandatory for those currencies and it identifies the recipient user account.
With certain currencies, like AEON, BTS, GXS, NXT, SBD, STEEM, STR, XEM, XLM, XMR, XRP, an additional argument ``tag`` is usually required by exchanges. Other currencies will have the ``tag`` set to ``undefined / None / null``. The tag is a memo or a message or a payment id that is attached to a withdrawal transaction. The tag is mandatory for those currencies and it identifies the recipient user account.

Be careful when specifying the ``tag`` and the ``address``. The ``tag`` is **NOT an arbitrary user-defined string** of your choice! You cannot send user messages and comments in the ``tag``. The purpose of the ``tag`` field is to address your wallet properly, so it must be correct. You should only use the ``tag`` received from the exchange you’re working with, otherwise your withdrawal transaction might not arrive to its destination ever.

Expand Down
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.14.242",
"version": "1.14.243",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace ccxt;

$version = '1.14.242';
$version = '1.14.243';

// rounding mode
const TRUNCATE = 0;
Expand Down
4 changes: 1 addition & 3 deletions php/bittrex.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,8 @@ public function fetch_deposit_address ($code, $params = array ()) {
), $params));
$address = $this->safe_string($response['result'], 'Address');
$message = $this->safe_string($response, 'message');
$status = 'ok';
if (!$address || $message === 'ADDRESS_GENERATING')
$status = 'pending';
throw new AddressPending ($this->id . ' the $address for ' . $code . ' is being generated (pending, not ready yet, retry again later)');
$tag = null;
if (($code === 'XRP') || ($code === 'XLM')) {
$tag = $address;
Expand All @@ -674,7 +673,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => $status,
'info' => $response,
);
}
Expand Down
4 changes: 0 additions & 4 deletions php/braziliex.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ public function fetch_currencies ($params = array ()) {
$uppercase = strtoupper ($id);
$code = $this->common_currency_code($uppercase);
$active = $this->safe_integer($currency, 'active') === 1;
$status = 'ok';
$maintenance = $this->safe_integer($currency, 'under_maintenance');
if ($maintenance !== 0) {
$active = false;
$status = 'maintenance';
}
$canWithdraw = $this->safe_integer($currency, 'is_withdrawal_active') === 1;
$canDeposit = $this->safe_integer($currency, 'is_deposit_active') === 1;
Expand All @@ -94,7 +92,6 @@ public function fetch_currencies ($params = array ()) {
'code' => $code,
'name' => $currency['name'],
'active' => $active,
'status' => $status,
'precision' => $precision,
'funding' => array (
'withdraw' => array (
Expand Down Expand Up @@ -429,7 +426,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/cex.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => null,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
2 changes: 0 additions & 2 deletions php/cobinhood.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ public function create_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand All @@ -543,7 +542,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/crypton.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/cryptopia.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
2 changes: 0 additions & 2 deletions php/exmo.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
$this->load_markets();
$response = $this->privatePostDepositAddress ($params);
$depositAddress = $this->safe_string($response, $code);
$status = 'ok';
$address = null;
$tag = null;
if ($depositAddress) {
Expand All @@ -564,7 +563,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => $status,
'info' => $response,
);
}
Expand Down
9 changes: 2 additions & 7 deletions php/gatecoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand All @@ -656,7 +655,6 @@ public function create_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand All @@ -670,11 +668,8 @@ public function create_user_wallet ($code, $address, $name, $password, $params =
'Address' => $address,
'Password' => $password,
);
$response = $this->privatePostElectronicWalletUserWalletsDigiCurrency (array_merge ($request, $params));
return array (
'status' => 'ok',
'info' => $response,
);
// not unified yet
return $this->privatePostElectronicWalletUserWalletsDigiCurrency (array_merge ($request, $params));
}

public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
Expand Down
1 change: 0 additions & 1 deletion php/gateio.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ public function query_deposit_address ($method, $code, $params = array ()) {
'currency' => $currency,
'address' => $address,
'tag' => $tag,
'status' => ($address !== null) ? 'ok' : 'none',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/gemini.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public function create_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
2 changes: 0 additions & 2 deletions php/hitbtc2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ public function create_deposit_address ($code, $params = array ()) {
'currency' => $currency,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand All @@ -1073,7 +1072,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $currency['code'],
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/huobipro.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
$this->check_address($address);
return array (
'currency' => $code,
'status' => 'ok',
'address' => $address,
'info' => $response,
);
Expand Down
2 changes: 0 additions & 2 deletions php/kraken.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ public function create_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand Down Expand Up @@ -849,7 +848,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/kucoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/livecoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ public function fetch_deposit_address ($currency, $params = array ()) {
'currency' => $currency,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
5 changes: 2 additions & 3 deletions php/poloniex.php
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public function create_deposit_address ($code, $params = array ()) {
return array (
'currency' => $code,
'address' => $address,
'status' => 'ok',
'tag' => null,
'info' => $response,
);
}
Expand All @@ -779,11 +779,10 @@ public function fetch_deposit_address ($code, $params = array ()) {
$currencyId = $currency['id'];
$address = $this->safe_string($response, $currencyId);
$this->check_address($address);
$status = $address ? 'ok' : 'none';
return array (
'currency' => $code,
'address' => $address,
'status' => $status,
'tag' => null,
'info' => $response,
);
}
Expand Down
63 changes: 32 additions & 31 deletions php/quadrigacx.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public function describe () {
'BTG/CAD' => array ( 'id' => 'btg_cad', 'symbol' => 'BTG/CAD', 'base' => 'BTG', 'quote' => 'CAD', 'maker' => 0.005, 'taker' => 0.005 ),
'BTG/BTC' => array ( 'id' => 'btg_btc', 'symbol' => 'BTG/BTC', 'base' => 'BTG', 'quote' => 'BTC', 'maker' => 0.005, 'taker' => 0.005 ),
),
'exceptions' => array (
'101' => '\\ccxt\\AuthenticationError',
),
));
}

Expand Down Expand Up @@ -219,46 +222,41 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
), $params));
}

public function fetch_deposit_address ($currency, $params = array ()) {
$method = 'privatePost' . $this->get_currency_name ($currency) . 'DepositAddress';
public function fetch_deposit_address ($code, $params = array ()) {
$method = 'privatePost' . $this->get_currency_name ($code) . 'DepositAddress';
$response = $this->$method ($params);
$address = null;
$status = null;
// [E|e]rror
if (mb_strpos ($response, 'rror') !== false) {
$status = 'error';
} else {
$address = $response;
$status = 'ok';
throw new ExchangeError ($this->id . ' ' . $response);
}
$this->check_address($address);
$this->check_address($response);
return array (
'currency' => $currency,
'address' => $address,
'status' => $status,
'info' => $this->last_http_response,
'currency' => $code,
'address' => $response,
'tag' => null,
'info' => $response,
);
}

public function get_currency_name ($currency) {
public function get_currency_name ($code) {
$currencies = array (
'ETH' => 'Ether',
'BTC' => 'Bitcoin',
'LTC' => 'Litecoin',
'BCH' => 'Bitcoincash',
'BTG' => 'Bitcoingold',
);
return $currencies[$currency];
return $currencies[$code];
}

public function withdraw ($currency, $amount, $address, $tag = null, $params = array ()) {
public function withdraw ($code, $amount, $address, $tag = null, $params = array ()) {
$this->check_address($address);
$this->load_markets();
$request = array (
'amount' => $amount,
'address' => $address,
);
$method = 'privatePost' . $this->get_currency_name ($currency) . 'Withdrawal';
$method = 'privatePost' . $this->get_currency_name ($code) . 'Withdrawal';
$response = $this->$method (array_merge ($request, $params));
return array (
'info' => $response,
Expand Down Expand Up @@ -290,22 +288,25 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (

public function handle_errors ($statusCode, $statusText, $url, $method, $headers, $body) {
if (gettype ($body) !== 'string')
return; // fallback to default error handler
return; // fallback to default $error handler
if (strlen ($body) < 2)
return;
// Here is a sample QuadrigaCX response in case of authentication failure:
// array ("error":{"code":101,"message":"Invalid API Code or Invalid Signature")}
if ($statusCode === 200 && mb_strpos ($body, 'Invalid API Code or Invalid Signature') !== false) {
throw new AuthenticationError ($this->id . ' ' . $body);
if (($body[0] === '{') || ($body[0] === '[')) {
$response = json_decode ($body, $as_associative_array = true);
$error = $this->safe_value($response, 'error');
if ($error !== null) {
//
// array ("$error":{"$code":101,"message":"Invalid API Code or Invalid Signature")}
//
$code = $this->safe_string($error, 'code');
$feedback = $this->id . ' ' . $this->json ($response);
$exceptions = $this->exceptions;
if (is_array ($exceptions) && array_key_exists ($code, $exceptions)) {
throw new $exceptions[$code] ($feedback);
} else {
throw new ExchangeError ($this->id . ' unknown "$error" value => ' . $this->json ($response));
}
}
}
}

public function request ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$response = $this->fetch2 ($path, $api, $method, $params, $headers, $body);
if (gettype ($response) === 'string')
return $response;
if (is_array ($response) && array_key_exists ('error', $response))
throw new ExchangeError ($this->id . ' ' . $this->json ($response));
return $response;
}
}
1 change: 0 additions & 1 deletion php/southxchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ public function create_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $address,
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
1 change: 0 additions & 1 deletion php/tidebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public function fetch_deposit_address ($code, $params = array ()) {
'currency' => $code,
'address' => $this->check_address($address),
'tag' => $tag,
'status' => 'ok',
'info' => $response,
);
}
Expand Down
Loading

0 comments on commit 9c83260

Please sign in to comment.