Conversation
…Error Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> Agent-Logs-Url: https://github.com/tschm/jquantstats/sessions/383b5562-61f0-4aff-87d7-d1ef4999f95a
Member
|
@copilot: no need to install hypothesis |
Copilot
AI
changed the title
[WIP] Add property-based tests using hypothesis for statistical invariants
Add hypothesis property-based tests for statistical invariants; fix Mar 23, 2026
sortino ZeroDivisionError
…skip Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> Agent-Logs-Url: https://github.com/tschm/jquantstats/sessions/798615a2-215f-4a3d-b5a9-3b66cabcf25c
…' into copilot/add-property-based-tests
Contributor
Author
Removed |
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.
Adds property-based tests using
hypothesisto verify mathematical invariants that must hold for any valid returns series. In doing so, exposes and fixes a latentZeroDivisionErrorinsortino()when no negative returns are present.New: property-based tests (
tests/test_jquantstats/test_properties.py)Six invariants tested across arbitrary generated return sequences:
test_sharpe_nonnegative_for_all_positive_returnstest_max_drawdown_always_nonnegativetest_max_drawdown_zero_for_nonnegative_returnstest_win_rate_in_unit_intervaltest_volatility_nonnegativetest_sortino_nonnegative_for_all_positive_returnsTests use
@pytest.mark.property(already registered inpytest.ini) and@settings(max_examples=100). The module usespytest.importorskip("hypothesis")so tests are automatically skipped when hypothesis is not installed, and run normally when it is available — no changes topyproject.tomlare required.Bug fix:
sortino()ZeroDivisionError (_stats.py)When every return is non-negative,
downside_deviation = 0. Previously this raisedZeroDivisionError; now returns the mathematically correct value:Original prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.