Type/to search
0
Follow
1
Followers
Ftx平台设置了挂单成交还是按照市价平了
Help
Created 2021-08-12 10:19:51  
 4
 1690

用的是平台现成的代码,
Trading view webhook接fmz,
同样的设置币安没有问题ftx平台,
直接平空开多不行,或者平多开空也不行


设置了挂单成交,还是有好多taker成交的,。

/*

// 参数
// var IsMarketOrder = false
// var QuotePrecision = 2
// var BasePrecision = 2

// 期货参数
// var Ct = ""

// 全局变量
var BUY = "xxx"
var SELL = "xxxxx"
var LONG = "long"
var SHORT = "short"
var COVER_LONG = "cover_long"
var COVER_SHORT = "cover_short"
var SPK = "sell"
var BPK = "buy"

function main() {
// 清空日志,如不需要,可以删除
LogReset(1)

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

// 识别期货还是现货
var eType = 0
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])

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, amount) : exchange.Sell(ticker.Buy, amount)
} else if (action == COVER_SHORT) {
exchange.SetDirection("closesell")
tradeInfo = IsMarketOrder ? exchange.Buy(-1, amount) : exchange.Buy(ticker.Sell, amount)
} 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)
}
}

Related Recommendations
Comment
All comments (4)

    你用的是类库的下单函数,并不保证挂单成交。即使买单挂买一价,也有一定的概率吃单。确保maker可以自己下单

    5 years ago

    好的,我想一下

    5 years ago

    另外求个交流群,主页的所有群都满了

    5 years ago

    加首页微信,拉你到微信群,会定期拉

    5 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)