Skip to content

Fix information ratio for DataFrame inputs - #310

Merged
timkpaine merged 3 commits into
pmorissette:masterfrom
russlan23:agent/fix-dataframe-information-ratio
Aug 12, 2026
Merged

timkpaine merged 3 commits into
pmorissette:masterfrom
russlan23:agent/fix-dataframe-information-ratio

Conversation

@russlan23

Copy link
Copy Markdown
Contributor

Problem

calc_information_ratio works for a Series, but a DataFrame's tracking-error calculation returns a Series of per-column standard deviations. The current scalar guard then asks pandas to coerce that Series to a single Boolean and raises ValueError: The truth value of a Series is ambiguous.

Fix

Handle DataFrame results per column. Columns with valid tracking error return their information ratio; zero or missing tracking error returns 0.0, matching the function's existing Series convention.

The regression covers both a varying active-return series and a zero-tracking-error series.

Testing

  • python -m pytest -q - 63 passed
  • python -m ruff check ffn docs/source/conf.py - passed
  • git diff --check - passed

AI assistance was used to scan for the untested DataFrame path and help draft the regression. I reproduced the failure in a clean Python 3.13 container and reviewed the implementation, expectations, and final diff before publication.

@russlan23
russlan23 force-pushed the agent/fix-dataframe-information-ratio branch from 3626cea to 69a6f9a Compare August 8, 2026 09:16
@russlan23
russlan23 marked this pull request as ready for review August 8, 2026 09:17
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>

# Conflicts:
#	tests/test_core.py
@timkpaine
timkpaine merged commit e64bbcc into pmorissette:master Aug 12, 2026
6 checks passed
timkpaine pushed a commit that referenced this pull request Sep 5, 2026
DataFrame-minus-Series subtraction aligns the Series against the frame's
columns, so calc_prob_mom returned an all-NaN array the length of the
calendar instead of one probability per column. Subtract along the index
for that shape, and restore the column labels that t.cdf drops.

This is the same defect fixed in calc_information_ratio by #310 and in
to_excess_returns by #324. calc_prob_mom calls calc_information_ratio,
so the two disagreed on identical inputs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
dev — de41be80 Deployed Aug 12, 2026 by timkpaine via build (3.10, ubuntu-latest, <2, <2) #49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants