Drawdown Severity Histogram [oisigma] — Python Companion & Episode Distribution Toolkit
Most drawdown information on a chart is a single number: how far price is from its peak right now. That number is hard to judge on its own. Is a 7% drawdown a routine dip or a rare event? Historically, how deep do drawdowns on an instrument go, and how long do they take to recover?
oisigma-drawdown is the open-source Python companion to the free public TradingView indicator Drawdown Severity Histogram [oisigma] developed by Oisigma.
It scans a price series, identifies every completed drawdown episode, bins those episodes by maximum percentage depth, and computes depth percentiles (median, 90th, 95th, deepest) and time-under-water duration statistics—while tracking the currently open, unfinished drawdown separately so it does not bias the completed counts.
Important: This is a descriptive tool, not a predictive one. It measures what has already happened on the loaded history. It does not forecast price, does not generate buy or sell signals, and says nothing about whether a current drawdown will deepen or reverse.
Live TradingView Indicator (Free Community Script)
To plot the histogram and summary table directly on any TradingView chart:
For Oisigma's research on calibrated expected ranges and empirical volatility band audits across 97 years of S&P 500 data and 40 cross-asset instruments:
- Oisigma Home (
oisigma.com) - Empirical Proof (
oisigma.com/proof) - Working Paper (
oisigma.com/paper) - Oisigma Research Blog (
oisigma.com/blog)
How It Counts Drawdown Episodes
- Episode Definition: An episode begins at a peak, runs through its lowest point, and ends when price sets a new peak. At that moment its maximum depth (%) and its duration in bars (time under water) are recorded, and a new episode begins.
- Completed vs. Open Drawdown Separation: Only completed episodes enter the histogram and the percentile statistics. The drawdown that is still open is tracked separately and highlighted in its provisional depth bin, because it has not finished yet and including it would bias the counts.
- Minimum Depth Floor (
min_depth_pct, default1.0%): Episodes shallower than 1% are excluded by default so trivial one-bar dips below a peak do not dominate the shallowest bucket and distort the median. - Close vs. High/Low Consistency: By default, closing prices are used for both peaks and troughs for an internally consistent series. When High/Low mode is used, on a bar that sets a new peak, the intrabar order of high and low is unknown, so that bar's low is not counted toward the next trough.
Installation
pip install oisigma-drawdown
Quickstart in Python
import math
from oisigma_drawdown import analyze_drawdown_episodes
# Example price series
closes = [100.0 * math.exp(0.0015 * i - 0.018 * math.sin(i * 0.15)) for i in range(500)]
summary = analyze_drawdown_episodes(
closes,
bin_width_pct=5.0, # 5% depth buckets
min_depth_pct=1.0, # Ignore trivial dips shallower than 1%
)
print(summary.format_report())
Limitations to Know Before Using It
- Statistics describe the loaded history only: A short price series gives unreliable percentiles, so load as much historical data as possible.
- Deep drawdowns are rare: Even with long history, the right-hand tail bins and the 95th percentile rest on a small number of completed episodes.
- Open drawdown comparison is provisional: Compare percentiles with the open drawdown's deepest point so far, bearing in mind an unfinished drawdown can still deepen before recovering to a new peak.
Related Oisigma Research & Links
Metadata
Release files for oisigma-drawdown 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oisigma_drawdown-0.1.0.tar.gz | 9.9 kB | Without provenance | Details for oisigma_drawdown-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oisigma_drawdown-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for oisigma_drawdown-0.1.0-py3-none-any.whl |
Total release size: 19.1 kB
Release files / oisigma_drawdown-0.1.0.tar.gz
| Download URL | oisigma_drawdown-0.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79edbaec036012fc1e464b8a3c79be5406e215a4d841302256fa3d2a89db7d61
|
|
BLAKE2b-256 checksum How to use checksums |
51cee4854276fef01af661e5adcbd8866cab3b23d0fd0e550931c0be8bef363c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / oisigma_drawdown-0.1.0-py3-none-any.whl
| Download URL | oisigma_drawdown-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66668df38fcfbaf0fabcebcb8979c57d0b2e03d51114215672c09bcd8e4878d0
|
|
BLAKE2b-256 checksum How to use checksums |
1e5e04756cbff0c6524583f3dc93b786a275a93e42b1bcec66acfa815612e55e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for oisigma-drawdown 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.