期货一键对冲插件


创建日期: 2020-03-18 15:59:34 最后修改: 2020-03-24 10:52:08
复制: 54 点击次数: 2258
3
关注
1228
关注者

可自动立即对冲两个合约,注意加适当的滑价,可能会不成交。仓位较多可分多次点击.

插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051

策略源码

function main(){
    exchange.SetContractType(Reverse ? Contract_B : Contract_A)
    var ticker_A = exchange.GetTicker()
    if(!ticker_A){return 'Unable to get quotes'}
    exchange.SetDirection('buy')
    var id_A = exchange.Buy(ticker_A.Sell+Slip, Amount)
    exchange.SetContractType(Reverse ? Contract_B : Contract_A)
    var ticker_B = exchange.GetTicker()
    if(!ticker_B){return 'Unable to get quotes'}
    exchange.SetDirection('sell')
    var id_B = exchange.Sell(ticker_B.Buy-Slip, Amount)
    if(id_A){
        exchange.SetContractType(Reverse ? Contract_B : Contract_A)
        exchange.CancelOrder(id_A)
    }
    if(id_B){
        exchange.SetContractType(Reverse ? Contract_B : Contract_A)
        exchange.CancelOrder(id_B)
    }
    return 'Position: ' + JSON.stringify(exchange.GetPosition())
}
更多内容