Estatísticas de financiamento

Autora:Número: louco, Data: 28/12/2015 21:41:45
Tags:Ferramenta

Usando o recurso de API de uma bolsa para mostrar a situação atual de financiamento de uma bolsa (não reembolsado, incluindo taxas de processamento). Atualmente, apenas OKCoin e tokens são suportados, bem-vindo a continuar a melhorar. O site também tem uma rede de blogs e blogs.


function getLoanInfo(exchange, type) {
    var loanInfo;
    var dueAmount;
    if (exchange.GetName() == "OKCoin") { 
        loanInfo = exchange.IO("api", "borrows_info", "symbol=cny");
        if (type == "btc") {
            dueAmount = loanInfo.borrow_btc + loanInfo.interest_btc;
        }
        else if (type == "ltc") {
            dueAmount = loanInfo.borrow_ltc + loanInfo.interest_ltc;
        }   
        else if (type == "cny") {
            dueAmount = loanInfo.borrow_cny + loanInfo.interest_cny;
        }
    }
    else if (exchange.GetName() == "Huobi") {
        loanInfo = exchange.IO("api", "get_loans", "market=cny");
        dueAmount = 0;
            for (var i = 0; i < loanInfo.length; i++) {
                if (type == "cny" && loanInfo[i].type == 1 || type == "btc" && loanInfo[i].type == 2 || type == "ltc" && loanInfo[i].type == 3) {
                    dueAmount += (Number(loanInfo[i].loan_amount) - Number(loanInfo[i].repayment_amount) + Number(loanInfo[i].interest_nopay) + Number(loanInfo[i].interest_payed));
                }
            }
    }
    else 
        throw "暂不支持交易所: " + exchange.GetName();
    return dueAmount;
}

function main() {
    for (var i = 0; i < exchanges.length; i++)
        Log(exchanges[i].GetName(),
            "未归还CNY:", getLoanInfo(exchanges[i], "cny"),
            "未归还BTC:", getLoanInfo(exchanges[i], "btc"),
            "未归还LTC:", getLoanInfo(exchanges[i], "ltc")
           );
}

Relacionados

Mais.

Minha filhaObrigado por compartilhar.

O que é?Onde está o mais recente API? Eu não encontrei o get_loans API em https://www.okcoin.cn/about/rest_api.do?

Número: loucoOK é borrows_info get_loans é a API do token