okcoin / websocket Goto Github PK
View Code? Open in Web Editor NEWOKCoin WebSocket Api客户端示例
OKCoin WebSocket Api客户端示例
reConnect() in WebSocketBase does not re-connect to authenticated channels such as ok_future_realtrades
webscoket API有太多 rest api的 功能不支持了。。。
Hello,
I have an issue for ok_sub_spot_btc_usd_depth.
{'event':'addChannel','channel':'ok_sub_spot_btc_usd_depth'}
I'm getting this error.
[{"binary":0,"data":{"result":false,"error_msg":"The subscription event type is invalid.","error_code":20103}}]
Can you help me please?
Best Regards
You have to use this configuration to get it working:
wss://real.okex.com:10441/websocket
{'event':'addChannel','channel':'ok_sub_spot_usd_btc_ticker'}
{'event':'addChannel','channel':'ok_sub_spot_usd_btc_depth_20'}
okcoin_websocket.py works fine if url = okcoin.com
if __name__ == "__main__":
url = "wss://real.okcoin.com:10440/websocket/okcoinapi" #if okcoin.cn change url wss://real.okcoin.cn:10440/websocket/okcoinapi
but if I change url to okcoin.cn, I've got this error:
'str' does not support the buffer interface
(python 3.4.4)
doSend("{'event':'addChannel','channel':'ok_sub_spotcny_btc_kline_1min'}");
为什么不用标准的Stringify的JSON? 调用这个JSON.stringify()获得。后台收到后Parse也很方便。我看了Java的实例代码,也同样用的是类似的方法。
I tried the python version on okex.com. Seems the connection closes every 5 min?
没有返回值
How To
Execute the com.okcoin.websocket.test.Example.java
Experienced Behavior
As soon as the line 36 is executed, the Web Socket Client got disconnected:
client.addChannel("ok_sub_spotusd_btc_ticker");
Then it keep getting disconnected due to the reconnecter / re-subscription mechanism (c.f. com.okcoin.websocket.WebSocketBase#MoniterTask.java
).
The program output:
WebSocket Client connected!
WebSocket Client disconnected!
WebSocket Client connected!
[INFO] 2018-03-16 08:28:31,888 BuissnesWebSocketServiceImpl.java:17:WebSocket Client received message: {"event":"pong"}
WebSocket Client disconnected!
WebSocket Client connected!
[INFO] 2018-03-16 08:28:41,814 BuissnesWebSocketServiceImpl.java:17:WebSocket Client received message: {"event":"pong"}
WebSocket Client disconnected!
WebSocket Client connected!
[INFO] 2018-03-16 08:28:51,793 BuissnesWebSocketServiceImpl.java:17:WebSocket Client received message: {"event":"pong"}
WebSocket Client disconnected!
Solution
It seems that the com.okcoin.websocket.WebSocketBase.addChannel(String channel)
build the wrong data message. From the ws_request documentation, the binary field is an integer (0, 1), not a boolean.
Changing the add channel data message to the following value seems to solve the problem:
String dataMsg = "{'event':'addChannel','channel':'" + channel + "','binary':0}";
.
api地址里面有端口号,微信小程序不支持
经过测试发现是sign加密的时候status字段位置写错了,应该放在symbol前面,否则会一直20024验签错误
What timezone is used for date in ok_sub_spot_X_deals
responses ? Currently I get this
[{"binary":1,"channel":"ok_sub_spot_ltc_btc_deals","data":[["145159335","0.01868501","0.02999999","21:19:11","ask"]]}]
It looks like it's GMT+8 time but I want to make sure. Also could you send epoch instead ? It's more reliable.
Starting from today, websocket api returns following value when I subscribe to "ok_sub_futureusd_btc_depth_this_week_10"channel:
b'M\xca1\n\x800\x0c\x05\xd0\xbb\xfc\xd9A\xd7\xae\x1eC$\xa4&\xa2(U\xda\x04\x15\xf1\xee.\x0e\x8e\x0f^w#\xce\x89\xf3\x85\xd0T\x18&NIW\x04\xb0H\xfb\xa1\x82\xb01\xc2\x8d\xac\xc5WC\xb0\xec\xfa\xcf\xdbB\xc5#\x8dn\x9e\xd5\x8bP\xb4\x81Dw\x9b(\xe9it\xa8.\xd4\xd4x\x9e\xfe\x05'
2018-10-29 23:01:16,578 - root - ERROR - Expecting value: line 1 column 1 (char 0)
Jason.loads() can't decode it. Anyone has similar issue or knows what's going on?
Thanks,
Hi. Could you please help me to make a websocket server on my own url to connect my websocket client to it and send and get binary data.
Thank you
应该改为 ok_futureusd_trade
I've noticed that a channel notifying about your orders status sometimes sends the same message twice. Is it a known problem?
您好
请问websocket 用户交易相关的说明文档有吗。github上的文档不全啊。没有相关参数说明。我发送了login请求反应答应状态 20116 :参数不匹配
麻烦给一份相关的说明文档呗,谢谢
websocket.send("{'event':'addChannel', 'channel':'ok_spotcny_order_info', 'parameters': { 'api_key':'XXXX','symbol':'XXXX','order_id':'XXXX','sign':'XXXX' }}");
I have to check the order once a second by myself.
And addChannel twice every second if I have two orders.
我addChannel只收到第一次status=0的, 当被买进去成交了, 并没有通知过来
当我自己撤销了这个订单, 也没有通知我, 这时应该通知给我status=-1:已撤销了
我只能我隔一秒查询一下订单状态
webservice也不支持批量查订单状态,[{"channel":"ok_spotcny_order_info","data":{"orders":[],"result":true}}] 如果我的订单号用逗号隔开,就返回这样的
Actually I was looking for a JS / node example. So I simply tried the web example.
I did set the API Key and Secret. What happens is a website showing me:
ERROR: undefined
DISCONNECTED
Is that example still working?
okCoinWebSocket.websocket.send("{'event':'addChannel','channel':'ok_btcusd_ticker'}");
but return
{"result":false,"error_msg":"param not match.","error_code":20116}
2018/08/07 18:54:27 errrr dial tcp: lookup real.okcoin.cn: no such host
Is the connection restricted for some countries?
on_close() missing 1 required positional argument: 'evt'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.