Skip to content

Commit

Permalink
1.10.538
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Dec 31, 2017
1 parent 4059352 commit 357201e
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 45 deletions.
56 changes: 45 additions & 11 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 errors = require ('./js/base/errors')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.10.537'
const version = '1.10.538'

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.537",
"version": "1.10.538",
"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.537';
$version = '1.10.538';

abstract class Exchange {

Expand Down
52 changes: 43 additions & 9 deletions php/virwox.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,33 @@ public function fetch_ticker ($symbol, $params = array ()) {
);
}

public function parse_trade ($trade, $symbol = null) {
$sec = $this->safe_integer($trade, 'time');
$timestamp = $sec * 1000;
return array (
'id' => $trade['tid'],
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'order' => null,
'symbol' => $symbol,
'type' => null,
'side' => null,
'price' => $this->safe_float($trade, 'price'),
'amount' => $this->safe_float($trade, 'vol'),
'fee' => null,
'info' => $trade,
);
}

public function fetch_trades ($symbol, $since = null, $limit = null, $params = array ()) {
$this->load_markets();
$market = $this->market ($symbol);
return $this->publicGetRawTradeData (array_merge (array (
'instrument' => $market['id'],
$response = $this->publicGetRawTradeData (array_merge (array (
'instrument' => $symbol,
'timespan' => 3600,
), $params));
$result = $response['result'];
$trades = $result['data'];
return $this->parse_trades($trades, $symbol);
}

public function create_order ($market, $type, $side, $amount, $price = null, $params = array ()) {
Expand Down Expand Up @@ -234,11 +254,25 @@ public function sign ($path, $api = 'public', $method = 'GET', $params = array (
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 (is_array ($response) && array_key_exists ('error', $response))
if ($response['error'])
throw new ExchangeError ($this->id . ' ' . $this->json ($response));
return $response;
public function handle_errors ($code, $reason, $url, $method, $headers, $body) {
if ($code == 200) {
if (($body[0] == '{') || ($body[0] == '[')) {
$response = json_decode ($body, $as_associative_array = true);
if (is_array ($response) && array_key_exists ('result', $response)) {
$result = $response['result'];
if (is_array ($result) && array_key_exists ('errorCode', $result)) {
$errorCode = $result['errorCode'];
if ($errorCode != 'OK') {
throw new ExchangeError ($this->id . ' error returned => ' . $body);
}
}
} else {
throw new ExchangeError ($this->id . ' malformed $response => no $result in $response => ' . $body);
}
} else {
// if not a JSON $response
throw new ExchangeError ($this->id . ' returned a non-JSON reply => ' . $body);
}
}
}
}
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.537'
__version__ = '1.10.538'

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

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.537'
__version__ = '1.10.538'

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

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.537'
__version__ = '1.10.538'

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

Expand Down
47 changes: 38 additions & 9 deletions python/ccxt/async/virwox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from ccxt.async.base.exchange import Exchange
import json
from ccxt.base.errors import ExchangeError


Expand Down Expand Up @@ -171,13 +172,32 @@ async def fetch_ticker(self, symbol, params={}):
'info': ticker,
}

def parse_trade(self, trade, symbol=None):
sec = self.safe_integer(trade, 'time')
timestamp = sec * 1000
return {
'id': trade['tid'],
'timestamp': timestamp,
'datetime': self.iso8601(timestamp),
'order': None,
'symbol': symbol,
'type': None,
'side': None,
'price': self.safe_float(trade, 'price'),
'amount': self.safe_float(trade, 'vol'),
'fee': None,
'info': trade,
}

async def fetch_trades(self, symbol, since=None, limit=None, params={}):
await self.load_markets()
market = self.market(symbol)
return await self.publicGetRawTradeData(self.extend({
'instrument': market['id'],
response = await self.publicGetRawTradeData(self.extend({
'instrument': symbol,
'timespan': 3600,
}, params))
result = response['result']
trades = result['data']
return self.parse_trades(trades, symbol)

async def create_order(self, market, type, side, amount, price=None, params={}):
await self.load_markets()
Expand Down Expand Up @@ -222,9 +242,18 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
})
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 'error' in response:
if response['error']:
raise ExchangeError(self.id + ' ' + self.json(response))
return response
def handle_errors(self, code, reason, url, method, headers, body):
if code == 200:
if (body[0] == '{') or (body[0] == '['):
response = json.loads(body)
if 'result' in response:
result = response['result']
if 'errorCode' in result:
errorCode = result['errorCode']
if errorCode != 'OK':
raise ExchangeError(self.id + ' error returned: ' + body)
else:
raise ExchangeError(self.id + ' malformed response: no result in response: ' + body)
else:
# if not a JSON response
raise ExchangeError(self.id + ' returned a non-JSON reply: ' + body)
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.537'
__version__ = '1.10.538'

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

Expand Down
47 changes: 38 additions & 9 deletions python/ccxt/virwox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from ccxt.base.exchange import Exchange
import json
from ccxt.base.errors import ExchangeError


Expand Down Expand Up @@ -171,13 +172,32 @@ def fetch_ticker(self, symbol, params={}):
'info': ticker,
}

def parse_trade(self, trade, symbol=None):
sec = self.safe_integer(trade, 'time')
timestamp = sec * 1000
return {
'id': trade['tid'],
'timestamp': timestamp,
'datetime': self.iso8601(timestamp),
'order': None,
'symbol': symbol,
'type': None,
'side': None,
'price': self.safe_float(trade, 'price'),
'amount': self.safe_float(trade, 'vol'),
'fee': None,
'info': trade,
}

def fetch_trades(self, symbol, since=None, limit=None, params={}):
self.load_markets()
market = self.market(symbol)
return self.publicGetRawTradeData(self.extend({
'instrument': market['id'],
response = self.publicGetRawTradeData(self.extend({
'instrument': symbol,
'timespan': 3600,
}, params))
result = response['result']
trades = result['data']
return self.parse_trades(trades, symbol)

def create_order(self, market, type, side, amount, price=None, params={}):
self.load_markets()
Expand Down Expand Up @@ -222,9 +242,18 @@ def sign(self, path, api='public', method='GET', params={}, headers=None, body=N
})
return {'url': url, 'method': method, 'body': body, 'headers': headers}

def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
response = self.fetch2(path, api, method, params, headers, body)
if 'error' in response:
if response['error']:
raise ExchangeError(self.id + ' ' + self.json(response))
return response
def handle_errors(self, code, reason, url, method, headers, body):
if code == 200:
if (body[0] == '{') or (body[0] == '['):
response = json.loads(body)
if 'result' in response:
result = response['result']
if 'errorCode' in result:
errorCode = result['errorCode']
if errorCode != 'OK':
raise ExchangeError(self.id + ' error returned: ' + body)
else:
raise ExchangeError(self.id + ' malformed response: no result in response: ' + body)
else:
# if not a JSON response
raise ExchangeError(self.id + ' returned a non-JSON reply: ' + body)

0 comments on commit 357201e

Please sign in to comment.