ENH: Expose long and short trade counts - #1394
Open
AtomicGlance wants to merge 1 commit into
Open
AtomicGlance wants to merge 1 commit into
AtomicGlance wants to merge 1 commit into
Conversation
Author
|
I reran the full backtesting.py test module on this branch (81 passed, 1 skipped). The change reports completed long and short trade counts while leaving the existing statistics unchanged. Before I add any ratio, could you confirm the preferred zero-denominator semantics (omit it, return NaN, or expose a separately documented ratio)? I have deliberately not introduced an arbitrary epsilon. |
AtomicGlance
force-pushed
the
codex/1309-trade-direction-stats
branch
from
September 9, 2026 18:42
7ba804e to
ff7ba70
Compare
This branch has not been deployed
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
Fixes #1309.
Adds
# Long Tradesand# Short Tradesto an optional_extended_statsentry in the result series. This keeps the default report compact while making the counts available asstats['_extended_stats']['# Long Trades'](or through the convenientstats['# Long Trades']lookup).Counts are derived from the signed
Sizecolumn of completed trades. Zero-size records are excluded, and open trades are not counted until they are finalized. No ratio is added because its zero-long-trade behavior needs a separate API decision.This follows the extended-statistics direction suggested in the discussion on the earlier attempts at this issue.
Tests
finalize_trades=Truebacktesting/test/_test.pysuite: 81 passed, 1 skipped