OKEX hat eine Position.
BTC/USD-Details für die Dauer der Transaktion
全仓
买入
Zeit der Abwicklung, Anzahl, Preis, Transaktionsvolumen, Liquiditätsrichtung, Bearbeitungsgebühren
2021-11-06
13:45:19
1.0001 BTC 61,496.6 USD 1.0001 BTC 吃单 -0.00050002 BTC
Der Code
var position = exchange.GetPosition()
Log("position.length",position.length)
if(position.length > 0){
Log("Amount:", position[0].Amount, "FrozenAmount:", position[0].FrozenAmount, "Price:",
position[0].Price, "Profit:", position[0].Profit, "Type:", position[0].Type,
"ContractType:", position[0].ContractType)
}
Es wird angezeigt:
2021-11-07 14:56:50 Informationen zu Position.length 0
2021-11-07 14:56:50 Informationen {"Instrument":"ETH-USD-SWAP", "InstrumentID":"ETH-USD-SWAP"} Kontrakt aufzustellen: swap
2021-11-07 14:56:50 Hinweis: Futures_OKCoin wurde als Futures-Börse hinzugefügt
Aktuelle Börse: Futures_OKCoin
Was ist der Grund, warum die Daten nicht gelesen werden können? Die API hat Simulationsinformationen hinzugefügt
var Ct = 'swap' //合约类型为永续合约 详见API文档
function main() {
// 清空日志,如不需要,可以删除
LogReset(1)
// 设置价格小数位精度为2位,品种下单量小数位精度为3位
exchange.SetPrecision(QuotePrecision, BasePrecision)
//设置为模拟仓
exchange.IO("simulate", true)
Log("当前交易所:", exchange.GetName())
Log("策略开始")
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 position = exchange.GetPosition()
Log("position.length", position.length)
if (position.length > 0) {
Log("Amount:", position[0].Amount, "FrozenAmount:", position[0].FrozenAmount, "Price:",
position[0].Price, "Profit:", position[0].Profit, "Type:", position[0].Type,
"ContractType:", position[0].ContractType)
}
在实盘配置的时候 添加BTC了 可是不知道为什么 log出来的就是ETH啊
策略: 曲奇测试代码 (最后更新 2021-11-07 23:07:18)
日期: 创建于 2021-11-06 13:43:16 最近开始于 2021-11-08 12:41:18 停止于 2021-11-08 12:41:25
状态: K线周期 3分钟 已停止
托管于 546412 : 8.218.123.197 - linux/amd64 (VPS-12054), ID: 394619
OKEX期货模拟/ETHOKEX期货模拟/BTC
在实盘添加交易所对象时设置的交易对注意下,在策略代码里也可以切换交易对,使用exchange.SetCurrency("XXX_YYY")设置完要重新设置合约代码。可以看下萌新入门:https://www.fmz.com/digest-topic/6857 先了解这些基础概念、功能。

代码是这个样子的
Log("exchanges[0].GetTicker()", exchanges[0].GetTicker())
Log("exchanges[1].GetTicker()", exchanges[1].GetTicker())
Log("exchanges[0]. GetPosition()", exchanges[0].GetPosition())
Log("exchanges[1]. GetPosition()", exchanges[1].GetPosition())
exchanges[0]. GetPosition() [{"Info":{"deltaBS":"","margin":"","availPos":"","cTime":"1636376761683","liqPx":"","mmr":"0.0011116299320592","posCcy":"","thetaBS":"","thetaPA":"","vegaPA":"","instId":"ETH-USD-SWAP","interest":"0","liab":"","mgnRatio":"21842.219147614658","deltaPA":"","imr":"0.001445118911677","optVal":"","posSide":"net","ccy":"ETH","gammaBS":"","last":"4760.37","notionalUsd":"29.99097305872279","avgPx":"4763.22","uTime":"1636376761683","uplRatio":"0","gammaPA":"","lever":"0","mgnMode":"cross","pos":"3","posId":"377924498758184961","tradeId":"35114871","upl":"-0.0000027348184755","vegaBS":"","adl":"1","instType":"SWAP","liabCcy":"","markPx":"4761.152621504205"},"MarginLevel":0,"Amount":3,"FrozenAmount":0,"Price":4763.22,"Profit":-0.0000027348184755,"Margin":0.001445118911677,"Type":0,"ContractType":"swap"}]
这是返回的信息
请问 1)日志文件里为什么【1】是空的呢?2)返回的信息 也没有开仓信息什么的啊?完全懵逼了。。。。。。谢谢梦总

代码是这个样子的
Log("exchanges[0].GetTicker()", exchanges[0].GetTicker())
Log("exchanges[1].GetTicker()", exchanges[1].GetTicker())
Log("exchanges[0]. GetPosition()", exchanges[0].GetPosition())
Log("exchanges[1]. GetPosition()", exchanges[1].GetPosition())
exchanges[0]. GetPosition() [{"Info":{"deltaBS":"","margin":"","availPos":"","cTime":"1636376761683","liqPx":"","mmr":"0.0011116299320592","posCcy":"","thetaBS":"","thetaPA":"","vegaPA":"","instId":"ETH-USD-SWAP","interest":"0","liab":"","mgnRatio":"21842.219147614658","deltaPA":"","imr":"0.001445118911677","optVal":"","posSide":"net","ccy":"ETH","gammaBS":"","last":"4760.37","notionalUsd":"29.99097305872279","avgPx":"4763.22","uTime":"1636376761683","uplRatio":"0","gammaPA":"","lever":"0","mgnMode":"cross","pos":"3","posId":"377924498758184961","tradeId":"35114871","upl":"-0.0000027348184755","vegaBS":"","adl":"1","instType":"SWAP","liabCcy":"","markPx":"4761.152621504205"},"MarginLevel":0,"Amount":3,"FrozenAmount":0,"Price":4763.22,"Profit":-0.0000027348184755,"Margin":0.001445118911677,"Type":0,"ContractType":"swap"}]
这是返回的信息
- 1
