calmar() raises ZeroDivisionError when returns have no drawdown
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start with the calmar implementation in quantstats.stats and trace how it computes max_dd and divides the CAGR ratio for Series and DataFrame inputs. Run the two examples from the issue, then add or find tests covering a return series with no drawdown in both shapes. Done means neither input raises and both produce the same result, either inf or nan.
Written by the indexing model from the issue text.
Description
qs.stats.calmar crashes on a Series that never goes down, for example a short sample where every day is positive.
import numpy as np, pandas as pd, quantstats as qs
rising = pd.Series(np.linspace(0.001, 0.01, 20), index=pd.bdate_range("2024-01-01", periods=20))
qs.stats.calmar(rising) # ZeroDivisionError: float division by zero
qs.stats.calmar(rising.to_frame("a")) # a inf
The max drawdown is 0, and calmar ends with return cagr_ratio / abs(max_dd). A Series and a one-column DataFrame of the same data also behave differently.
Expected: both inputs give the same result, either inf or nan, without an exception.
- Dominant language
- Python
- Stars
- 7.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ranaroussi/quantstats
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
ranaroussi/quantstats#592 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ranaroussi/quantstats#591 ·
-
Matplotlib tick-label warning with pandas 3.1.0Possibly taken @jackiectl2 claimed this 40 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ranaroussi/quantstats#582 ·
-
Drawdown functions fail on supported RangeIndex inputsPossibly taken @Cyber-Marty claimed this 51 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranaroussi/quantstats#575 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
ranaroussi/quantstats#586 · 1 comment ·
All issues in ranaroussi/quantstats
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choicePossibly taken @beartester34 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelscope/evalscope#2330 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Distribution plot crashes when a numeric feature is constant in the train or test setPossibly taken @adembilge claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
MAIF/shapash#847 · 1 comment ·
Maintainers usually reply within 10 days