Add # Long Trades and # Short Trades to stats output#1349
Open
wavebyrd wants to merge 1 commit intokernc:masterfrom
Open
Add # Long Trades and # Short Trades to stats output#1349wavebyrd wants to merge 1 commit intokernc:masterfrom
wavebyrd wants to merge 1 commit intokernc:masterfrom
Conversation
Add two new statistics to the backtest results: - # Long Trades: count of trades with positive size (buy positions) - # Short Trades: count of trades with negative size (sell positions) This helps users understand the balance between bullish and bearish positions in their strategies without needing to manually filter the trades dataframe. Fixes kernc#1309 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
Friendly ping on this feature addition. Let me know if you'd like any changes to the implementation! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two new statistics to the backtest results output:
# Long Trades: count of trades with positive size (long positions)# Short Trades: count of trades with negative size (short positions)Example output
Motivation
This helps users gauge how balanced their bull and bear models are without needing to manually filter the trades dataframe. As noted in the issue, this is useful for understanding strategy behavior.
Implementation
Simple addition in
_stats.py- counts trades based on the sign of theSizecolumn:Size > 0= long tradeSize < 0= short tradeTest plan
Fixes #1309
🤖 Generated with Claude Code