Loading ...

期货看穿式测试

Author: Hukybo, Date: 2019-06-17 10:28:53
Tags:


num = 0

function onTick() {
    if (num < 1) {
        _C(exchange.SetContractType, "rb1910")
        account = _C(exchange.GetAccount).Info.AccountID
        Log("账号:", account);
        Log("AppID:", "client_fmz_1.0");
        records = _C(exchange.GetRecords)
        k = records[records.length - 1].Close
        exchange.SetDirection("buy");
        id = exchange.Buy(k + 2, 1)
        Log("sessionid:", id);
        Log("登陆时间:", Date());
        
        Log("账号:", account);
        records = _C(exchange.GetRecords)
        k = records[records.length - 1].Close
        for (x = 0; x < 5; x++) {
            exchange.SetDirection("buy");
            id = exchange.Buy(k + 2, 1)
            Log("sessionid:", id);
            Sleep(1000)
        }
        
        Log("账号:", account);
        for (y = 0; y < 5; y++) {
            exchange.SetDirection("buy");
            id = exchange.Buy(k - 2, 1)
            Log("sessionid:", id);
            Sleep(1000)
        }
        orders = _C(exchange.GetOrders)
        for (z = 0; z < 5; z++) {
            Log("账号:", account);
            Log("合约:", "rb1910");
            var ordersid = orders[z].Id
            if (exchange.CancelOrder(ordersid)) {
                Log("订单:" + ordersid + " 已撤单")
            }
        }
        num++
    }
}

function main() {
    while (true) {
        onTick();
        Sleep(1000);
    }
}

More