Late sharing Bitcoin high-frequency robot that earned 5% daily in 2014

Author: The grass, Created: 2017-11-30 14:15:27, Updated: 2023-11-01 20:23:49

img

The strategy is presented.

This is the address of the policy sharing:https://www.fmz.com/strategy/1088This strategy has been my main strategy since I started working on virtual currencies, and after constant improvement and modification, it has become much more complex, but the main idea has not changed. This version shared is the original version without obvious bugs, the simplest and clearest, no position management, every transaction is full, no card reset after death, etc., but it is also enough to explain the problem. The strategy ran from August 2014 until the exchange charged fees earlier this year. It was a good run, with little time to lose. The funds ran from the initial $200 to $80 bitcoin.The Sina blog of the little grassIn theHow to automate virtual currency transactionsThis is a series of articles. The chart below is the earnings curve of the OKcoin platform that I specifically calculated, with an initial investment of 1000 yuan, you can see that the initial money steadily increased, and the middle line is that my strategy stopped, and then as a result of changing the strategy entirely to the coin strategy, the earnings in the renminbi fluctuated sharply.Strategic deals two years onIn the article, the author describes the situation.imgThe following graph shows the curve of the total assets of the coupon:img

Why Share This Strategy

1. The exchange has killed almost all high-frequency strategies, including mine, after charging the transaction fee. 2. I haven't shared anything in a long time, I wanted to write this article for a long time. 3. Share and learn together.

The Principles of Strategy

This strategy is extremely simple, it can be understood as a quasi-high-frequency market strategy, you may want to beat someone after you see it, it can make money, almost anyone can write it. I did not expect it to be so effective at the beginning, it is obvious that there is an idea in my mind to rush to practice, not to say there must be surprises. As with all high-frequency strategies, this one is based on an order book, and the chart below is a typical Bitcoin exchange's order distribution.imgYou can see on the left side is the purchase order, showing the number of pending orders at different prices, on the right side is the sale order. You can imagine if a person wants to buy bitcoin, if he does not want to wait for the pending order, he can only choose to buy the order, if his order is more, it will make a lot of transactions, causing a shock to the price, but this shock is generally continuous, and someone does not want to eat the order, the price is likely to recover in a very short time, and in turn understands that someone wants to sell the coin similarly. For example, if someone were to buy 5 coins directly, the price would reach 10,377, while if someone were to sell 5 coins directly, the price would reach 10,348, which is the profit space. The strategy would be to list a price slightly below 10,377, such as 10,376.99, while buying at a price slightly above 10,348, such as 10,348.01, which would obviously make up the difference if this had just happened. To explain the specific operation with the parameters of the strategy now, this parameter can not be used, of course, only as an illustration. It will look up for the price of the cumulative number of pending orders of 8 coins, here is 10377, so the selling price at this time is this price minus 0.01 (minus how much can be random), the same way to look down for the cumulative purchase order hanging for 8 coins, here is 10348, so the selling price at this time is 10348.01, at this time the difference in the purchase price is 10376.99-10348.01 = 28.98, greater than the price difference predicted by the strategy of 1.5, so that if the two price pending orders are delivered, the price difference is less than 1.5, also find a price for the pending order, such as the discount price of 10, plus the waiting hole. It is also worth noting that this strategy is only related to the current deep listing, does not care about the historical market and its own historical transaction, and the strategy does not have the concept of a single loss, in fact, a single win rate is high.

Further information

  1. What do you do with no money or coins? This situation is very common when I have less money, most of the time only hanging on one side of the note, but it is not a big problem. In fact, it can be added to the logic of monetary balance, but in the process of balancing, inevitably there are losses, after all, each transaction is a speculation of probability, I choose to remain unilaterally waiting for the transaction, of course this also wastes the opportunity of the other side.
  2. How is the position managed? At the beginning, there are full stocks bought and sold, then divided into different groups according to different parameters, not completely completed at once.
  3. Is there no stopping? The strategy has a complete logic of buying and selling lists, I think there is no need to stop losses (it can be discussed), there is also the prospect of probability, the transaction is an opportunity, the stop loss is unfortunate.
  4. How can the strategy be adapted to the coin? The parameters at this time are symmetrical, i.e. the cumulative sale order of up to 8 coins, the cumulative payment of down to 8 coins, slightly unbalanced, such as the up to 15 coins cumulative sale order, making it more difficult to sell the coin, there is a greater chance that the coin will come back at a lower price, so the coin will be minted, in turn, make money.
  5. How to deal with the loss? A single transaction will of course incur losses, such as a rise in the price of the currency after selling and a fall in the price of the currency after buying, such a floating loss does not need to be processed, because the transaction is frequent, thousands of times a day are normal, floating losses are normal, as long as the probability of profit is greater.
  6. How to prevent black swans? Bitcoin's black swan time is a lot, sometimes it is all the way down, there is no chance to sell a little, this situation does not need to worry too much, because black swan time often brings high volatility, the strategic trick is just this part of the money, the loss can quickly recover.

Code explained

The full code can be found on my policy share at www.fmz.com, where only the core logic functions are explained. It is very impressive that without any changes, the analogue disk of the botvs carrier works perfectly, which is a strategy that was supported more than 3 years ago and is still supported today. The first is to get the buy/sell price function GetPrice (), which needs to get order depth information, be aware that order depth information lengths vary between different platforms, and that even if all orders are traveled, there is still no required amount (which causes this situation in many later 0.01 grid listings), the call is GetPrice (Buy) is to get the buy price.

function GetPrice(Type) {
   //_C()是平台的容错函数
    var depth=_C(exchange.GetDepth);
    var amountBids=0;
    var amountAsks=0;
    //计算买价,获取累计深度达到预设的价格
    if(Type=="Buy"){
       for(var i=0;i<20;i++){
           amountBids+=depth.Bids[i].Amount;
           //参数floatamountbuy是预设的累计深度
           if (amountBids>floatamountbuy){
               //稍微加0.01,使得订单排在前面
              return depth.Bids[i].Price+0.01;}
        }
    }
    //同理计算卖价
    if(Type=="Sell"){
       for(var j=0; j<20; j++){
    	   amountAsks+=depth.Asks[j].Amount;
            if (amountAsks>floatamountsell){
            return depth.Asks[j].Price-0.01;}
        }
    }
    //遍历了全部深度仍未满足需求,就返回一个价格,以免出现bug
    return depth.Asks[0].Price
}

The main function of each loop is onTick (), where the cycle time is set to 3.5s, with each cycle canceling the original single and re-hanging the list, the simpler the less bugs will occur.

function onTick() {
    var buyPrice = GetPrice("Buy");
    var sellPrice= GetPrice("Sell");
    //diffprice是预设差价,买卖价差如果小于预设差价,就会挂一个相对更深的价格
    if ((sellPrice - buyPrice) <= diffprice){
            buyPrice-=10;
            sellPrice+=10;}
    //把原有的单子全部撤销,实际上经常出现新的价格和已挂单价格相同的情况,此时不需要撤销
    CancelPendingOrders() 
    //获取账户信息,确定目前账户存在多少钱和多少币
    var account=_C(exchange.GetAccount);
    //可买的比特币量,_N()是平台的精度函数
    var amountBuy = _N((account.Balance / buyPrice-0.1),2); 
    //可卖的比特币量,注意到没有仓位的限制,有多少就买卖多少,因为我当时的钱很少
    var amountSell = _N((account.Stocks),2); 
    if (amountSell > 0.02) {
        exchange.Sell(sellPrice,amountSell);}
    if (amountBuy > 0.02) {
        exchange.Buy(buyPrice, amountBuy);}
    //休眠,进入下一轮循环
    Sleep(sleeptime);
}

The tail

The whole process was also more than 40 lines, it seemed very simple, but at the time it took me more than a week, this was still the case on the botvs platform. The biggest advantage was to start early, in 2014, the market was dominated by moving, the grid and the high frequency of the grab plate was not much, making the strategy like fish get water, then the competition inevitably became more and more fierce, my money was also more and more, the challenges faced a lot, every once in a while to make major changes to deal with, but overall it was going well. But there's plenty of room for a quantification strategy that doesn't require high frequency.


Related

More

232322The dam is really high and wide.

ziwuyouThe people who have been writing strategies for 14 years are at the top, can they not make money?

yinchaojiI'm not going to say anything about it.

taaa111Good stuff, learned!

The bride too.If you're using this strategy, you'll be able to see if the platform has a brush rate.

The bride too.Adding a tick to the trend judgement is similar to using a cabbage harvester, and can significantly increase the odds of winning.

muiaTesting for 10 minutes, loss of $2000

nxtplayerMany simple strategies work with zero fees and active delivery, and by the way, I'm mourning my own failure.

The bride too.It's good.

ZeroThe road to Jane:)

louisAvenue to Jane

momoxI have a lot of support!!!!!!!!!!!!!!

impWhat do you think?

Ignorance and FearHow many Q's you got?

louisWhat about the parameters? The actual measurement?

The grassSo we can't test without this set of parameters.

The grassIt works, share it.