Cover all contracts

Author: The grass, Date: 2020-03-18 17:04:51
Tags:

All futures positions in the trading pair are settled. Payout mode: Payout multiple positions, for example, continuously hanging a sell, after 0.5s revoked, continue hanging a sell, know the full payout. Each hanging order amount is all current payout positions.

The plug-in can be started at the touch of a button on the transaction terminal, without charging a fee, and facilitates manual transactions.https://www.fmz.com/digest-topic/5051



function main(){
    while(ture){
        var pos = exchange.GetPosition()
        var ticker = exchange.GetTicekr()
        if(!ticker){return '无法获取ticker'}
        if(!pos || pos.length == 0 ){return '已无持仓'}
        for(var i=0;i<pos.length;i++){
            if(pos[i].Type == PD_LONG){
                exchange.SetContractType(pos[i].ContractType)
                exchange.SetDirection('closebuy')
                exchange.Sell(ticker.Buy, pos[i].Amount - pos[i].FrozenAmount)
            }
            if(pos[i].Type == PD_SHORT){
                exchange.SetContractType(pos[i].ContractType)
                exchange.SetDirection('closesell')
                exchange.Buy(ticker.Sell, pos[i].Amount - pos[i].FrozenAmount)
            }
        }
        var orders = exchange.Getorders()
        Sleep(500)
        for(var j=0;j<orders.length;j++){
            if(orders[i].Status == ORDER_STATE_PENDING){
                exchange.CancelOrder(orders[i].Id)
            }
        }
    }
}


More

eth8888The test was positive for binance, but not positive for yoke.

eth8888Exchange.GetTicker is a free exchange. It's written as exchange.GetTicekr.

eth8888Exchange.GetTicker is a free exchange. It's written as exchange.GetTicekr.