-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Is it possible to track custom stats in results? Is it possible to use tick data? #130
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
Comments
Thanks!
Sure. I think something like the following might work. You can access the ran class MyStrategy(Strategy):
...
def next(self):
...
for trade in self.trades:
trade.max_pl = max(getattr(trade, 'max_pl', -np.inf), trade.pl)
...
stats = bt.run()
mean_max_pl = np.mean([trade.max_pl for trade in stats._strategy.closed_trades]) |
No, OHLC is hardcoded, but there's no lower bound: you can have 5-second OHLC bars or even 1-tick OHLC bars (O=H=L=C), limited only by your space/time resources. |
I try to pass some custom data with trades like you say: It shows only standard information. How to see my custom data (aka custom column) in trades after the backtest has run? |
It won't, for the time being, automatically show in trades DataFrame nor in for trade in stats._strategy.closed_trades:
this = trade.custom_data
... E.g. to add it to the data frame: stats._trades.assign(custom_data=[t.custom_data for t in stats._strategy.closed_trades]) |
I need a way, per trade to track the maximum profit it can have before it gets stopped out or before the market closes/week ends. Then at the end results I need to tally this property as well like what's the maximum "maximum profit" from all the trades. Is this possible within the library? Can I append custom data on each trade? Thanks, great repo btw!
Edit: Follow up question, is it possible to use tick data instead, then resample it to whatever timeframe I need? thanks!
The text was updated successfully, but these errors were encountered: