Skip to content
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

Automatically cancel trigger orders if position has been closed/flipped #452

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

aforaleka
Copy link
Contributor

  • add logic to cancel trigger orders when its associated position has been closed or flipped
  • tested locally and works on both cross and isolated positions' orphaned trigger orders

An order will be canceled if it meets the following conditions:

  • order is a conditional order, reduce-only
  • order is untriggered or open status
  • order's market has no position or position was flipped (i.e. different direction than the order's side)

followup:

  • currently cancel reason will say user canceled it, not ideal but there'll be extra logic needed to override indexer's cancel reason and we want to ship this asap
  • tests :)

@aforaleka aforaleka force-pushed the cancel-trigger-orders-automatically branch from 30f560c to 5e5f318 Compare June 17, 2024 21:54
@aforaleka aforaleka force-pushed the cancel-trigger-orders-automatically branch from b4ba7eb to 04f2aa0 Compare June 17, 2024 21:54
@@ -778,7 +812,8 @@ internal class SubaccountSupervisor(
payload: HumanReadableCancelOrderPayload,
analyticsPayload: IMap<String, Any>?,
uiClickTimeMs: Double,
isTriggerOrder: Boolean = false,
fromSlTpDialog: Boolean = false,
isOrphanedTriggerOrder: Boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm do we use isOrphanedTriggerOrder here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gr8888 catch

@aforaleka aforaleka force-pushed the cancel-trigger-orders-automatically branch from 733819d to 98e4a95 Compare June 17, 2024 22:51
@aforaleka aforaleka force-pushed the cancel-trigger-orders-automatically branch from cd77d5a to dc14199 Compare June 17, 2024 22:52
@aforaleka aforaleka merged commit 95aee0d into main Jun 17, 2024
3 of 4 checks passed
@aforaleka aforaleka deleted the cancel-trigger-orders-automatically branch June 17, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants