Trong tài liệu api của FMZ đã xem một nửa ngày, chỉ có một hàm dials như vậy liên quan đến loại ws, cảm thấy mô tả vẫn chưa đủ rõ ràng, không có hệ thống
Tôi không có trình độ cao, tôi muốn thử bitmex's ws-type api, để có được các thông tin cần xác minh như vị trí, tài khoản, không hiểu chức năng dial, nhưng tôi đã có thể làm điều đó.
Tôi đã gửi một đơn xin việc, và khách hàng đã yêu cầu tôi tự mình đi tìm trường hợp, tìm tài liệu của sàn giao dịch, trường hợp của Strategy Square.
Các trường hợp liên quan đến Strategy Square - sử dụng giao thức websocket và HMAC mới nhất trên nền tảng để lấy chữ ký, thay đổi vị trí đã được chuyển đến WeChat - là một ví dụ điển hình.
Đây là mã cũ, lỗi cũ, xin hãy đổi mã mới, cảm ơn.
function main() {
var APIKEY = "your Access Key(Bitmex API ID)"
var expires = parseInt(Date.now() / 1000) + 10
var signature = exchange.HMAC("sha256", "hex", "GET/realtime" + expires, "{{secretkey}}")//secretkey在执行时自动替换,不用填写
var client = Dial("wss://www.bitmex.com/realtime", 60)
var auth = JSON.stringify({args: [APIKEY, expires, signature], op: "authKeyExpires"})
var pos = 0
client.write(auth)
client.write('{"op": "subscribe", "args": "position"}')
while (true) {
bitmexData = client.read()
if(bitmexData.table == 'position' && pos != parseInt(bitmexData.data[0].currentQty)){
Log('position change', pos, parseInt(bitmexData.data[0].currentQty), '@')
pos = parseInt(bitmexData.data[0].currentQty)
}
}
}
这个例子测试过了,没有什么问题,有数据返回。
您是不是 这个例子里没填 自己的 api ID ?
var APIKEY = "your Access Key(Bitmex API ID)"
这个里面 your Access Key(Bitmex API ID) 这个字符串要你替换成自己的 Bitmex 账号 API ID 的。
梦总,用这段代码返回的数据,其时间戳,比当前时间要滞后几分钟,例如,我获取bitmex的quote,获取的时间戳ISO时间,折算为北京时间为8月7日6点9分18秒,实际时间为2019-08-07 06:12:37,滞后3分钟,我也跟rest获取的ticker比对,确实错了,这是啥情况呢?求指教:
2019-08-07 06:12:37 信息 {"table":"quote","action":"insert","data":[{"timestamp":"2019-08-06T22:09:18.150Z","symbol":"XBTUSD","bidSize":34939,"bidPrice":11353....
2019-06-03 12:00:52 信息 {"info":"Welcome to the BitMEX Realtime API.","version":"2019-05-29T18:35:35.000Z","timestamp":"2019-06-03T04:00:51.178Z","docs":"https://www.bitmex.com/app/wsAPI","limit":{"remaining":37}}
2019-06-03 12:00:50 信息 {"info":"Welcome to the BitMEX Realtime API.","version":"2019-05-29T18:35:35.000Z","timestamp":"2019-06-03T04:00:49.503Z","docs":"https://www.bitmex.com/app/wsAPI","limit":{"remaining":38}}
2019-06-03 12:00:49 信息 {"success":true,"request":{"args":["Zp8Ub0Iom7SxwDXuB5oXetWV",1559534457,"1cf5ce9c114b6991bfde394cdfebab3b36db9ea0e7a365ed7c4328a6f3ce4efe"],"op":"authKeyExpires"}}
2019-06-03 12:00:48 信息 {"info":"Welcome to the BitMEX Realtime API.","version":"2019-05-29T18:35:35.000Z","timestamp":"2019-06-03T04:00:47.720Z","docs":"https://www.bitmex.com/app/wsAPI","limit":{"remaining":39}} 这是不是提示需要重连?
TypeError: cannot read property 'write' of null at main (FILE:8) 这个报错是 程序错误,估计是您改了什么代码导致的。
另外 请先确保您的 托管者所在服务器 可以访问到 OKEX 接口。
目前 只有海外服务器才能访问到OKEX 了。
我把positon换成wallet后,经常报错:错误 TypeError: cannot read property 'write' of null at main (FILE:8)
2019-06-03 12:09:30,错误 websocket: bad handshake
回复的是你的这个问题,麻烦看下。
- 1



