-
-
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
Logging Orders #53
Comments
Is the Entry Direction column not longer available ? |
This was overhauled in #47 (released in 0.2.0), rendering this issue obsolete. The new way to access individual trades data is: stats = bt.run()
stats._equity_curve # equity/drawdown data
stats._trades # trade data |
I'm curious about orders though, not trades. |
@bscully27 You could always continue to log orders yourself: 😁 class MyStrategy(Strategy):
def init(self):
self.orders_log = []
...
def buy(self, *args, **kwargs):
super().buy(*args, **kwargs)
self.orders_log.append(self.orders[-1])
def next(self):
...
self.buy(...)
stats = Backtest(...).run()
orders_placed = stats._strategy.orders_log |
@lkmh In fact, you can infer the |
Dear author, the information about accessing individual trades and orders is very useful and even essential. Would you please make it easier to find? I mean, add this information into the manuals and examples. When I tried the following code I got an error
I have found the solution here. This works better: |
There's some new related discussion in #197. |
Desired Behavior
To dig into each backtest order, specifically to evaluate target prices which I don't believe are working correctly or I'm not calling properly. Didn't see an example in the docs.
I tried adding self.orders to _broker.log but without success - the idea was use copy.copy(self.orders) in backtesting.py for a PIT (point in time) snapshot.
So 2 points I'd like addressed:
Additional Log Attempt
In class _Broker.next(), I called this function when opening or closing a position.
then in class _Broker:
Steps to Reproduce
The 3rd line should have been closing the position when target_price was hit.
Additional info
The text was updated successfully, but these errors were encountered: