Skip to content

Commit

Permalink
transpiled to php and python ccxt#541
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 19, 2017
1 parent ec07e19 commit 71918ef
Show file tree
Hide file tree
Showing 214 changed files with 416 additions and 106 deletions.
7 changes: 5 additions & 2 deletions php/_1broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function describe () {
'www' => 'https://1broker.com',
'doc' => 'https://1broker.com/?c=en/content/api-documentation',
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => false,
),
'api' => array (
'private' => array (
'get' => array (
Expand Down Expand Up @@ -239,8 +243,7 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
}

public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
if (!$this->apiKey)
throw new AuthenticationError ($this->id . ' requires apiKey for all requests');
$this->check_required_credentials();
$url = $this->urls['api'] . '/' . $this->version . '/' . $path . '.php';
$query = array_merge (array ( 'token' => $this->apiKey ), $params);
$url .= '?' . $this->urlencode ($query);
Expand Down
1 change: 1 addition & 0 deletions php/_1btcxe.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$query = array_merge (array (
'api_key' => $this->apiKey,
'nonce' => $this->nonce (),
Expand Down
1 change: 1 addition & 0 deletions php/acx.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$query = $this->urlencode ($this->keysort (array_merge (array (
'access_key' => $this->apiKey,
Expand Down
1 change: 1 addition & 0 deletions php/anxpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$body = $this->urlencode (array_merge (array ( 'nonce' => $nonce ), $query));
$secret = base64_decode ($this->secret);
Expand Down
1 change: 1 addition & 0 deletions php/binance.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'wapi')
$url .= '.html';
if (($api == 'private') || ($api == 'wapi')) {
$this->check_required_credentials();
$nonce = $this->nonce ();
$query = $this->urlencode (array_merge (array ( 'timestamp' => $nonce ), $params));
$signature = null;
Expand Down
1 change: 1 addition & 0 deletions php/bit2c.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'public') {
$url .= '.json';
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$query = array_merge (array ( 'nonce' => $nonce ), $params);
$body = $this->urlencode ($query);
Expand Down
1 change: 1 addition & 0 deletions php/bitbay.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'public') {
$url .= '/' . $this->implode_params($path, $params) . '.json';
} else {
$this->check_required_credentials();
$body = $this->urlencode (array_merge (array (
'method' => $path,
'moment' => $this->nonce (),
Expand Down
1 change: 1 addition & 0 deletions php/bitcoincoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'public') {
$url .= '/' . $this->implode_params($path, $params);
} else {
$this->check_required_credentials();
$body = $this->urlencode (array_merge (array (
'method' => $path,
'nonce' => $this->nonce (),
Expand Down
1 change: 1 addition & 0 deletions php/bitfinex.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
}
}
if ($api == 'private') {
$this->check_required_credentials();
$nonce = $this->nonce ();
$query = array_merge (array (
'nonce' => (string) $nonce,
Expand Down
1 change: 1 addition & 0 deletions php/bitfinex2.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
$url .= '?' . $this->urlencode ($query);
}
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$body = $this->json ($query);
$auth = '/api' . '/' . $request . $nonce . $body;
Expand Down
1 change: 1 addition & 0 deletions php/bitflyer.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
}
$url = $this->urls['api'] . $request;
if ($api == 'private') {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$body = $this->json ($params);
$auth = implode ('', array ($nonce, $method, $request, $body));
Expand Down
1 change: 1 addition & 0 deletions php/bithumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$body = $this->urlencode (array_merge (array (
'endpoint' => $endpoint,
), $query));
Expand Down
5 changes: 5 additions & 0 deletions php/bitlish.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function describe () {
'www' => 'https://bitlish.com',
'doc' => 'https://bitlish.com/api',
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => false,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -297,6 +301,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
$headers = array ( 'Content-Type' => 'application/json' );
}
} else {
$this->check_required_credentials();
$body = $this->json (array_merge (array ( 'token' => $this->apiKey ), $params));
$headers = array ( 'Content-Type' => 'application/json' );
}
Expand Down
1 change: 1 addition & 0 deletions php/bitmarket.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'public') {
$url .= '/' . $this->implode_params($path . '.json', $params);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$query = array_merge (array (
'tonce' => $nonce,
Expand Down
1 change: 1 addition & 0 deletions php/bitmex.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
$query .= '?' . $this->urlencode ($params);
$url = $this->urls['api'] . $query;
if ($api == 'private') {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
if ($method == 'POST')
if ($params)
Expand Down
1 change: 1 addition & 0 deletions php/bitso.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$request = implode ('', array ($nonce, $method, $query));
if ($params) {
Expand Down
8 changes: 6 additions & 2 deletions php/bitstamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public function describe () {
'www' => 'https://www.bitstamp.net',
'doc' => 'https://www.bitstamp.net/api',
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -253,8 +258,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
if (!$this->uid)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.uid` property for authentication');
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$auth = $nonce . $this->uid . $this->apiKey;
$signature = $this->encode ($this->hmac ($this->encode ($auth), $this->encode ($this->secret)));
Expand Down
8 changes: 6 additions & 2 deletions php/bitstamp1.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public function describe () {
'www' => 'https://www.bitstamp.net',
'doc' => 'https://www.bitstamp.net/api',
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -220,8 +225,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
if (!$this->uid)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.uid` property for authentication');
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$auth = $nonce . $this->uid . $this->apiKey;
$signature = $this->encode ($this->hmac ($this->encode ($auth), $this->encode ($this->secret)));
Expand Down
1 change: 1 addition & 0 deletions php/bittrex.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$url .= $api . '/';
if ((($api == 'account') && ($path != 'withdraw')) || ($path == 'openorders'))
Expand Down
1 change: 1 addition & 0 deletions php/bl3p.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$body = $this->urlencode (array_merge (array ( 'nonce' => $nonce ), $query));
$secret = base64_decode ($this->secret);
Expand Down
1 change: 1 addition & 0 deletions php/btcbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$query = array_merge (array (
'key' => $this->apiKey,
Expand Down
5 changes: 1 addition & 4 deletions php/btcchina.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ public function nonce () {
public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$url = $this->urls['api'][$api] . '/' . $path;
if ($api == 'private') {
if (!$this->apiKey)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.apiKey` property for authentication');
if (!$this->secret)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.secret` property for authentication');
$this->check_required_credentials();
$p = array ();
if (array_key_exists ('params', $params))
$p = $params['params'];
Expand Down
1 change: 1 addition & 0 deletions php/btcmarkets.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$auth = $uri . "\n" . $nonce . "\n";
$headers = array (
Expand Down
1 change: 1 addition & 0 deletions php/btctradeua.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= $this->implode_params($path, $query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$body = $this->urlencode (array_merge (array (
'out_order_id' => $nonce,
Expand Down
1 change: 1 addition & 0 deletions php/btcturk.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ().toString;
$body = $this->urlencode ($params);
$secret = $this->base64ToString ($this->secret);
Expand Down
1 change: 1 addition & 0 deletions php/btcx.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($api == 'public') {
$url .= $this->implode_params($path, $params);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$url .= $api;
$body = $this->urlencode (array_merge (array (
Expand Down
1 change: 1 addition & 0 deletions php/bter.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$request = array ( 'nonce' => $nonce );
$body = $this->urlencode (array_merge ($request, $query));
Expand Down
1 change: 1 addition & 0 deletions php/bxinth.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
if ($api == 'private') {
$this->check_required_credentials();
$nonce = $this->nonce ();
$auth = $this->apiKey . (string) $nonce . $this->secret;
$signature = $this->hash ($this->encode ($auth), 'sha256');
Expand Down
1 change: 1 addition & 0 deletions php/ccex.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function cancel_order ($id, $symbol = null, $params = array ()) {
public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$url = $this->urls['api'][$api];
if ($api == 'private') {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$query = $this->keysort (array_merge (array (
'a' => $path,
Expand Down
8 changes: 6 additions & 2 deletions php/cex.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public function describe () {
'www' => 'https://cex.io',
'doc' => 'https://cex.io/cex-api',
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -381,8 +386,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
if (!$this->uid)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.uid` property for authentication');
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$auth = $nonce . $this->uid . $this->apiKey;
$signature = $this->hmac ($this->encode ($auth), $this->encode ($this->secret));
Expand Down
1 change: 1 addition & 0 deletions php/coincheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
if ($query)
$body = $this->urlencode ($this->keysort ($query));
Expand Down
6 changes: 6 additions & 0 deletions php/coinfloor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function describe () {
'https://www.coinfloor.co.uk/api',
),
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -164,6 +169,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$body = $this->urlencode (array_merge (array ( 'nonce' => $nonce ), $query));
$auth = $this->uid . '/' . $this->apiKey . ':' . $this->password;
Expand Down
1 change: 1 addition & 0 deletions php/coingi.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
$this->check_required_credentials();
$nonce = $this->nonce ();
$request = array_merge (array (
'token' => $this->apiKey,
Expand Down
4 changes: 4 additions & 0 deletions php/coinmarketcap.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public function describe () {
'www' => 'https://coinmarketcap.com',
'doc' => 'https://coinmarketcap.com/api',
),
'requiredCredentials' => array (
'apiKey' => false,
'secret' => false,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down
8 changes: 6 additions & 2 deletions php/coinmate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function describe () {
'https://coinmate.io/developers',
),
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -176,8 +181,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
if (!$this->uid)
throw new AuthenticationError ($this->id . ' requires `' . $this->id . '.uid` property for authentication');
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$auth = $nonce . $this->uid . $this->apiKey;
$signature = $this->hmac ($this->encode ($auth), $this->encode ($this->secret));
Expand Down
5 changes: 5 additions & 0 deletions php/coinsecure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function describe () {
'https://github.com/coinsecure/plugins',
),
),
'requiredCredentials' => array (
'apiKey' => true,
'secret' => false,
),
'api' => array (
'public' => array (
'get' => array (
Expand Down Expand Up @@ -261,6 +265,7 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
$url = $this->urls['api'] . '/' . $this->version . '/' . $this->implode_params($path, $params);
$query = $this->omit ($params, $this->extract_params($path));
if ($api == 'private') {
$this->check_required_credentials();
$headers = array ( 'Authorization' => $this->apiKey );
if ($query) {
$body = $this->json ($query);
Expand Down
Loading

0 comments on commit 71918ef

Please sign in to comment.