资源加载中... loading...

Buy then Sell (ping-pong strategy)

Author: 小草, Date: 2018-10-11 15:31:49
Tags: StudyTrade-aided

如题,可设定买入价格,买入成功后自动挂卖出价格卖出, 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051


function CancelPendingOrders() {
    var orders = _C(exchange.GetOrders);
    for (var j = 0; j < orders.length; j++) {
        exchange.CancelOrder(orders[j].Id, orders[j]);
    }
}
function main() {
    Log('robot starts to run')
    if(BUYPRICE >= SELLPRICE){
        throw 'check buy and sell price'
    }
    CancelPendingOrders()
    var account = _C(exchange.GetAccount)
    var init_account = account
    Log('account: ', account.Balance);
    if(account.Balance > BUYPRICE*BUYAMOUNT){
        exchange.Buy(BUYPRICE, BUYAMOUNT);
    }else{
        throw 'account balances is not enough'
    }
    while(true){
        account = _C(exchange.GetAccount)
        if(account.Stocks >= init_account.Stocks + 0.01){
            exchange.Sell(SELLPRICE, account.Stocks - init_account.Stocks)
        }
        Sleep(Intervel*1000)
    }
}

template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6