Precisión de las monedas

El autor:Un chico con un puñetazo, Fecha: 2019-07-26 15:06:23
Las etiquetas:Herramienta

  • ...................

Precisión del conteo de transacciones con monedas base (número de dígitos después de decimal) Devuelve el tipo de valor number

  • . GetPricePrecisión (moneda)

Precisión de la transacción con respecto a las ofertas (digitos después del decimal) Devuelve el tipo de valor number

  • $.getMinOrderAmount ((Moneda)

Negociación para el mínimo pedido Devuelve el tipo de valor number

  • $.getMaxOrderAmount ((Moneda)

Negociación para la mayor cantidad de pedidos Devuelve el tipo de valor number

  • $.getValuePrecision (Moneda)

Precisión de la transacción por el monto de la transacción (los dígitos después del decimal) Devuelve el tipo de valor number

  • $.getMinValue ((Moneda)

El importe mínimo de la orden (el importe de la orden se refiere a la cantidad que se transmite por la interfaz de la orden cuando el tipo de orden es un pedido de precio limitado; el monto que se transmite por la interfaz de la orden cuando el tipo de orden es buy-market) Devuelve el tipo de valor number


var _symbols = _C(getSymbols)
var _cacheTicker = {}

function parseJson(str) {
    try {
        return JSON.parse(str)
    } catch(e) {
        Log(str + e.message + '#FF0000')
        return null
    }
}

function getSymbols() {
    var ret = parseJson(HttpQuery('https://api.huobi.pro/v1/common/symbols'))
    if (ret && ret.status === 'ok') {
        return ret.data
    } else {
        return null
    }
}

function getTicker(ex) {
    var currency = getCurreny(ex)
    if (_cacheTicker[currency] && Unix() - _cacheTicker[currency].UpdatedAt < TICKER_EXPIRE_TIME) {
        return _cacheTicker[currency]
    }
    var sym = currency.replace('_', '').toLocaleLowerCase()
    var ret = parseJson(HttpQuery('https://api.huobi.pro/market/detail/merged?symbol=' + sym))
    if (ret && ret.status === 'ok') {
        _cacheTicker[currency] = _.extend({ UpdatedAt: Unix() }, ret.tick)
        return ret.data
    } else {
        return null
    }
}

function getCurreny(ex) {
    var currency = null
    if (typeof(ex) === 'object') {
        return ex.GetCurrency()
    } else {
        return ex
    }
}

function getCoin(ex) {
    var currency = getCurreny(ex)
    var currencyAry = _.map(currency.split('_'), function(sym) { return sym.toLocaleLowerCase() })
    return _.find(_symbols, function(coin) {
        return currencyAry[0] === coin['base-currency'] && currencyAry[1] === coin['quote-currency']
    })
}

$.getSymbols = getSymbols

$.getAmountPrecision = function (ex) {
    var coin = getCoin(ex)
    if (coin) {
        return coin['amount-precision']
    }
    return 0
}

$.getPricePrecision = function(ex) {
    var coin = getCoin(ex)
    if (coin) {
        return coin['price-precision']
    }
    return 0
}

$.getMinOrderAmount = function(ex, price) {
    var coin = getCoin(ex)
    if (coin) {
        price = price || _C(getTicker, ex).close
        return +(new Decimal(coin['min-order-value']).mul(1.1).div(price).toFixed($.getAmountPrecision(ex), Decimal.ROUND_CEIL))
    }
    return 0
}

$.getMaxOrderAmount = function(ex) {
    var coin = getCoin(ex)
    if (coin) {
        return coin['max-order-amt']
    }
    return 0
}

$.getValuePrecision = function(ex) {
    var coin = getCoin(ex)
    if (coin) {
        return coin['value-precision']
    }
    return 0
}

$.getMinValue = function(ex) {
    var coin = getCoin(ex)
    if (coin) {
        return coin['min-order-value']
    }
    return 0
}


Relacionados

Más.