Type/to search
0
Follow
1
Followers
트레이딩뷰 시그널 트레이딩 로봇 오류 해결 방법
Help
Created 2021-01-02 07:06:59  
 6
 2266

트레이딩 뷰 신호로 자동으로 거래하고 싶어하는 초보자, 로봇을 배포한 후 오류가 나타납니다. Ct 계약이 빈으로 설정되어 있습니다.
코드는 TradingViewWebHook의 신호 실행 전략을 복제합니다.
/*

// 변수
// var IsMarketOrder = false
// var QuotePrecision = 2
// var BasePrecision = 2

// 선물 변수
// var Ct = ""

// 범용 변수
var BUY = "buy"
var SELL = "sell"
var LONG = "long"
var SHORT = "short"
var COVER_LONG = "cover_long"
var COVER_SHORT = "cover_short"
var SPK = "spk"
var BPK = "bpk"

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 (6)

    错误信息都没,怎么看。

    6 years ago

    期货机器人错误是
    2021-01-02 23:40:08 信息 期货交易所不支持!
    2021-01-02 23:40:05 信息 期货交易所不支持!
    2021-01-02 23:38:23 信息 {"InstrumentID":"BTCUSDT","instrument":"BTCUSDT"} 设置合约: swap
    2021-01-02 23:38:23 信息 添加的交易所为期货交易所: Futures_Binance

    麻烦大神了 感谢

    6 years ago

    日期 平台 类型 价格 数量 信息
    2021-01-02 23:39:01 信息 sellInfo: null
    2021-01-02 23:39:01 Binance 错误 Sell(-1, 0.01): 400: {"code":-2010,"msg":"Account has insufficient balance for requested action."}
    2021-01-02 23:38:53 信息 buyInfo: null
    2021-01-02 23:38:53 Binance 错误 Buy(-1, 0.01): 400: {"code":-2010,"msg":"Account has insufficient balance for requested action."}

    6 years ago

    账户资金不足

    6 years ago

    新手 求教教 怎么设置btcusdt永续合约,具体是改哪行代码

    6 years ago

    现货机器人完全按 b站视频设置的 也运行不了,收到交易指令以后 buynull返回 sellnull

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