Spot Iceberg Entrust Vender Plugin

Study Trade-aided Iceberg
Data de criação: 2020-03-20 16:38:52 última modificação: 2020-03-24 10:50:43
cópia: 31 Cliques: 2692
3
focar em
1444
Seguidores

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

A venda por encomenda de icebergs, que divide as encomendas em pequenas vendas para evitar choques no mercado, é uma boa estratégia de aprendizagem simples para entrar em negociação de quantidade de bitcoin. O plug-in pode ser iniciado em um terminal de negociação com um toque, sem cobrança de taxas, facilitando a negociação manual. Mais informações: https://www.fmz.com/digest-topic/5051

Código-fonte da estratégia
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
            
        }
    }
}