The resource loading... loading...

Simple Iceberg order to sell (Copy)

Author: The grass, Date: 2020-03-20 16:38:52
Tags: StudyTrade-aidedIceberg

Very simple, just for learn. Code is best annotation.

Iceberg commissioning and selling, breaking orders into small pieces to avoid shocking the market, is a good simple introduction to Bitcoin quantitative trading learning strategy. The plug-in can be started at the touch of a button on the transaction terminal, without charging a fee, and facilitates manual transactions.https://www.fmz.com/digest-topic/5051


function main(){
    var initAccount = _C(exchange.GetAccount)
    if (initAccount.Stocks < SELLAMOUNT){
        throw 'check your account amount to sell'
    }
    while(true){
        var account = _C(exchange.GetAccount)
        var dealAmount =  initAccount.Stocks - account.Stocks
        var ticker = _C(exchange.GetTicker)
        if(SELLAMOUNT - dealAmount >= SELLSIZE){
            var id = exchange.Sell(ticker.Buy, SELLSIZE)
            Sleep(INTERVAL*1000)
            if(id){
                exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right.
            }else{
                throw 'sell error'
            }
        }else{
            account = _C(exchange.GetAccount)
            var avgCost = (account.Balance - initAccount.Balance)/(initAccount.Stocks - account.Stocks)
            return 'Iceberg order to sell is done, avg price is ' + avgCost
            
        }
    }
}

Related

More