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

Adds handling of FOK orders status getting stuck #684

Conversation

lunswor
Copy link
Contributor

@lunswor lunswor commented Aug 15, 2023

Fixes #681

@@ -29,6 +29,9 @@ def execute_place(
if instruction_report.status == "SUCCESS":
if instruction_report.order_status == "PENDING":
pass # async request pending processing
elif instruction_report.order_status == "EXPIRED":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how this may effect other orders

@lunswor lunswor marked this pull request as ready for review August 15, 2023 18:15
@mzaja
Copy link
Contributor

mzaja commented Aug 15, 2023

Awesome work! Do you have responses from the Betfair order stream when placing FOK bets (matched/cancelled) by any chance? I assumed the order goes straight from PENDING -> EXECUTION_COMPLETE when implementing FOK simulation, but I would like to verify that against a live market.

order.responses.placed()
order.bet_id = current_order.bet_id
log_control(OrderEvent(order))
# pickup FOK orders
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't a FOK order have a bet_id in the place response?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a good point. It is provided by Betfair: #681 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to happen when the order comes back in the stream before we get the instruction report and set the bet_id. Just tested and think the fix in betfairexecution.py should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would explain the stochastic nature of this bug. However, I am quite surprised this has not been picked up on earlier because it's not just FOK bets that are affected by the place response arriving later than the order update.

@liampauling liampauling changed the base branch from master to release/2.5.0 October 5, 2023 07:58
@liampauling liampauling merged commit 83e3375 into betcode-org:release/2.5.0 Oct 5, 2023
6 checks passed
@lunswor lunswor deleted the fill-or-kill-orders-stuck-executable branch October 5, 2023 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fill or kill orders stuck in executable state
3 participants