Skip to content

[Bug]: DSR skew/kurtosis use mixed moments, rolling attribution betas shift after NaN drop, Hill lower tail includes gains, Polars 2 timestamp and empty-frame crashes #89

Closed

Description

@quantum-like

Affected package version

0.1.8 (main at 2a1c3490)

Environment

Linux, source checkout of main at 2a1c3490 with the repo's dev environment (uv sync); offline test suite.

Observed behavior

  1. Return skewness/kurtosis divide 1/n moments by the n−1 std, understating deflated-Sharpe inputs on short samples.
  2. Rolling attribution fits betas on uncleaned factor rows after NaN return rows are dropped, shifting lagged betas.
  3. The lower Hill tail uses absolute returns, so gains enter the loss tail; with that fixed, tail="both" raises on all-positive samples.
  4. String factor timestamps fail under Polars 2 (cast rejected); empty frames crash outlier filtering (Null-dtype abs()).
  5. Non-mapping YAML/JSON configs raise TypeError instead of the documented ValueError.

Expected behavior

  1. Population moments, exact match with scipy.stats.skew/kurtosis(fisher=False). 2. Betas estimated on the same cleaned rows. 3. Loss-only lower tail; both falls back to the upper tail. 4. ISO strings parse; empty frames pass through. 5. ValueError.

Minimal reproduction

Each case has a focused unit test on quantum-like/diagnostic branch review/fixes (one commit per fix, on top of 2a1c3490). Every test fails on main and passes with its fix:

  • tightened tests/test_evaluation/test_moments.py::test_reference_scipy_skewness and ::test_reference_scipy_kurtosis to an exact SciPy match on 30 observations
  • tests/test_evaluation/test_factor_attribution.py::test_nan_row_matches_predropped_sample
  • tests/test_evaluation/test_distribution.py::test_hill_lower_tail_ignores_right_tail_spikes
  • tests/test_evaluation/test_distribution.py::test_hill_both_on_positive_sample_uses_upper_tail
  • existing TestUtf8Timestamps (both tests were failing before)
  • existing test_empty_dataframe (was failing before)
  • tests/test_config/test_io.py::test_non_mapping_documents_raise_value_error

Compatibility impact

Public behavior or results

Acceptance criteria

Each case has a test that fails on main and passes with the fix (new tests, tightened SciPy reference tests, or previously failing existing tests).

I have a PR ready with these fixes and will link it here.

Amir

Activity

  1. added
    type: bugConfirmed or reported incorrect behavior
    compatibility: affectedHas Python, platform, dependency, or cross-library compatibility impact
    on Oct 7, 2026
  2. stefan-jansen commented on Oct 15, 2026

    @stefan-jansen
    Contributor

    All reported defects are resolved on main through #99, #100, #101, #102 and #103. The focused replacements preserve the original contributor's credit and passed their required checks against the current main base before merge.

    Verification covered the reported DSR moments, NaN attribution alignment, loss-only Hill tail, positive-only combined tail, Polars 2 timestamps, empty-frame filtering and config exception contract. Additional regressions protect ISO datetime strings on Polars 1 and negative-only combined Hill tails. The final config head passed 5483 full local tests (7 skipped), and every focused head passed all 39 applicable hosted checks before merge. Main is dc9768c; package publication remains a separate pending step. Closing as resolved on main.

    Thanks @quantum-like (Amir) for the report and original fixes. AI assistance includes the retained original Cursor Agent commits and Codex's reproduction, focused repairs, testing, review and this closure text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibility: affectedHas Python, platform, dependency, or cross-library compatibility impactpriority: normalNormal planned workstatus: needs-triageAwaiting maintainer classificationtype: bugConfirmed or reported incorrect behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions