Bitcoin minimalist high-frequency strategies robot

That is, I just started to write the source code Bitcoin high-frequency robots, almost no change, but also the parameters of the original parameters. This version of the program there are many areas for improvement, but even so, it was an amazing performance in addition to profitability, in a little while I am the principal, without leverage average profit of around 5% per day. Of course, no matter where on the one hand, it does not adapt to today's market. I also sent an article in the community, we can look at.

This strategy is very simple principle, be subject to understand high-frequency market-making strategy, then you might want to read the beat, it can make money, then almost anyone can write. I did not expect it to start so effective, visible heart the idea to quickly pay practices that do not necessarily have a pleasant surprise. Bitcoin robot in early-2014, the write strategy to make money too easy.

Strategy Source Address: https://www.fmz.com/strategy/1088

Slightly changed a little, fault tolerant platform function _C (), function and precision _N ().

function CancelPendingOrders () {
     var Orders = _C (exchange.GetOrders);
     for ( var J = 0; J <orders.length; J ++ ) { 
          exchange.CancelOrder (Orders [J] .Id, Orders [J]);} 
} 

// calculations will be the price of a single 
function the GetPrice (the Type, depth) {
     var amountBids = 0 ;
     var amountAsks = 0 ;
     // calculate the purchase price, obtaining the depth reaches a predetermined total price 
    IF (the Type == "Buy" ) {
        for ( var I = 0; I <20 is; I ++ ) { 
           amountBids + = depth.Bids [I] .Amount;
           // floatamountbuy is accumulated to pay a preset depth 
           IF (amountBids> floatamountbuy) {
                // add a little 0.01, such that the top surface orders 
              return depth.Bids [I] + 0.01 .price ;} 
        } 
    } 
    // Similarly calculated selling price 
    IF (the Type == "Sell" ) {
        for ( var J = 0; J <20 is; J ++ ) { 
           amountAsks + = depth.Asks [J] .Amount;
             IF (amountAsks> floatamountsell) {
             return depth.Asks [J] 0.01-.price ;} 
        } 
    } 
    // traverse the full depth of the demands have not been met, it returns a price to avoid bug 
    returndepth.Asks [0 ] .price 
} 
 
function forward, the onTick () {
     var depth = _C (exchange.GetDepth);
     var buyPrice the GetPrice = ( "Buy" , depth);
     var SellPrice the GetPrice = ( "Sell" , depth);
     // bid-ask spread is less than a preset value diffprice, it will be linked to the price of a relatively deeper 
    IF ((SellPrice - buyPrice) <= diffprice) { 
            buyPrice - = 10 ; 
            SellPrice + = 10 ;}
     // the original list of all revoked, the new price and the case has been pending in fact often the same price, then do not need to withdraw 
    CancelPendingOrders () 
     // get account information, determine how much money and how much money there is at present accounts 
    var the account =_C (exchange.GetAccount);
     // can buy credits bit amount 
    var amountBuy = _N ((account.Balance / buyPrice-0.1), 2 ); 
     // credits the amount of bits may be sold, there is no limit positions of the note, there how much to trade, because I had very little money 
    var amountSell _N = ((account.Stocks), 2 ); 
     IF (amountSell> 0.02 ) { 
        exchange.Sell (SellPrice, amountSell);} 
    IF (amountBuy> 0.02 ) { 
        exchange.Buy (buyPrice, amountBuy);} 
    // sleep, loop around 
    sleep (sleeptime,); 
} 
    
function main () {
     the while ( to true ) { 
        forward, the onTick (); 
    } 
}

 

Guess you like

Origin www.cnblogs.com/botvsing/p/10984292.html