vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 31
声望: 0

在使用deribit API 接口时,连接实盘账户时可以正常读取到账户的信息和持仓,但在对交易记录解析时存在一些bug。

报错1:
description

原因:deribit 在下单时除了有limit 和 market order之外,还存在 stop_limit 和stop_market order,但这两笔订单类型并没有在ORDERTYPE_VT2DERIBIT里被转换为vnpy里的OrderType

附件1: deribit 下单界面的几种订单类型
description

部分解决方案:在第46行添加 OrderType.STOP: "stop_market", 将stop_market order 类型 转换为vnpy里可识别的OrderType.STOP。
不过deribit 里还有另外一种stop_limit order 类型,我在想如果这种也转换成OrderType.STOP是否会存在潜在的其他下单问题。
description

由于我在deribit 的order 类型只有stop_market ,所以按照我上述的修改之后,我遇到的上述报错代码可以运行了,但又遇到了下面的问题:
description
原因是 OrdarData里面的data数据中,"price":"market_price",而不是应该具体价格。

对应于我在deribit 挂的stop order截图如下:
description

希望相关的bug可以得到官方社区的关注和修复,谢谢!

Member
avatar
加入于:
帖子: 2038
声望: 134

有bug类的问题建议可以去gitub开个issue

Member
avatar
加入于:
帖子: 31
声望: 0

错误依然存在,我去把这个帖子链接放在issue上

[2020-12-30T13:05:55.468061]: Unhandled WebSocket Error:<class 'KeyError'>
LastSentText:
{"jsonrpc": "2.0", "id": 4, "method": "public/get_instruments", "params": {"currency": "ETH", "expired": false}}
LastReceivedText:
{"jsonrpc":"2.0","id":2,"error":{"message":"unauthorized","code":13009},"usIn":1609304755397684,"usOut":1609304755397757,"usDiff":73,"testnet":false}
Exception trace:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\api\websocket\websocket_client.py", line 216, in _run
self.on_packet(data)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\gateway\deribit\deribit_gateway.py", line 349, in on_packet
callback(packet)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\gateway\deribit\deribit_gateway.py", line 361, in on_access_token
data = packet["result"]
KeyError: 'result'
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\api\websocket\websocket_client.py", line 216, in _run
self.on_packet(data)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\gateway\deribit\deribit_gateway.py", line 349, in on_packet
callback(packet)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\vnpy\gateway\deribit\deribit_gateway.py", line 361, in on_access_token
data = packet["result"]
KeyError: 'result'

Process finished with exit code -1073741819 (0xC0000005)

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号