The resource loading... loading...

The difference between platforms is calculated every minute.

Author: yzl_126@126.com, Date: 2014-06-23 13:14:02
Tags: Tool

Statistics on the biggest differences between platforms; If you want to print the market conditions of the exchanges at the time, you can delete //printCurPrice ((); the previous comment//;


var maxSpace = 0;

function adjustFloat(v) {
    return Math.floor(v*1000)/1000;
}

function printCurPrice() {
    for (var i = 0; i < exchanges.length; i++) {
        Log(exchanges[i].GetName(),'=',exchanges[i].GetTicker());
    }
}

function onTick() {
    // TODO something.
    var smallPrice = 99999;
    var bigPrice = 0;
    var curPrice = 0;
    var curSpace = 0;
    
    for (var i = 0; i < exchanges.length; i++) {
        curPrice = exchanges[i].GetTicker().Last;
        if (curPrice < smallPrice){
            smallPrice = curPrice;
        }
        if (curPrice > bigPrice){
            bigPrice = curPrice;
        }
        curSpace = bigPrice - smallPrice;
    }
    
    if (curSpace > maxSpace){
        maxSpace = curSpace;
        //打印各交易所当前的市场行情;
        printCurPrice();
        Log('有新高差价:', adjustFloat(maxSpace),'高价:', bigPrice,'低价:', smallPrice, '发生时间 →_→');
    }
    Log('当前差价:', adjustFloat(curSpace),'高价:', bigPrice,'低价:', smallPrice,'最高差价:', adjustFloat(maxSpace));
}

function main() {
    if (exchanges.length < 2) {
        Log("交易所数量最少得两个才能完成统计");
        return;
    }
    while(true) {
        onTick();
        Sleep(60000);
    }
}

Related

More

ytrezq Hello, what are the platforms you are comparin?