0
Follow
0
Followers

function main(){
var param = {
"op": "subscribe",
"args": [
{
"channel" : "instruments",
"instType": "FUTURES"
}
]
}
// 在调用Dial函数时,指定reconnect=true即设置为重连模式,指定payload即为重连时发送的消息。在websocket连接断开后,会自动重连,自动发送消息。
var ws = Dial("wss://wsaws.okex.com:8443/ws/v5/public|compress=gzip_raw&mode=recv&reconnect=true&"+ JSON.stringify(param))
if(ws){
ws.write(JSON.stringify(param))
var pingCyc = 1000 * 20
var lastPingTime = new Date().getTime()
while(1){
var nowTime = new Date().getTime()
var ret = ws.read()
Log("ret:", ret)
if(nowTime - lastPingTime > pingCyc){
var retPing = ws.write("ping")
lastPingTime = nowTime
Log("发送 :ping", "#FF0000")
}
LogStatus("当前时间:", _D())
Sleep(1000)
}
ws.close()
}
}
如题,用以上代码请求okex的websocket接口中的产品频道,总是超时,有谁能给个正确的代码么
Related Recommendations
How to Specify Different Versions of Data for the Rented Strategy by Its Rental Code MetadataAdvanced Tutorial for FMZ Quant platform Strategy WritingElementary Tutorial for FMZ Quant platform Strategy WritingGet Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?
Comment
All comments (1)
- 1
