The Penny Jump of high-frequency trading strategies

Author: Zero, Date: 2014-08-18 12:52:35
Tags: High-frequency

$1.01 x $1.03 200. And then all of a sudden this crazy institutional investor comes in and hangs up a $1.01 bill for 3,000 shares, and then the order book becomes $3.200. $1.01 x $1.03. 200. And we usually call this crazy institutional investor an elephant buzzard, an elephant buzzard, and the high-frequency trader knows that the $1.01 price is backed up by a buy, so they raise their bid price by 1 cent to $1.02, and this strategy is called the Penny Jump; because the high-frequency trader knows that somewhere down the line, there's an elephant buzzard in the back, so if the price goes up to $1.03 x $1.05, he can immediately make a $0.01 profit.

If the high-frequency trader buys the stock after the price has not gone up because an elephant is supporting it below, he can quickly sell it back to the elephant for $1.01.

For high-frequency traders, the way they make a profit is actually very simple: they use the microstructure in the market to guess the intentions of their counterparts and then build a segment one step ahead of others.

For the elephant, he exposed his trading intentions by hanging a huge ransom note in the market and naturally became a target for high-frequency traders.

In the real world of stock trading, there should be very few such shrewd institutional investors who would openly and brazenly post huge quotes on the market. Instead, it is common for large institutional investors, who want to get out of a stock, to intentionally post huge quotes to create a false impression, to attract high-frequency traders to enter the market to push the stock price, and then another brain dump out, which is what I call the profit trade in the world.

For high-frequency traders, once this strategy is seen and matched by the gaming lobby, they will turn back to the lobby against the lobby, developing strategies to eat the institutional investor's tofu against the lobby.

This is a picture of me.

img



var Counter = {
    i: 0,
    w: 0,
    f: 0
};

// Variables
var InitAccount = null;

function CancelAll() {
    while (true) {
        var orders = _C(exchange.GetOrders);
        if (orders.length == 0) {
            break;
        }
        for (var i = 0; i < orders.length; i++) {
            exchange.CancelOrder(orders[i].Id);
        }
        Sleep(Interval);
    }
}

function updateStatus(msg) {
    LogStatus("调戏次数:", Counter.i, "成功:", Counter.w, "失败:", Counter.f, "\n"+msg+"#0000ff\n"+new Date());
}

function main() {
    if (DisableLog) {
        EnableLog(false);
    }
    CancelAll();
    InitAccount = _C(exchange.GetAccount);
    Log(InitAccount);
    var i = 0;
    var locks = 0;
    while (true) {
        Sleep(Interval);
        var depth = _C(exchange.GetDepth);
        if (depth.Asks.length === 0 || depth.Bids.length === 0) {
            continue;
        }
        updateStatus("搜索大象中.... 买一: " + depth.Bids[0].Price + ",  卖一:" + depth.Asks[0].Price + ", 锁定次数: " + locks);
        var askPrice = 0;
        for (i = 0; i < depth.Asks.length; i++) {
            if (depth.Asks[i].Amount >= Lot) {
                askPrice = depth.Asks[i].Price;
                break;
            }
        }
        if (askPrice === 0) {
            continue;
        }
        var elephant = null;
        // skip Bids[0]
        for (i = 1; i < depth.Bids.length; i++) {
            if ((askPrice - depth.Bids[i].Price) > ElephantSpace) {
                break;
            }
            if (depth.Bids[i].Amount >= ElephantAmount) {
                elephant = depth.Bids[i];
                break;
            }
        }

        if (!elephant) {
            locks = 0;
            continue;
        }
        locks++;
        if (locks < LockCount) {
            continue;
        }
        locks = 0;

        updateStatus("调戏大象中....大象在第" + i + "档, " + JSON.stringify(elephant));
        exchange.Buy(elephant.Price + PennyTick, Lot, "Bids[" + i + "]", elephant);
        var ts = new Date().getTime();
        while (true) {
            Sleep(CheckInterval);
            var orders = _C(exchange.GetOrders);
            if (orders.length == 0) {
                break;
            }
            if ((new Date().getTime() - ts) > WaitInterval) {
                for (var i = 0; i < orders.length; i++) {
                    exchange.CancelOrder(orders[i].Id);
                }
            }
        }
        var account = _C(exchange.GetAccount);
        var opAmount = _N(account.Stocks - InitAccount.Stocks);
        if (opAmount < 0.001) {
            Counter.f++;
            Counter.i++;
            continue;
        }
        updateStatus("买单得手: " + opAmount +", 开始出手...");
        exchange.Sell(elephant.Price + (PennyTick * ProfitTick), opAmount);
        var success = true;
        while (true) {
            var depth = _C(exchange.GetDepth);
            if (depth.Bids.length > 0 && depth.Bids[0].Price <= (elephant.Price-(STTick*PennyTick))) {
                success = false;
                updateStatus("没有得手, 开始止损, 当前买一: " + depth.Bids[0].Price);
                CancelAll();
                account = _C(exchange.GetAccount);
                var opAmount = _N(account.Stocks - InitAccount.Stocks);
                if (opAmount < 0.001) {
                    break;
                }
                exchange.Sell(depth.Bids[0].Price, opAmount);
            }
            var orders = _C(exchange.GetOrders);
            if (orders.length === 0) {
                break;
            }
            Sleep(CheckInterval);
        }
        if (success) {
            Counter.w++;
        } else {
            Counter.f++;
        }
        Counter.i++;
        var account = _C(exchange.GetAccount);
        LogProfit(account.Balance - InitAccount.Balance, account);
    }
}

Related

More

caixb1233If you want to know how to do this, you can check the following page:

bbThanks for sharing, I didn't quite understand it, I explained it in the comments below, thank you! https://dn-filebox.qbox.me/91dee18be7307389046517f405b410897a1f3fb9.png https://dn-filebox.qbox.me/4d90b4713a44f61b3a836114fceaf62bcff0756e.png https://dn-filebox.qbox.me/1937c68cfe9f33040d29e03efa5160e13c5ad174.png https://dn-filebox.qdn.me/bdc54915ecc86cebb582fee0307758519207a78.png