UNPKG

sfccxt

Version:

A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges

42 lines (34 loc) 1.09 kB
'use strict' // ---------------------------------------------------------------------------- const assert = require ('assert') // ---------------------------------------------------------------------------- module.exports = (exchange, balance, method) => { const currencies = [ 'USD', 'USDT', 'CNY', 'EUR', 'BTC', 'ETH', 'JPY', 'LTC', 'DASH', 'DOGE', 'UAH', 'RUB', 'XRP', ] assert (typeof balance['total'] === 'object') assert (typeof balance['free'] === 'object') assert (typeof balance['used'] === 'object') const codes = Object.keys (balance['total']) for (let i = 0; i < codes.length; i++) { const code = codes[i] const total = balance['total'][code] const free = balance['free'][code] const used = balance['used'][code] if ((total !== undefined) && (free !== undefined) && (used !== undefined)) { assert (total === free + used, 'free and used do not sum to total ' + exchange.id) } } }