Bug Fixes
This commit is contained in:
1 parent
82bc086e92
commit
b1af6e078c
131 files changed
+8597
-1930
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const log = require ('ololog')
|
||||
, chai = require ('chai')
|
||||
, assert = chai.assert
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
module.exports = (exchange, balance, method) => {
|
||||
|
||||
let currencies = [
|
||||
'USD',
|
||||
'CNY',
|
||||
'EUR',
|
||||
'BTC',
|
||||
'ETH',
|
||||
'JPY',
|
||||
'LTC',
|
||||
'DASH',
|
||||
'DOGE',
|
||||
'UAH',
|
||||
'RUB',
|
||||
'XRP',
|
||||
]
|
||||
|
||||
// log.yellow (balance)
|
||||
|
||||
assert (typeof balance['total'] === 'object')
|
||||
assert (typeof balance['free'] === 'object')
|
||||
assert (typeof balance['used'] === 'object')
|
||||
|
||||
for (let currency of Object.keys (balance['total'])) {
|
||||
let total = balance['total'][currency]
|
||||
let free = balance['free'][currency]
|
||||
let used = balance['used'][currency]
|
||||
if (total !== undefined && free !== undefined && used !== undefined) {
|
||||
assert (total === free + used, 'free and used do not sum to total ' + exchange.id)
|
||||
}
|
||||
}
|
||||
|
||||
let result = currencies
|
||||
.filter (currency => (currency in balance) &&
|
||||
(balance[currency]['total'] !== undefined))
|
||||
|
||||
if (result.length > 0) {
|
||||
result = result.map (currency => currency + ': ' + balance[currency]['total'])
|
||||
if (exchange.currencies.length > result.length)
|
||||
result = result.join (', ') + ' + more...'
|
||||
else
|
||||
result = result.join (', ')
|
||||
|
||||
} else {
|
||||
|
||||
result = 'zero balance'
|
||||
}
|
||||
|
||||
log (result)
|
||||
|
||||
}
|
||||
+7
-62
@@ -2,15 +2,12 @@
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const log = require ('ololog')
|
||||
, ansi = require ('ansicolor').nice
|
||||
, chai = require ('chai')
|
||||
, expect = chai.expect
|
||||
, assert = chai.assert
|
||||
const log = require ('ololog')
|
||||
, testBalance = require ('./test.balance.js')
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
module.exports = async (exchange, symbol) => {
|
||||
module.exports = async (exchange) => {
|
||||
|
||||
if (!(exchange.has.fetchBalance)) {
|
||||
log (exchange.id.green, ' does not have fetchBalance')
|
||||
@@ -19,61 +16,9 @@ module.exports = async (exchange, symbol) => {
|
||||
|
||||
log ('fetching balance...')
|
||||
|
||||
let balance = await exchange.fetchBalance ()
|
||||
const response = await exchange.fetchBalance ()
|
||||
|
||||
let currencies = [
|
||||
'USD',
|
||||
'CNY',
|
||||
'EUR',
|
||||
'BTC',
|
||||
'ETH',
|
||||
'JPY',
|
||||
'LTC',
|
||||
'DASH',
|
||||
'DOGE',
|
||||
'UAH',
|
||||
'RUB',
|
||||
'XRP',
|
||||
]
|
||||
testBalance (exchange, response)
|
||||
|
||||
// log.yellow (balance)
|
||||
|
||||
assert (typeof balance['total'] === 'object')
|
||||
assert (typeof balance['free'] === 'object')
|
||||
assert (typeof balance['used'] === 'object')
|
||||
|
||||
if ('info' in balance) {
|
||||
for (let currency of Object.keys (balance['total'])) {
|
||||
let total = balance['total'][currency]
|
||||
let free = balance['free'][currency]
|
||||
let used = balance['used'][currency]
|
||||
if (total !== undefined && free !== undefined && used !== undefined) {
|
||||
assert (total === free + used, 'free and used do not sum to total ' + exchange.id)
|
||||
}
|
||||
}
|
||||
|
||||
let result = currencies
|
||||
.filter (currency => (currency in balance) &&
|
||||
(balance[currency]['total'] !== undefined))
|
||||
|
||||
if (result.length > 0) {
|
||||
result = result.map (currency => currency + ': ' + balance[currency]['total'])
|
||||
if (exchange.currencies.length > result.length)
|
||||
result = result.join (', ') + ' + more...'
|
||||
else
|
||||
result = result.join (', ')
|
||||
|
||||
} else {
|
||||
|
||||
result = 'zero balance'
|
||||
}
|
||||
|
||||
log (result)
|
||||
|
||||
} else {
|
||||
|
||||
log (exchange.omit (balance, 'info'))
|
||||
}
|
||||
|
||||
return balance
|
||||
return response
|
||||
}
|
||||
+1
@@ -14,6 +14,7 @@ const log = require ('ololog')
|
||||
module.exports = async (exchange, symbol) => {
|
||||
|
||||
const skippedExchanges = [
|
||||
'btcalpha', // issue with 404 on a documented endpoint https://travis-ci.org/ccxt/ccxt/builds/643930431#L2213
|
||||
'bitmex', // an issue with null values,to be resolved later
|
||||
'cex',
|
||||
'okex',
|
||||
|
||||
+3
-5
@@ -17,11 +17,9 @@ const printOrderBookOneLiner = (orderbook, method, symbol) => {
|
||||
|
||||
log (symbol.toString ().green,
|
||||
method,
|
||||
orderbook['datetime'],
|
||||
'bid: ' + ((bids.length > 0) ? bids[0][0] : 'N/A'),
|
||||
'bidVolume: ' + ((bids.length > 0) ? bids[0][1] : 'N/A'),
|
||||
'ask: ' + ((asks.length > 0) ? asks[0][0] : 'N/A'),
|
||||
'askVolume: ' + ((asks.length > 0) ? asks[0][1] : 'N/A'))
|
||||
orderbook['nonce'] || orderbook['datetime'],
|
||||
bids.length, 'bids:', bids[0],
|
||||
asks.length, 'asks:', asks[0])
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ module.exports = (exchange, ticker, method, symbol) => {
|
||||
assert (!('first' in ticker), '`first` field leftover in ' + exchange.id)
|
||||
assert (ticker['last'] === ticker['close'], '`last` != `close` in ' + exchange.id)
|
||||
|
||||
// log (ticker)
|
||||
log (ticker['datetime'], exchange.id, method, ticker['symbol'].green, ticker['last'])
|
||||
|
||||
keys.forEach (key => assert (key in ticker))
|
||||
|
||||
|
||||
Reference in new issue
Block a user