The resource loading... loading...

Get the real-time price of the OK futures

Author: The number is crazy., Date: 2016-06-19 00:56:00
Tags: Tool

Get the real-time price limit of OK futures, valid only in real time. The code is for learning purposes only, the author does not guarantee the correctness of the program, according to which the transaction consequences are assumed.


$.GetLimit = function(currStr, contract) {
    var url = "https://www.okcoin.com/api/v1/future_price_limit.do?symbol=" + currStr + "_usd&contract_type=" + contract;
    var httpResp = HttpQuery(url);
    if (httpResp.indexOf("false") != -1) return null;
    var parsedResp;
    try {
        parsedResp = JSON.parse(httpResp);
    } catch (e) {
        return null;
    }
    return parsedResp;
};

function main() {
    var limit = $.GetLimit('btc', 'quarter'); // 获取 比特币 季度 合约限价
    Log(limit.high, limit.low); // 最高买入、最低卖出限价
    limit = $.GetLimit('ltc', 'this_week'); // 获取 莱特币 当周 合约限价
    Log(limit.high, limit.low); // 最高买入、最低卖出限价
    limit = $.GetLimit('btc', 'next_week'); // 获取 比特币 次周 合约限价
    Log(limit.high, limit.low); // 最高买入、最低卖出限价
    
}

Related

More

I love Jimmy.TypeError: value has no property at main (__FILE__:16) Please tell me where the problem occurs, error after running in the debug tool, as shown above.