Skip to content

Separate statistics for long and short trades? #194

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

Closed
s-kust opened this issue Dec 12, 2020 · 3 comments · Fixed by #281
Closed

Separate statistics for long and short trades? #194

s-kust opened this issue Dec 12, 2020 · 3 comments · Fixed by #281
Labels
enhancement New feature or request good first issue Good for newcomers question Not a bug, but a FAQ entry

Comments

@s-kust
Copy link

s-kust commented Dec 12, 2020

After the backtest run, we see the statistics. It is very good! Is there any simple way to see that statistics separately for long ans short trades?

@kernc
Copy link
Owner

kernc commented Dec 12, 2020

No "simple" way. You'd have to analyze stats._trades yourself.

Might be up for exposing:

compute_stats(trades: pd.DataFrame,
              equity: Sequence[float],
              ohlc_data: pd.DataFrame,
              risk_free_rate: float = 0) -> pd.Series

in backtesting.lib module if someone contribs it. 👍 That way, we also tackle #71.

@kernc kernc added enhancement New feature or request question Not a bug, but a FAQ entry labels Dec 12, 2020
@kernc kernc changed the title How to see the statistics separately for long ans short trades? Separate statistics for long and short trades? Dec 12, 2020
@s-kust
Copy link
Author

s-kust commented Dec 19, 2020

compute_stats

Is it possible to call that function explicitly somehow to obtain separate statistics for long and short trades?

@kernc
Copy link
Owner

kernc commented Aug 3, 2021

It is since v0.3.2 possible to use backtesting.lib.compute_stats and do something like:

stats = Backtest(GOOG, MyStrategy).run()
only_long_trades = stats._trades[stats._trades.Size > 0]
long_stats = compute_stats(stats=stats, trades=only_long_trades,
                           data=GOOG, risk_free_rate=.02)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Not a bug, but a FAQ entry
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants