-
Notifications
You must be signed in to change notification settings - Fork 493
fix paradex mismatch error #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,13 +250,11 @@ async def _handle_order_result(self, order_result) -> bool: | |
| try: | ||
| cancel_result = await self.exchange_client.cancel_order(order_id) | ||
| if not cancel_result.success: | ||
| self.order_canceled_event.set() | ||
| self.logger.log(f"[CLOSE] Failed to cancel order {order_id}: {cancel_result.error_message}", "ERROR") | ||
| else: | ||
| self.current_order_status = "CANCELED" | ||
|
|
||
| except Exception as e: | ||
| self.order_canceled_event.set() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果 set event,下面会无法获取最新的 order_filled_amount。并且我目前理解出错时不 set event 是更自然的:因为无法知道 cancel 是否成功,所以不在这里直接 set event 而是等待 order_update_handler 来 set(如果理解有误请指正)
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码因为需要兼顾三个交易所,所以确实有点绕。我们试图取消 paradex 的订单后的逻辑是这样的:
这里的问题是,在第二种情况下,会有race condition。也就是有可能在websocket还没来得及更新,设定self.order_filled_amount 为 order size之前,代码已经到了下止盈单的部分。 我想这也是为什么当延迟比较低时,这个问题不会发生。
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯嗯,那按照这个 PR 的改法去掉 event.set() 会有逻辑问题吗 这处改动如果群主觉得不太好也可以只合并另一处 filled_size 的改动,毕竟不止有这一处有网络延迟问题,要解决所有的网络延迟问题就很麻烦了,省事儿的做法还是建议大家都去用 aws 东京( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 开源项目群策群力,不断发展,赞 |
||
| self.logger.log(f"[CLOSE] Error canceling order {order_id}: {e}", "ERROR") | ||
|
|
||
| if self.config.exchange == "backpack": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里你的逻辑是正确的,但是代码可能不小心写错了。
paradex 返回内容没有 filled_size,只有 remaining_size, 所以这里应该:
remaining_size = Decimal(order_data.get('remaining_size', 0))这里修复了之后也可以避免 partial fill 时无法正确地下止盈单的问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯已修复