Skip to content

Commit

Permalink
1.14.72
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed May 26, 2018
1 parent 249861f commit 580d2b0
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 33 deletions.
75 changes: 67 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.14.71'
const version = '1.14.72'

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.14.71",
"version": "1.14.72",
"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.71';
$version = '1.14.72';

// rounding mode
const TRUNCATE = 0;
Expand Down
71 changes: 65 additions & 6 deletions php/cryptopia.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function describe () {
'fetchCurrencies' => true,
'fetchDepositAddress' => true,
'fetchMyTrades' => true,
'fetchOHLCV' => true,
'fetchOrder' => 'emulated',
'fetchOrderBooks' => true,
'fetchOrders' => 'emulated',
Expand All @@ -32,7 +33,11 @@ public function describe () {
),
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/29484394-7b4ea6e2-84c6-11e7-83e5-1fccf4b2dc81.jpg',
'api' => 'https://www.cryptopia.co.nz/api',
'api' => array (
'public' => 'https://www.cryptopia.co.nz/api',
'private' => 'https://www.cryptopia.co.nz/api',
'web' => 'https://www.cryptopia.co.nz',
),
'www' => 'https://www.cryptopia.co.nz',
'referral' => 'https://www.cryptopia.co.nz/Register?referrer=kroitor',
'doc' => array (
Expand All @@ -41,7 +46,22 @@ public function describe () {
'https://www.cryptopia.co.nz/Forum/Thread/256',
),
),
'timeframes' => array (
'15m' => 15,
'30m' => 30,
'1h' => 60,
'2h' => 120,
'4h' => 240,
'12h' => 720,
'1d' => 1440,
'1w' => 10080,
),
'api' => array (
'web' => array (
'get' => array (
'Exchange/GetTradePairChart',
),
),
'public' => array (
'get' => array (
'GetCurrencies',
Expand Down Expand Up @@ -164,6 +184,43 @@ public function fetch_order_book ($symbol, $limit = null, $params = array ()) {
return $this->parse_order_book($orderbook, null, 'Buy', 'Sell', 'Price', 'Volume');
}

public function fetch_ohlcv ($symbol, $timeframe = '15m', $since = null, $limit = null, $params = array ()) {
$dataRange = 0;
if ($since !== null) {
$dataRanges = array (
86400,
172800,
604800,
1209600,
2592000,
7776000,
15552000,
);
$numDataRanges = is_array ($dataRanges) ? count ($dataRanges) : 0;
$now = $this->seconds ();
$sinceSeconds = intval ($since / 1000);
for ($i = 1; $i < $numDataRanges; $i++) {
if (($now - $sinceSeconds) > $dataRanges[$i]) {
$dataRange = $i;
}
}
}
$this->load_markets();
$market = $this->market ($symbol);
$request = array (
'tradePairId' => $market['id'],
'dataRange' => $dataRange,
'dataGroup' => $this->timeframes[$timeframe],
);
$response = $this->webGetExchangeGetTradePairChart (array_merge ($request, $params));
$candles = $response['Candle'];
$volumes = $response['Volume'];
for ($i = 0; $i < count ($candles); $i++) {
$candles[$i][] = $volumes[$i]['basev'];
}
return $this->parse_ohlcvs($candles, $market, $timeframe, $since, $limit);
}

public function join_market_ids ($ids, $glue = '-') {
$result = (string) $ids[0];
for ($i = 1; $i < count ($ids); $i++) {
Expand Down Expand Up @@ -647,12 +704,9 @@ public function withdraw ($code, $amount, $address, $tag = null, $params = array
}

public function sign ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$url = $this->urls['api'] . '/' . $this->implode_params($path, $params);
$url = $this->urls['api'][$api] . '/' . $this->implode_params($path, $params);
$query = $this->omit ($params, $this->extract_params($path));
if ($api === 'public') {
if ($query)
$url .= '?' . $this->urlencode ($query);
} else {
if ($api === 'private') {
$this->check_required_credentials();
$nonce = (string) $this->nonce ();
$body = $this->json ($query, array ( 'convertArraysToObjects' => true ));
Expand All @@ -668,12 +722,17 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
'Content-Type' => 'application/json',
'Authorization' => $auth,
);
} else {
if ($query)
$url .= '?' . $this->urlencode ($query);
}
return array ( 'url' => $url, 'method' => $method, 'body' => $body, 'headers' => $headers );
}

public function request ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$response = $this->fetch2 ($path, $api, $method, $params, $headers, $body);
if ($api === 'web')
return $response;
if ($response) {
if (is_array ($response) && array_key_exists ('Success', $response))
if ($response['Success']) {
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.14.71'
__version__ = '1.14.72'

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

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.14.71'
__version__ = '1.14.72'

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

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.14.71'
__version__ = '1.14.72'

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

Expand Down
66 changes: 60 additions & 6 deletions python/ccxt/async/cryptopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def describe(self):
'fetchCurrencies': True,
'fetchDepositAddress': True,
'fetchMyTrades': True,
'fetchOHLCV': True,
'fetchOrder': 'emulated',
'fetchOrderBooks': True,
'fetchOrders': 'emulated',
Expand All @@ -38,7 +39,11 @@ def describe(self):
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/29484394-7b4ea6e2-84c6-11e7-83e5-1fccf4b2dc81.jpg',
'api': 'https://www.cryptopia.co.nz/api',
'api': {
'public': 'https://www.cryptopia.co.nz/api',
'private': 'https://www.cryptopia.co.nz/api',
'web': 'https://www.cryptopia.co.nz',
},
'www': 'https://www.cryptopia.co.nz',
'referral': 'https://www.cryptopia.co.nz/Register?referrer=kroitor',
'doc': [
Expand All @@ -47,7 +52,22 @@ def describe(self):
'https://www.cryptopia.co.nz/Forum/Thread/256',
],
},
'timeframes': {
'15m': 15,
'30m': 30,
'1h': 60,
'2h': 120,
'4h': 240,
'12h': 720,
'1d': 1440,
'1w': 10080,
},
'api': {
'web': {
'get': [
'Exchange/GetTradePairChart',
],
},
'public': {
'get': [
'GetCurrencies',
Expand Down Expand Up @@ -166,6 +186,38 @@ async def fetch_order_book(self, symbol, limit=None, params={}):
orderbook = response['Data']
return self.parse_order_book(orderbook, None, 'Buy', 'Sell', 'Price', 'Volume')

async def fetch_ohlcv(self, symbol, timeframe='15m', since=None, limit=None, params={}):
dataRange = 0
if since is not None:
dataRanges = [
86400,
172800,
604800,
1209600,
2592000,
7776000,
15552000,
]
numDataRanges = len(dataRanges)
now = self.seconds()
sinceSeconds = int(since / 1000)
for i in range(1, numDataRanges):
if (now - sinceSeconds) > dataRanges[i]:
dataRange = i
await self.load_markets()
market = self.market(symbol)
request = {
'tradePairId': market['id'],
'dataRange': dataRange,
'dataGroup': self.timeframes[timeframe],
}
response = await self.webGetExchangeGetTradePairChart(self.extend(request, params))
candles = response['Candle']
volumes = response['Volume']
for i in range(0, len(candles)):
candles[i].append(volumes[i]['basev'])
return self.parse_ohlcvs(candles, market, timeframe, since, limit)

def join_market_ids(self, ids, glue='-'):
result = str(ids[0])
for i in range(1, len(ids)):
Expand Down Expand Up @@ -595,12 +647,9 @@ async def withdraw(self, code, amount, address, tag=None, params={}):
}

def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
url = self.urls['api'] + '/' + self.implode_params(path, params)
url = self.urls['api'][api] + '/' + self.implode_params(path, params)
query = self.omit(params, self.extract_params(path))
if api == 'public':
if query:
url += '?' + self.urlencode(query)
else:
if api == 'private':
self.check_required_credentials()
nonce = str(self.nonce())
body = self.json(query, {'convertArraysToObjects': True})
Expand All @@ -616,10 +665,15 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
'Content-Type': 'application/json',
'Authorization': auth,
}
else:
if query:
url += '?' + self.urlencode(query)
return {'url': url, 'method': method, 'body': body, 'headers': headers}

async def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
response = await self.fetch2(path, api, method, params, headers, body)
if api == 'web':
return response
if response:
if 'Success' in response:
if response['Success']:
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.14.71'
__version__ = '1.14.72'

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

Expand Down

0 comments on commit 580d2b0

Please sign in to comment.