Skip to content

Commit

Permalink
1.10.1213
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Feb 26, 2018
1 parent 749fec9 commit 1da5221
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 33 deletions.
63 changes: 55 additions & 8 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.1212'
const version = '1.10.1213'

Exchange.ccxtVersion = version

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.10.1212",
"version": "1.10.1213",
"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.1212';
$version = '1.10.1213';

abstract class Exchange {

Expand Down
52 changes: 46 additions & 6 deletions php/btcmarkets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function describe () {
'rateLimit' => 1000, // market data cached for 1 second (trades cached for 2 seconds)
'has' => array (
'CORS' => false,
'fetchOHLCV' => true,
'fetchOrder' => true,
'fetchOrders' => true,
'fetchClosedOrders' => 'emulated',
Expand All @@ -23,7 +24,11 @@ public function describe () {
),
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/29142911-0e1acfc2-7d5c-11e7-98c4-07d9532b29d7.jpg',
'api' => 'https://api.btcmarkets.net',
'api' => array (
'public' => 'https://api.btcmarkets.net',
'private' => 'https://api.btcmarkets.net',
'web' => 'https://btcmarkets.net/data',
),
'www' => 'https://btcmarkets.net/',
'doc' => 'https://github.com/BTCMarkets/API',
),
Expand Down Expand Up @@ -52,6 +57,11 @@ public function describe () {
'order/detail',
),
),
'web' => array (
'get' => array (
'market/BTCMarkets/{id}/tickByTime',
),
),
),
'markets' => array (
'BTC/AUD' => array ( 'id' => 'BTC/AUD', 'symbol' => 'BTC/AUD', 'base' => 'BTC', 'quote' => 'AUD', 'maker' => 0.0085, 'taker' => 0.0085, 'limits' => array ( 'amount' => array ( 'min' => 0.001, 'max' => null )), 'precision' => array ( 'price' => 2 )),
Expand All @@ -66,6 +76,11 @@ public function describe () {
'XRP/BTC' => array ( 'id' => 'XRP/BTC', 'symbol' => 'XRP/BTC', 'base' => 'XRP', 'quote' => 'BTC', 'maker' => 0.0022, 'taker' => 0.0022, 'limits' => array ( 'amount' => array ( 'min' => 0.001, 'max' => null ))),
'BCH/BTC' => array ( 'id' => 'BCH/BTC', 'symbol' => 'BCH/BTC', 'base' => 'BCH', 'quote' => 'BTC', 'maker' => 0.0022, 'taker' => 0.0022, 'limits' => array ( 'amount' => array ( 'min' => 0.001, 'max' => null ))),
),
'timeframes' => array (
'1m' => 'minute',
'1h' => 'hour',
'1d' => 'day',
),
'exceptions' => array (
'3' => '\\ccxt\\InvalidOrder',
'6' => '\\ccxt\\DDoSProtection',
Expand Down Expand Up @@ -94,6 +109,31 @@ public function fetch_balance ($params = array ()) {
return $this->parse_balance($result);
}

public function parse_ohlcv ($ohlcv, $market = null, $timeframe = '1m', $since = null, $limit = null) {
$multiplier = 100000000; // for price and volume
return [
$ohlcv[0],
floatval ($ohlcv[1]) / $multiplier,
floatval ($ohlcv[2]) / $multiplier,
floatval ($ohlcv[3]) / $multiplier,
floatval ($ohlcv[4]) / $multiplier,
floatval ($ohlcv[5]) / $multiplier,
];
}

public function fetch_ohlcv ($symbol, $timeframe = '1m', $since = null, $limit = null, $params = array ()) {
$this->load_markets ();
$market = $this->market ($symbol);
$request = array (
'id' => $market['id'],
'timeWindow' => $this->timeframes[$timeframe],
);
if ($since !== null)
$request['since'] = $since;
$response = $this->webGetMarketBTCMarketsIdTickByTime (array_merge ($request, $params));
return $this->parse_ohlcvs($response['ticks'], $market, $timeframe, $since, $limit);
}

public function fetch_order_book ($symbol, $limit = null, $params = array ()) {
$this->load_markets();
$market = $this->market ($symbol);
Expand Down Expand Up @@ -344,11 +384,8 @@ public function nonce () {

public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$uri = '/' . $this->implode_params($path, $params);
$url = $this->urls['api'] . $uri;
if ($api === 'public') {
if ($params)
$url .= '?' . $this->urlencode ($params);
} else {
$url = $this->urls['api'][$api] . $uri;
if ($api === 'private') {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
// eslint-disable-next-line quotes
Expand All @@ -365,6 +402,9 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
$secret = base64_decode ($this->secret);
$signature = $this->hmac ($this->encode ($auth), $secret, 'sha512', 'base64');
$headers['signature'] = $this->decode ($signature);
} else {
if ($params)
$url .= '?' . $this->urlencode ($params);
}
return array ( 'url' => $url, 'method' => $method, 'body' => $body, 'headers' => $headers );
}
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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

__version__ = '1.10.1212'
__version__ = '1.10.1213'

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

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

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

__version__ = '1.10.1212'
__version__ = '1.10.1213'

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

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

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

__version__ = '1.10.1212'
__version__ = '1.10.1213'

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

Expand Down
50 changes: 44 additions & 6 deletions python/ccxt/async/btcmarkets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def describe(self):
'rateLimit': 1000, # market data cached for 1 second(trades cached for 2 seconds)
'has': {
'CORS': False,
'fetchOHLCV': True,
'fetchOrder': True,
'fetchOrders': True,
'fetchClosedOrders': 'emulated',
Expand All @@ -32,7 +33,11 @@ def describe(self):
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/29142911-0e1acfc2-7d5c-11e7-98c4-07d9532b29d7.jpg',
'api': 'https://api.btcmarkets.net',
'api': {
'public': 'https://api.btcmarkets.net',
'private': 'https://api.btcmarkets.net',
'web': 'https://btcmarkets.net/data',
},
'www': 'https://btcmarkets.net/',
'doc': 'https://github.com/BTCMarkets/API',
},
Expand Down Expand Up @@ -61,6 +66,11 @@ def describe(self):
'order/detail',
],
},
'web': {
'get': [
'market/BTCMarkets/{id}/tickByTime',
],
},
},
'markets': {
'BTC/AUD': {'id': 'BTC/AUD', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'maker': 0.0085, 'taker': 0.0085, 'limits': {'amount': {'min': 0.001, 'max': None}}, 'precision': {'price': 2}},
Expand All @@ -75,6 +85,11 @@ def describe(self):
'XRP/BTC': {'id': 'XRP/BTC', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'maker': 0.0022, 'taker': 0.0022, 'limits': {'amount': {'min': 0.001, 'max': None}}},
'BCH/BTC': {'id': 'BCH/BTC', 'symbol': 'BCH/BTC', 'base': 'BCH', 'quote': 'BTC', 'maker': 0.0022, 'taker': 0.0022, 'limits': {'amount': {'min': 0.001, 'max': None}}},
},
'timeframes': {
'1m': 'minute',
'1h': 'hour',
'1d': 'day',
},
'exceptions': {
'3': InvalidOrder,
'6': DDoSProtection,
Expand All @@ -100,6 +115,29 @@ async def fetch_balance(self, params={}):
result[currency] = account
return self.parse_balance(result)

def parse_ohlcv(self, ohlcv, market=None, timeframe='1m', since=None, limit=None):
multiplier = 100000000 # for price and volume
return [
ohlcv[0],
float(ohlcv[1]) / multiplier,
float(ohlcv[2]) / multiplier,
float(ohlcv[3]) / multiplier,
float(ohlcv[4]) / multiplier,
float(ohlcv[5]) / multiplier,
]

async def fetch_ohlcv(self, symbol, timeframe='1m', since=None, limit=None, params={}):
await self.load_markets()
market = self.market(symbol)
request = {
'id': market['id'],
'timeWindow': self.timeframes[timeframe],
}
if since is not None:
request['since'] = since
response = await self.webGetMarketBTCMarketsIdTickByTime(self.extend(request, params))
return self.parse_ohlcvs(response['ticks'], market, timeframe, since, limit)

async def fetch_order_book(self, symbol, limit=None, params={}):
await self.load_markets()
market = self.market(symbol)
Expand Down Expand Up @@ -328,11 +366,8 @@ def nonce(self):

def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
uri = '/' + self.implode_params(path, params)
url = self.urls['api'] + uri
if api == 'public':
if params:
url += '?' + self.urlencode(params)
else:
url = self.urls['api'][api] + uri
if api == 'private':
self.check_required_credentials()
nonce = str(self.nonce())
# eslint-disable-next-line quotes
Expand All @@ -348,6 +383,9 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
secret = base64.b64decode(self.secret)
signature = self.hmac(self.encode(auth), secret, hashlib.sha512, 'base64')
headers['signature'] = self.decode(signature)
else:
if params:
url += '?' + self.urlencode(params)
return {'url': url, 'method': method, 'body': body, 'headers': headers}

def handle_errors(self, code, reason, url, method, headers, body):
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.10.1212'
__version__ = '1.10.1213'

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

Expand Down
50 changes: 44 additions & 6 deletions python/ccxt/btcmarkets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def describe(self):
'rateLimit': 1000, # market data cached for 1 second(trades cached for 2 seconds)
'has': {
'CORS': False,
'fetchOHLCV': True,
'fetchOrder': True,
'fetchOrders': True,
'fetchClosedOrders': 'emulated',
Expand All @@ -32,7 +33,11 @@ def describe(self):
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/29142911-0e1acfc2-7d5c-11e7-98c4-07d9532b29d7.jpg',
'api': 'https://api.btcmarkets.net',
'api': {
'public': 'https://api.btcmarkets.net',
'private': 'https://api.btcmarkets.net',
'web': 'https://btcmarkets.net/data',
},
'www': 'https://btcmarkets.net/',
'doc': 'https://github.com/BTCMarkets/API',
},
Expand Down Expand Up @@ -61,6 +66,11 @@ def describe(self):
'order/detail',
],
},
'web': {
'get': [
'market/BTCMarkets/{id}/tickByTime',
],
},
},
'markets': {
'BTC/AUD': {'id': 'BTC/AUD', 'symbol': 'BTC/AUD', 'base': 'BTC', 'quote': 'AUD', 'maker': 0.0085, 'taker': 0.0085, 'limits': {'amount': {'min': 0.001, 'max': None}}, 'precision': {'price': 2}},
Expand All @@ -75,6 +85,11 @@ def describe(self):
'XRP/BTC': {'id': 'XRP/BTC', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'maker': 0.0022, 'taker': 0.0022, 'limits': {'amount': {'min': 0.001, 'max': None}}},
'BCH/BTC': {'id': 'BCH/BTC', 'symbol': 'BCH/BTC', 'base': 'BCH', 'quote': 'BTC', 'maker': 0.0022, 'taker': 0.0022, 'limits': {'amount': {'min': 0.001, 'max': None}}},
},
'timeframes': {
'1m': 'minute',
'1h': 'hour',
'1d': 'day',
},
'exceptions': {
'3': InvalidOrder,
'6': DDoSProtection,
Expand All @@ -100,6 +115,29 @@ def fetch_balance(self, params={}):
result[currency] = account
return self.parse_balance(result)

def parse_ohlcv(self, ohlcv, market=None, timeframe='1m', since=None, limit=None):
multiplier = 100000000 # for price and volume
return [
ohlcv[0],
float(ohlcv[1]) / multiplier,
float(ohlcv[2]) / multiplier,
float(ohlcv[3]) / multiplier,
float(ohlcv[4]) / multiplier,
float(ohlcv[5]) / multiplier,
]

def fetch_ohlcv(self, symbol, timeframe='1m', since=None, limit=None, params={}):
self.load_markets()
market = self.market(symbol)
request = {
'id': market['id'],
'timeWindow': self.timeframes[timeframe],
}
if since is not None:
request['since'] = since
response = self.webGetMarketBTCMarketsIdTickByTime(self.extend(request, params))
return self.parse_ohlcvs(response['ticks'], market, timeframe, since, limit)

def fetch_order_book(self, symbol, limit=None, params={}):
self.load_markets()
market = self.market(symbol)
Expand Down Expand Up @@ -328,11 +366,8 @@ def nonce(self):

def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
uri = '/' + self.implode_params(path, params)
url = self.urls['api'] + uri
if api == 'public':
if params:
url += '?' + self.urlencode(params)
else:
url = self.urls['api'][api] + uri
if api == 'private':
self.check_required_credentials()
nonce = str(self.nonce())
# eslint-disable-next-line quotes
Expand All @@ -348,6 +383,9 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
secret = base64.b64decode(self.secret)
signature = self.hmac(self.encode(auth), secret, hashlib.sha512, 'base64')
headers['signature'] = self.decode(signature)
else:
if params:
url += '?' + self.urlencode(params)
return {'url': url, 'method': method, 'body': body, 'headers': headers}

def handle_errors(self, code, reason, url, method, headers, body):
Expand Down

0 comments on commit 1da5221

Please sign in to comment.