La précision des pièces

Auteur:Un coup de poing pour un garçon, Date: le 26 septembre 2019 à 15h06h23
Les étiquettes:Outil

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

Précision du comptage des transactions pour les devises de base (numéros après le point de départ) Retourne le type de valeur number

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

La précision de la transaction par rapport à l'offre (numéros après le comma) Retourne le type de valeur number

  • $.getMinOrderAmount (monnaie)

Traiter le plus petit volume Retourne le type de valeur number

  • $.getMaxOrderAmount (monnaie)

Les transactions pour le plus grand nombre de commandes Retourne le type de valeur number

  • $.getValuePrecision (monnaie)

Précision de la transaction par montant de la transaction (numéros après le comma) Retourne le type de valeur number

  • $.getMinValue (monnaie)

Le montant minimum de la commande (le montant de la commande est le montant transmis par l'interface lorsque le type de commande est un ordre à prix limité); le montant du colis transmis par l'interface lorsque le type de commande est un ordre buy-market) Retourne le type de valeur 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
}


Relationnée

Plus de