Spot Iceberg Entrust Mua Plugin

Study Trade-aided Iceberg
Ngày tạo: 2020-03-20 16:37:02 sửa đổi lần cuối: 2020-03-24 10:50:51
sao chép: 40 Số nhấp chuột: 2718
3
tập trung vào
1444
Người theo dõi

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

Bầu băng giao mua, chia đơn đặt hàng thành M mua nhỏ, tránh thị trường bị sốc, là một chiến lược học tập đơn giản và tốt để bắt đầu giao dịch định lượng Bitcoin. Các plugin có thể được khởi động bằng một nút trên thiết bị đầu cuối giao dịch, không tính phí, thuận tiện cho giao dịch thủ công.

Mã nguồn chiến lược
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)
            return 'Iceberg order to buy is done, avg cost is '+avgCost
        }
        
    }
}