Skip to content

Commit

Permalink
unified bitc2 balance
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Jul 21, 2017
1 parent ae717c1 commit 3a47690
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ccxt.es5.js

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//-----------------------------------------------------------------------------

var version = '1.1.10'
var version = '1.1.11'
var isNode = (typeof window === 'undefined')

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -983,7 +983,7 @@ var anxpro = {
},

async fetchBalance () {
let response = await this.privatePostMoneyInfo ();
let response = await this.privatePostMoneyInfo ();
let balance = response['data'];
let currencies = Object.keys (balance['Wallets']);
let result = { 'info': balance };
Expand Down Expand Up @@ -1156,8 +1156,24 @@ var bit2c = {
'LTC/NIS': { 'id': 'LtcNis', 'symbol': 'LTC/NIS', 'base': 'LTC', 'quote': 'NIS' },
},

fetchBalance () {
return this.privatePostAccountBalanceV2 ();
async fetchBalance () {
let balance = await this.privatePostAccountBalanceV2 ();
let result = { 'info': balance };
for (let c = 0; c < this.currencies.length; c++) {
let currency = this.currencies[c];
let account = {
'free': undefined,
'used': undefined,
};
if (currency in balance) {
let available = 'AVAILABLE_' + currency;
account['free'] = balance[available];
account['total'] = balance[currency];
account['used'] = account['total'] - account['free'];
}
result[currency] = account;
}
return result;
},

async fetchOrderBook (product) {
Expand Down
19 changes: 6 additions & 13 deletions ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class EndpointNotAvailableError extends NotAvailableError {}
class OrderBookNotAvailableError extends NotAvailableError {}
class TickerNotAvailableError extends NotAvailableError {}

$version = '1.1.10';

class Market {

public static $markets = array (
Expand Down Expand Up @@ -323,18 +325,9 @@ public function jwt ($request, $secret, $alg = 'HS256', $hash = 'sha256') {
}

public function fetch ($url, $method = 'GET', $headers = null, $body = null) {

/*
try {
return JSON.parse (response)
} catch (e) {
var cloudflareProtection = response.match (/cloudflare/i) ? 'DDoS protection by Cloudflare' : ''
if ($this->verbose)
console.log ($this->id, response, cloudflareProtection, e)
throw e
}
*/


global $version;

if (strlen ($this->proxy))
$headers['Origin'] = '*';

Expand Down Expand Up @@ -362,7 +355,7 @@ public function fetch ($url, $method = 'GET', $headers = null, $body = null) {
curl_setopt ($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($this->curl, CURLOPT_SSL_VERIFYPEER, false);

$userAgent = 'ccxt/0.1.0 (+https://github.com/kroitor/ccxt) PHP/' . PHP_VERSION;
$userAgent = 'ccxt/' . $version . ' (+https://github.com/kroitor/ccxt) PHP/' . PHP_VERSION;
curl_setopt ($this->curl, CURLOPT_USERAGENT, $userAgent);

curl_setopt ($this->curl, CURLOPT_ENCODING, '');
Expand Down
2 changes: 1 addition & 1 deletion ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'TickerNotAvailableError',
]

__version__ = '1.1.10'
__version__ = '1.1.11'

# Python 2 & 3
import base64
Expand Down
26 changes: 19 additions & 7 deletions vss.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ console.log ('New version: ', version)

//-----------------------------------------------------------------------------

console.log ('Single-sourcing version', version, './package.json → ./ccxt.js')
let ccxtjsFilename = './ccxt.js'
let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8')
let ccxtjsParts = ccxtjs.split (/var version \= \'[^\']+\'/)
let ccxtjsNewContent = ccxtjsParts[0] + "var version = '" + version + "'" + ccxtjsParts[1]
fs.truncateSync (ccxtjsFilename)
fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent)
console.log ('Done.')

//-----------------------------------------------------------------------------

console.log ('Single-sourcing version', version, './package.json → ./ccxt/__init__.py')
let ccxtpyFilename = './ccxt/__init__.py'
let ccxtpy = fs.readFileSync (ccxtpyFilename, 'utf8')
Expand All @@ -33,13 +44,14 @@ console.log ('Done.')

//-----------------------------------------------------------------------------

console.log ('Single-sourcing version', version, './package.json → ./ccxt.js')
let ccxtjsFilename = './ccxt.js'
let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8')
let ccxtjsParts = ccxtjs.split (/var version \= \'[^\']+\'/)
let ccxtjsNewContent = ccxtjsParts[0] + "var version = '" + version + "'" + ccxtjsParts[1]
fs.truncateSync (ccxtjsFilename)
fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent)
console.log ('Single-sourcing version', version, './package.json → ./ccxt.php')
let ccxtphpFilename = './ccxt.php'
let ccxtphp = fs.readFileSync (ccxtphpFilename, 'utf8')
let ccxtphpParts = ccxtphp.split (/\$version \= \'[^\']+\'/)
let ccxtphpNewContent = ccxtphpParts[0] + '$version' + " = '" + version + "'" + ccxtphpParts[1]
console.log (ccxtphpNewContent)
// fs.truncateSync (ccxtphpFilename)
// fs.writeFileSync (ccxtphpFilename, ccxtphpNewContent)
console.log ('Done.')

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 3a47690

Please sign in to comment.