아이스버그 주문 구매 간단 버전

Study Trade-aided Iceberg
생성 날짜: 2018-10-13 11:10:27 마지막으로 수정됨: 2020-03-20 16:24:13
복사: 32 클릭수: 3572
3
집중하다
1444
수행원

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

빙산 위탁 구매, 작은 M 구매로 주문을 분할하여 시장을 충격에서 피하는 것은 비트코인의 양적 거래에 대한 간단한 학습 전략입니다.

전략 소스 코드
function main(){
    var initAccount = _C(exchange.GetAccount)
    while(true){
        var account = _C(exchange.GetAccount)
        var dealAmount = account.Stocks - initAccount.Stocks
        var ticker = _C(exchange.GetTicker)
        if(BUYAMOUNT - dealAmount > BUYSIZE){
            var id = exchange.Buy(ticker.Sell, BUYSIZE)
            Sleep(INTERVAL*1000)
            if(id){
                exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right.
            }else{
                throw 'buy error'
            }
        }else{
            account = _C(exchange.GetAccount)
            var avgCost = (initAccount.Balance - account.Balance)/(account.Stocks - initAccount.Stocks)
            Log('Iceberg order to buy is done, avg cost is ', avgCost) // including fee cost
            return
        }
        
    }
}