Ordem de venda simples Iceberg (cópia)

Autora:Ervas daninhas, Data: 2020-03-20 16:38:52
Tags:EstudoAjudados no comércioIceberg

Muito simples, só para aprender. O código é a melhor anotação.

A venda por encomenda do iceberg, dividindo os pedidos em pedacinhos e vendendo para evitar o impacto do mercado, é uma boa estratégia de aprendizagem simples de introdução à negociação quantitativa de Bitcoin. O plug-in pode ser iniciado com um clique no terminal de transações, sem cobrança, facilitando a transação manual.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
            
        }
    }
}

Relacionados

Mais.