gateio / gateapi-python

256 stars 96 forks source link

futures contracts websocket signature method #8

Closed Jastyle closed 5 years ago

Jastyle commented 5 years ago

合约交易获取交易的订单,需要权限部分,签名是如何实现的,SIGN怎么生成的。websocket方式,不是rest方式。 from websocket import create_connection ws = create_connection("wss://fx-ws-testnet.gateio.ws/v4/ws") ws.send('{ "time" : 123456, "channel" : "futures.orders", "event": "subscribe", "payload" : ["20011", "BTC_USD"], "auth": { "method": "api_key", "KEY":"xxxx", "SIGN": "xxxx" }}')

revilwang commented 5 years ago

https://www.gate.io/docs/futures/ws/index.html#api-overview

Jastyle commented 5 years ago

感谢!还有个问题,文档里要对Signature string concatenation method: channel=&event=&time=

revilwang commented 5 years ago

不需要,因为payload内容包装在了请求体里,如果服务端尝试从消息体里反序列化payload再序列化验证签名,可能会导致序列化的结果与客户端实际发送的不一致,因此payload不会包含在签名算法里

Jastyle commented 5 years ago

谢谢,还有个小问题,https://www.gate.io/docs/futures/ws/index.html#orders-subscription,要传递user id参数,翻遍文档找不到如何获取该参数

revilwang commented 5 years ago

用户ID可以从个人控制台获取

Jastyle commented 5 years ago

这个是唯一的么

revilwang commented 5 years ago

是的,每个用户都有固定的一个ID

Jastyle commented 5 years ago

非常感谢~~