-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ENH: Add the possibility to let unclose trades at end of bt.run (#273) (#343) #359
Conversation
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.
Looks good to me.
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.
Tremendous apologies for the late review. I'll try to catch up. 😅
Would you also add a changelog entry?
backtesting/backtesting.py
Outdated
@@ -984,7 +984,8 @@ def __init__(self, | |||
margin: float = 1., | |||
trade_on_close=False, | |||
hedging=False, | |||
exclusive_orders=False | |||
exclusive_orders=False, | |||
close_all_at_end=True |
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.
The type and amount of feedback following #168 makes me think we should flip the default back to False.
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.
Missing a descriptive docstring below.
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.
Done.
backtesting/backtesting.py
Outdated
@@ -1078,7 +1079,7 @@ def __init__(self, | |||
warnings.warn('Data index is not datetime. Assuming simple periods, ' | |||
'but `pd.DateTimeIndex` is advised.', | |||
stacklevel=2) | |||
|
|||
self._close_all_at_end = close_all_at_end |
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.
Cast to bool()
so passing =1
is supported.
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.
Done.
backtesting/test/_test.py
Outdated
if not self.position: | ||
self.buy() | ||
|
||
self.assertGreater(len( |
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.
Can this be assertEqual
too?
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.
Done
Done. |
Move to #393 |
Hi,
Just saw that this could be interessting for (#343).
Hope it will help.
Cheers.
Continued in #393