Iceberg commission refers to the fact that investors, when making large transactions, in order to avoid causing too much shock to the market, automatically break up the large order into multiple orders, automatically place a small order according to the current latest buy/sell price and the price strategy set by the customer, automatically re-commission the order when the previous order is fully completed or the latest price deviates significantly from the current order price. Examples: If the floating point number of a single mean is set to 10, then: Each order is 90% to 110% of its average single order value. The order price is the latest sell price* ((1+ depth of order), a new order is placed after the last order has been fully completed, automatically withdrawn and re-commissioned when the latest transaction price is more than the depth of order*2 from the order. The order is stopped when the total transaction volume is equal to its total order number.
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 LastSellPrice = 0; var InitAccount = null; function dispatch() { var account = null; var ticker = _C(exchange.GetTicker); // 在最新成交价格距离该笔委托超过委托深度*2时自动撤单并重新进行委托 if (LastSellPrice > 0) { // 订单没有完成 if (_C(exchange.GetOrders).length > 0) { if (ticker.Last < LastSellPrice && ((LastSellPrice - ticker.Last) / ticker.Last) > (2*(EntrustDepth/100))) { Log('偏离过多, 最新成交价:', ticker.Last, '委托价', LastSellPrice); CancelPendingOrders(); } else { return true; } } else { account = _C(exchange.GetAccount); Log("卖单完成, 累计卖出:", _N(InitAccount.Stocks - account.Stocks), "平均卖出价:", _N((account.Balance - InitAccount.Balance) / (InitAccount.Stocks - account.Stocks))); } LastSellPrice = 0; } // 委托价格为最新卖1价*(1+委托深度) var SellPrice = _N(ticker.Sell * (1 + EntrustDepth/100)); if (SellPrice < MinSellPrice) { return true; } if (!account) { account = _C(exchange.GetAccount); } if ((InitAccount.Stocks - account.Stocks) >= TotalSellStocks) { return false; } var RandomAvgSellOnce = (AvgSellOnce * ((100 - FloatPoint) / 100)) + (((FloatPoint * 2) / 100) * AvgSellOnce * Math.random()); var SellAmount = Math.min(TotalSellStocks - (InitAccount.Stocks - account.Stocks), RandomAvgSellOnce); if (SellAmount < MinStock) { return false; } LastSellPrice = SellPrice; exchange.Sell(SellPrice, SellAmount, '上次成交价', ticker.Last); return true; } function main() { if (exchange.GetName().indexOf('Futures_') != -1) { throw "只支持现货"; } CancelPendingOrders(); InitAccount = _C(exchange.GetAccount); Log(InitAccount); if (InitAccount.Stocks < TotalSellStocks) { throw "账户币数不足"; } LoopInterval = Math.max(LoopInterval, 1); while (dispatch()) { Sleep(LoopInterval); } Log("委托全部完成", _C(exchange.GetAccount)); }