The iceberg commission refers to the investor’s large-scale transaction, in order to avoid excessive impact on the market, the large single commission is automatically split one large order into multiple small orders, according to the current latest buy/sell price and customer setting price, The strategy automatically performs the small order delegation, and automatically re-placing the orders when the previous order is completely sold or the latest price deviates significantly from the current placing price.

Example:
If the single-average floating point is set to 10 then:

The number of each placing is 90%~110% of the average value of the single placing, and the placing price is the latest buying price let’s say 1 times (minus 1 delegation depth), and a new placing is made after the last placing is completed. automatically withdraw the order and re-placing when the latest transaction price is more than the placing depth *2.

The placing is stopped when the total volume of the strategy is equal to its total number of orders. When the latest transaction price of the market is higher than its maximum buying price, the commission is stopped, and the commission is resumed after the latest transaction price is lower than the highest buying price.

function CancelPendingOrders() {
    while (true) {
        var orders = _C(exchange.GetOrders);
        if (orders.length == 0) {
            return;
        }

        for (var j = 0; j < orders.length; j++) {
            exchange.CancelOrder(orders[j].Id);
            if (j < (orders.length-1)) {
                Sleep(Interval);
            }
        }
    }
}

var LastBuyPrice = 0;
var InitAccount = null;

function dispatch() {
    var account = null;
    var ticker = _C(exchange.GetTicker);
    if (LastBuyPrice > 0) {
        if (_C(exchange.GetOrders).length > 0) {
            if (ticker.Last > LastBuyPrice && ((ticker.Last - LastBuyPrice) / LastBuyPrice) > (2*(EntrustDepth/100))) {
                Log('deviate to much, newest last price:', ticker.Last, 'order buy price', LastBuyPrice);
                CancelPendingOrders();
            } else {
                return true;
            }
        } else {
            account = _C(exchange.GetAccount);
            Log("order finised, total cost:", _N(InitAccount.Balance - account.Balance), "avg buy price:", _N((InitAccount.Balance - account.Balance) / (account.Stocks - InitAccount.Stocks)));
        }
        LastBuyPrice = 0;
    }
    
    var BuyPrice = _N(ticker.Buy * (1 - EntrustDepth/100),PricePerision);
    if (BuyPrice > MaxBuyPrice) {
        return true;
    }
    
    if (!account) {
        account = _C(exchange.GetAccount);
    }


    if ((InitAccount.Balance - account.Balance) >= TotalBuyNet) {
        return false;
    }
    
    var RandomAvgBuyOnce = (AvgBuyOnce * ((100 - FloatPoint) / 100)) + (((FloatPoint * 2) / 100) * AvgBuyOnce * Math.random());
    var UsedMoney = Math.min(account.Balance, RandomAvgBuyOnce, TotalBuyNet - (InitAccount.Balance - account.Balance));
    
    var BuyAmount = _N(UsedMoney / BuyPrice, 3);
    if (BuyAmount < MinStock) {
        return false;
    }
    LastBuyPrice = BuyPrice;
    exchange.Buy(BuyPrice, BuyAmount, 'Cost: ', _N(UsedMoney), 'last price', ticker.Last);
    return true;
}

function main() {
    CancelPendingOrders();
    InitAccount = _C(exchange.GetAccount);
    Log(InitAccount);
    if (InitAccount.Balance < TotalBuyNet) {
        throw "balance not enough";
    }
    LoopInterval = Math.max(LoopInterval, 1);
    while (dispatch()) {
        Sleep(LoopInterval * 1000);
    }
    Log("All Done", _C(exchange.GetAccount));
}

also the Strategy Arguments setting:

For more information, please see: https://www.fmz.com/bbs-topic/2285

Leave a Reply

Your email address will not be published. Required fields are marked *