Earn 80 Times in 5 Days, the Power of High-frequency Strategy
Tags: strategy, fmzquant, contract, binance
Published: 2024-05-07 05:16:27

In the last two months, a print (money) account has become very popular, earning hundreds of times of profits on the Binance perpetual contract. The screenshots of his account returns can be seen in various groups. The profit curve almost without withdrawal makes many people jealous, and it also makes some people doubt the authenticity. However, my experience for 5 days from October 23 to October 27 has verified that high-frequency strategies can earn such abnormal returns in high volatility markets.

### My experience:
The strategy was finished in about two days. After one-day adjustment, on October 23, it started to run on Binance perpetual contract officially. Starting from 100USDT of top-up, I earned 8800USDT till October 27th, the yield was more than 80 times, and there was almost no withdrawal during the period. The total rate of return reached the 15th place in the ranking list of historical returns of Binance and the 2nd on returns in October. Due to problems in the statistics of Binance, the actual ranking should be more optimistic.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yn6szes5uovx4901jtnh.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cord77bijx3zdlv4t1g5.png)

### Experience summary:
Not all markets and times are suitable for high-frequency strategies, and the conditions for running high-frequency robots are very harsh. Here are some conditions:

1. Suitable for high-frequency market

In the past five days, FIL perpetual contracts were only traded in Binance. The FIL market was very chaotic when it was just launched. The difference between the perpetual price and the spot price has ever reached more than 30%, which lead to serious differences between the long and short position in FIL. The opening price on October 16 fell all the way from 60 to 26 and rebounded once again from 19 to 37. In the days with large trading amount, it ranked third among all trading pairs, second only to the BTC and ETH, which is a golden opportunity for high-frequency trading. Unfortunately, I didn't get the robot ready in time, so I missed the beginning few days, but I managed to catch up with the market on October 24-25. Most of the profits came from this period. After the October 27, the price difference decreased gradually, the capital rate of the top grid also disappeared, the trading amount shrank, and the strategy became more difficult to make money.

Similar opportunities also occurred in the early days of SUSHI/YFI/YFII/UNI's launch, when both volatility and trading amount were large. Print (money) also seized these opportunities. When these currencies can no longer make money, FIL appears again. One is the hot DEFI concept, and the other is the high-profile FIL. In the current situation, the next opportunity also needs to wait for a long time.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18m8q1viwdc7y9qcjeel.png)

2. Trading comission

High frequency strategies are very sensitive to comission. The threshold for Binance maker to return 2/100000 is not very much. Although the return fees are little, it can be understood as free of comission. A number of high-frequency strategies in the ancient era of no comission for spot have been revived. Of course, when the market fluctuates violently, the comission is relatively less important.

3. High frequency

The most famous feature of high-frequency robots is their extremely high frequency. When the market changes rapidly, many of my strategies can finish opening or closing positions within 100ms.

4. Strategy winning rate

High frequency strategy needs to make an accurate judgment on the short-term trend of the market, and the higher the winning rate, the larger the order amount will be, and the larger the trading amount in a short-term, the larger the order amount will be. Due to the large amount and frequent transactions of FIL, the trend prediction within a few seconds is very accurate. Similarly, the game between going long and going short is fierce, giving makers the opportunity to establish corresponding positions and close positions. This is different from the spot high-frequency in the early years. Now, makers have returned commission, but takers still have a high commission, so they can only pend orders. Imagine that if everyone is bullish for a short time, maker cannot make a profit because of the comission for high-frequency strategy. If there is no trend in the market, maker can make a deal, but the probability of profit is not very much. Therefore, the current high-frequency strategy requires that the market has a general trend to ensure a high winning rate, and there are local differences between going long and going short to ensure a large number of transactions.

When the market goes well, the winning rate of my strategy is more than 80%, and the profit loss ratio is greater than 1. When there is no obvious trend in the market, the winning rate in a long-term is also more than 65%, and the profit loss ratio is less than 1.

5. Capacity of high-frequency strategies

The capacity of high-frequency strategy is obviously not very much. Because of the perpetual high leverage, 100u can operate more than 2000u of funds, high-frequency strategy can start with very small funds. But the overall net profit will not be too much. The specific capacity depends on the trading volume in the market.

6. Risks of the strategy

There are risks in opening positions, but the advantage of high-frequency trading is that the number of transactions is large. If you lossed for once, you can cover it by 10 more transactions quickly, and the withdrawal is very small when the period is extended. The bigger the position is, the greater the risk will be. Therefore, it is not suggested to scale in the position indefinitely. There must be a certain negative feedback mechanism. When there are more positions, it is necessary to scale in the closing position and reduce the opening position, so as to ensure that the time for holding positions is short. If there is a position, there will be a big loss if the trend is just reversed. Therefore, the strategy has designed a judgment on the direction to ensure that the position is opened on the side of the trend when the trend is in surge or plunge, further reducing the risk, and the cost is there is no frequent small losses when the short-term trend is not clear.

### About my strategy
Strategy principle:

Obtain the trades traded recently, depth and current position, judge the trend according to the trades, and determine the opening position amount according to the trading volume. If the trend is upward, open a long position order, and close the long position at the same time. If you hold short positions at this time, close all positions first. It is the same to judge the decrease trend.

The idea of high-frequency strategy is very consistent. My strategy draws on the idea of 2014 high-frequency strategy and OKCoin LeeksReaper strategy that I have disclosed previously. The source code of both strategies can be found in FMZ. If you understand both strategies thoroughly, high-frequency trading will be easy for you.

  - Easy Bitcoin High-frequency Strategy Robot in 2014 (https://www.fmz.com/strategy/1088)
  - Transplant OKCoin LeeksReaper (https://www.fmz.com/strategy/34388)

Strategy structure:

The strategy adopts asynchronous architecture (refer to the FMZ Community Advanced Tutorial please). There is no source code here, just a simple description of functions, not a complete code that can be run, nor does it involve core logic. The API uses REST protocol instead of websocket. The server is in Tokyo, which can obtain lower latency.
```
//Set trading pairs and leverage
var pair = Symbol+'USDT'
exchange.SetCurrency(Symbol+'_USDT')
exchange.SetContractType("swap")
exchange.IO("api", "POST", "/fapi/v1/leverage", "symbol="+pair+"&leverage="+5+"&timestamp="+Date.now())

//Basic limits for trading accuracy
var price_precision = null
var tick_size = null
var amount_precision = null 
var min_qty = null

var exchange_info = JSON.parse(HttpQuery('https://fapi.binance.com/fapi/v1/exchangeInfo'))
for (var i=0; i<exchange_info.symbols.length; i++){
   if(exchange_info.symbols[i].baseAsset == Symbol){
       tick_size = parseFloat(exchange_info.symbols[i].filters[0].tickSize)
       price_precision = exchange_info.symbols[i].filters[0].tickSize.length > 2 ? exchange_info.symbols[i].filters[0].tickSize.length-2 : 0
       amount_precision = exchange_info.symbols[i].filters[1].stepSize.length > 2 ? exchange_info.symbols[i].filters[1].stepSize.length-2 : 0
       min_qty = parseFloat(exchange_info.symbols[i].filters[1].minQty)
   }
}

function updatePosition(){// Obtain the position. Symbol is a trading pair. Add the trading pair parameter instead of returning the full currency, which can reduce the API usage for one time
    position = exchange.IO("api", "GET","/fapi/v2/positionRisk","timestamp="+Date.now()+"&symbol="+Symbol+"USDT")
}
function updateTrades(){// Obtain Recent Transactions
    trades = exchange.IO("api", "GET","/fapi/v1/trades","limit=200&timestamp="+Date.now()+"&symbol="+Symbol+"USDT")
}
function updateDepth(){// Obtain depth
    depth = exchange.IO("IO", "api", "GET","/fapi/v1/depth","timestamp="+Date.now()+"&symbol="+Symbol+"USDT")
}

function onTick(){
    updateDepth() 
    updateTrades() 
    updatePosition() 
    makeOrder() //Calculate the order price, amount and place the order
    updateStatus() //Update status information
}

//The main loop, with a sleep time of 100ms, and the loop delay of the strategy is usually within 30ms.
function main() {
    while(true){
        if(Date.now() - update_loop_time > 100){
            onTick()
            update_loop_time = Date.now()
        }
        Sleep(1)
    }
}
```
The strategy is too strict for the market. It doesn't make money for most of the time, and the capacity is not large. If you this article was reposted on microblog, WeChat group and moments and other platforms actively, and if more than 100,000 people read it, I will consider renting it to let all of you do actual operation, and even publish the source code of the strategy in this article in the future. Add the WeChat contact on FMZ home page, reply the Binance, and you will enter into the FMZ Binance WeChat group.

From: https://blog.mathquant.com/2022/11/09/earn-80-times-in-5-days-the-power-of-high-frequency-strategy.html