-
Notifications
You must be signed in to change notification settings - Fork 60
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
all_or_nothing transactions #590
base: master
Are you sure you want to change the base?
all_or_nothing transactions #590
Conversation
flumine/execution/transaction.py
Outdated
@@ -224,5 +251,15 @@ def __enter__(self): | |||
return self | |||
|
|||
def __exit__(self, exc_type, exc_val, exc_tb): | |||
if self.all_or_nothing: |
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.
Move to below ln264 to keep things quick
renaming all_or_nothing to atomic clearing the transaction if there's a failure.
Thanks for the comments. I have updated the PR accordingly. |
Next problem is the |
flumine/execution/transaction.py
Outdated
@@ -146,6 +168,9 @@ def replace_order( | |||
def execute(self) -> int: | |||
packages = [] | |||
if self._pending_place: | |||
for order, market_version in self._pending_place: |
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.
We can't delay like this as it will result in the controls that act on live/open/count orders/trades incorrect
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.
I see that RunnerContext.place
updates these fields:
- invested
- datetime_last_placed
- trades
- live_trades
I've updated the transaction to remove failed trades from live_trades, but am unsure whether the other 3 fields need to be reverted as well.
If a transaction contains multiple orders on the same runner, working out which datetime_last_placed to set it to could be tricky.
Similarly for RunnerContext.trades, if a trade contains multiple orders, but only one of them fails, which element from RunnerContext.trades should we remove?
…cute(...)." This reverts commit 4dd5ce6.
This is to address issue:
#542