리소스 로딩... 로딩...

저자:q631207207, 창작: 2022-05-16 23:37:41, 업데이트:

/*

// 변수 // var IsMarketOrder = 거짓 // var QuotePrecision = 2 // var BasePrecision = 2

// 선물 변수 //var Ct =

// 글로벌 변수 var BUY = buy var SELL = var LONG = 길쭉한 수달 var SHORT = short var COVER_LONG = cover_long // 케이도 -1 var COVER_SHORT = cover_short //공간-1 var COVER_LONG1 = cover_long1 // 평다 -2 var COVER_SHORT1 = cover_short1 // 평면 -2 var COVER_LONG2 = cover_long2 // 평수 -3 var COVER_SHORT2 = cover_short2 // 평면 -3

var SPK = spk var BPK = bpk var Ct =

function main (() { // 빈 로그, 필요 없는 경우 삭제할 수 있습니다 로그리셋 (LogReset))

// 设置精度
exchange.SetPrecision(QuotePrecision, BasePrecision)

// 识别期货还是现货
var eType =1
var eName = exchange.GetName()
var patt = /Futures_/
if (patt.test(eName)) {
    Log("添加的交易所为期货交易所:", eName, "#FF0000")
    eType = 1
    if (Ct =="") {
        throw "Ct 合约设置为空"
    } else {
    	Log(exchange.SetContractType(Ct), "设置合约:", Ct, "#FF0000")
    }
} else {
	Log("添加的交易所为现货交易所:", eName, "#32CD32")
}

var lastMsg = ""
var acc = _C(exchange.GetAccount)
while(true) {
    var cmd = GetCommand()
    if (cmd) {
        // 检测交互命令
        lastMsg = "命令:" + cmd + "时间:" + _D()
        var arr = cmd.split(":")
        if (arr.length != 2) {
            Log("cmd信息有误:", cmd, "#FF0000")
            continue
        }

        var action = arr[0]
        //var amount = parseFloat(arr[1])
        var amount =0.10 //开单数
        var amount1 =0.3 //第一止盈
        var amount2 =0.5 //第二止盈
        var amount3 =0.2 //第三止盈
        if (eType == 0) {
            if (action == BUY) {               
                var buyInfo = IsMarketOrder ? exchange.Buy(-1, amount) : $.Buy(amount)
                Log("buyInfo:", buyInfo)
            } else if (action == SELL) {        
                var sellInfo = IsMarketOrder ? exchange.Sell(-1, amount) : $.Sell(amount)
                Log("sellInfo:", sellInfo)
            } else {
            	Log("现货交易所不支持!", "#FF0000")
            }
        } else if (eType == 1) {
        	var tradeInfo = null
        	var ticker = _C(exchange.GetTicker)
            if (action == LONG) {
            	exchange.SetDirection("buy")
                tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
            } else if (action == SHORT) {        
                exchange.SetDirection("sell")
                tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount) : exchange.Sell(ticker.Buy, amount)
            } else if (action == COVER_LONG) {        
                exchange.SetDirection("closebuy")
                tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount1) : exchange.Sell(ticker.Buy, amount1)
            } else if (action == COVER_LONG1) {        
                exchange.SetDirection("closebuy")
                tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount2) : exchange.Sell(ticker.Buy, amount2)
            } else if (action == COVER_LONG2) {        
                exchange.SetDirection("closebuy")
                tradeInfo = IsMarketOrder ? exchange.Sell(-1, amount3) : exchange.Sell(ticker.Buy, amount3)
            } else if (action == COVER_SHORT) {        
            	exchange.SetDirection("closesell")
            	tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount1) : exchange.Buy(ticker.Sell, amount1)
            } else if (action == COVER_SHORT1) {        
            	exchange.SetDirection("closesell")
            	tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount2) : exchange.Buy(ticker.Sell, amount2)
            } else if (action == COVER_SHORT2) {        
            	exchange.SetDirection("closesell")
            	tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount3) : exchange.Buy(ticker.Sell, amount3)
            } else if (action == SPK) {   // 卖出平多仓,卖出开空仓
                exchange.SetDirection("closebuy")
                var tradeInfo1 = IsMarketOrder ? exchange.Sell(-1, amount) : exchange.Sell(ticker.Buy, amount)
                exchange.SetDirection("sell")
                var tradeInfo2 = IsMarketOrder ? exchange.Sell(-1, amount) : exchange.Sell(ticker.Buy, amount)
                tradeInfo = [tradeInfo1, tradeInfo2]
            } else if (action == BPK) {   // 买入平空仓,买入开多仓
                exchange.SetDirection("closesell")
                var tradeInfo1 = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
                exchange.SetDirection("buy")
                var tradeInfo2 = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
                tradeInfo = [tradeInfo1, tradeInfo2]
            } else {
            	Log("期货交易所不支持!", "#FF0000")
            }
            if (tradeInfo) {
                Log("tradeInfo:", tradeInfo)
            }
        } else {
        	throw "eType error, eType:" + eType
        }
        acc = _C(exchange.GetAccount)
    }
    var tbl = {
    	type : "table", 
    	title : "状态信息", 
    	cols : ["数据"], 
    	rows : []
    }
    tbl.rows.push([JSON.stringify(acc)])
    LogStatus(_D(), eName, "上次接收到的命令:", lastMsg, "\n", "`" + JSON.stringify(tbl) + "`")
	Sleep(1000)
}

}

분배 정지 은 이렇게, 그리고 또 다른 평면 전체 저장소를 추가하고 싶습니다, 여러분, 어떻게 추가해야합니까?


더 많은

가벼운 구름내 평형 방식은 현재 보유 수를 얻는 것이고, 평형 시에는 매개 변수에서 보유 수를 얻을 수 있다.

가벼운 구름 https://www.fmz.com/api#exchange.getposition

q631207207이 글은 어떻게 써야 하는지 알려주실 수 있나요?