Repository navigation
v0.0.82 - Correctness and statistical fixes
Correctness fixes
- Fixed
max_drawdown()andto_drawdown_series()returning drawdowns that
depended on the price level of the input (#541). The baseline is now taken
from whether the series was rebuilt from returns or was a real price series,
instead of guessing from magnitude thresholds. A price series scaled by any
constant now reports the same drawdown. - Fixed
_prepare_prices()filling a missing price with0, which reported a
spurious -100% drawdown for any gapped price series (#545). Gaps now carry
the last known price forward. - Fixed weekly aggregation raising
AttributeError: 'DatetimeIndex' object has no attribute 'week'on pandas >= 2.0 (#533).aggregate_returns()now uses
isocalendar().weekfor the"week","eow"and"W"periods. - Fixed
cagr(compounded=False)turning a loss worse than -100% into a
positive return (#548). Terminal wealth at or below zero now yieldsNaN
rather than a value produced by taking a root of a negative number. - Fixed the prepared-returns cache returning a DataFrame to a caller that
passed a Series (#544). Container type, column names, dtypes and the
risk-free flag are now part of the cache key. - Fixed
information_ratio()preparing the benchmark twice, which re-ran
price/return detection on already-normalized data. - Fixed
rolling_volatility()passing its rolling period into the risk-free
rate argument.
Statistical corrections
- Fixed
probabilistic_sharpe_ratio()/probabilistic_ratio()(#551):
the raw-kurtosis formula was being fed excess kurtosis, the estimator
standard error now follows Bailey & Lopez de Prado, andrfis routed into
the underlying Sharpe/Sortino rather than dropped. Theannualizeargument
is documented as inert; it never affected the result. - Behavior change:
kelly_criterion()now divides by the average loss,
giving the position size the Kelly formula actually defines. The previous
result was scale-invariant and therefore dimensionally wrong; returned
values will differ in magnitude from 0.0.81 and earlier. autocorr_penalty()now guards against series shorter than two
observations and zero-variance input instead of emitting a numpy
RuntimeWarningand propagatingNaN(#525).
API
calmar()andrar()accept acompoundedflag (#512), and
reports.metrics()threads its owncompoundedsetting into both.- Report risk-free rates may now be a
pd.Seriesof time-varying rates
(#524). Rates are aligned onto the return dates, carried forward across
gaps, and subtracted row-wise for DataFrame input. The reported
"Risk-Free Rate" row shows the average over the period. reports.html(),reports.full()andreports.basic()now forward
match_datestometrics()(#536), so the table and the plots describe
the same date range.
Crash fixes
- Fixed
reports.metrics()raisingUnboundLocalErrorfor a single-column
DataFrame. - Fixed
reports.html()andreports.full()raisingTypeErrorwhen given a
DataFrame together with a stringstrategy_title. - Fixed a
KeyErrorin the drawdown table when the metrics frame came back
with a single-level MultiIndex. sharpe(),sortino(),rolling_sharpe()androlling_sortino()no
longer raise "truth value of a Series is ambiguous" whenrfis a Series.
Compatibility
- Fixed
ValueError: Invalid frequency: MEon pandas 2.0 and 2.1. The
codebase spells frequencies the pandas 2.2 way (ME/QE/YE), which
older versions reject; the compatibility layer now translates aliases in
both directions. Reports and plots were unusable on those versions. - Raised the declared pandas floor from
>=1.5.0to>=2.0.0to match what
is actually supported and tested. pandas 1.5 never worked with recent
releases.
Reports
- Fixed the "10Y (ann.)" column covering eleven calendar years (#523).
Internals
_prepare_returns()no longer inspects the call stack (inspect.stack())
to decide whether to apply the risk-free rate; callers pass an explicit
apply_rfargument.
CI
- Repaired the test workflow, which was disabled and pointed at
test_fixes.pyandtests/test_compatibility.py(#540) - neither file has
existed for several releases. It now runspytest tests/across a
Python 3.10-3.13 x pandas x numpy matrix, plus a latest-versions job and a
ruff lint job. - Repaired the publish workflow, which still called
python setup.py;
setup.pywas removed in 0.0.78 in favour of pyproject.toml + hatchling. - Bumped
actions/checkoutandactions/setup-pythonto v7 (#526, #534). - Removed the abandoned
.travis.yml(Python 3.6-3.9,nosetests). - Added a regression test module covering every fix above.
- Applied
ruffautofixes and formatting across the codebase, and
grandfathered the remaining violations per file so lint is enforced on new
code.