Skip to content

Commit b93ebb1

Browse files
committed
Add raw_data parameter to plot_timeseries and drawdown functions
- Introduced a new `raw_data` parameter in `plot_timeseries` to skip cumulative transformations for raw data. - Updated the `drawdown` function to pass `raw_data=True`, ensuring drawdown data is not cumulatively transformed.
1 parent 91792f3 commit b93ebb1

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

quantstats/_plotting/core.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def plot_timeseries(
350350
subtitle=True,
351351
savefig=None,
352352
show=True,
353+
raw_data=False,
353354
):
354355
"""
355356
Plot returns as a time series line chart
@@ -422,15 +423,16 @@ def plot_timeseries(
422423
returns = (returns / returns.std()) * bmark_vol
423424

424425
# ---------------
425-
# Transform data based on compound setting
426-
if compound:
427-
returns = _stats.compsum(returns)
428-
if isinstance(benchmark, _pd.Series):
429-
benchmark = _stats.compsum(benchmark)
430-
else:
431-
returns = returns.cumsum()
432-
if isinstance(benchmark, _pd.Series):
433-
benchmark = benchmark.cumsum()
426+
# Transform data based on compound setting (skip for raw data like drawdowns)
427+
if not raw_data:
428+
if compound:
429+
returns = _stats.compsum(returns)
430+
if isinstance(benchmark, _pd.Series):
431+
benchmark = _stats.compsum(benchmark)
432+
else:
433+
returns = returns.cumsum()
434+
if isinstance(benchmark, _pd.Series):
435+
benchmark = benchmark.cumsum()
434436

435437
# Apply resampling if specified
436438
if resample:

quantstats/_plotting/wrappers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ def drawdown(
11871187
subtitle=subtitle,
11881188
savefig=savefig,
11891189
show=show,
1190+
raw_data=True, # Skip cumulative transformation for drawdown data
11901191
)
11911192
if not show:
11921193
return fig

0 commit comments

Comments
 (0)