New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

quantstats

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quantstats - pypi Package Compare versions

Comparing version
0.0.78
to
0.0.79
+10
-0
CHANGELOG.md
Changelog
===========
0.0.79
------
**Hotfix Release**
- Fixed critical circular import error that broke `import quantstats` (#499):
- Root cause: `utils.py` imported `stats` at module level, creating circular dependency
- Fix: Deferred `stats` import inside `to_prices()` and `group_returns()` functions
- Import now works correctly on fresh installations
0.0.78

@@ -5,0 +15,0 @@ ------

+32
-11
Metadata-Version: 2.4
Name: quantstats
Version: 0.0.78
Version: 0.0.79
Summary: Portfolio analytics for quants

@@ -49,6 +49,7 @@ Project-URL: Homepage, https://github.com/ranaroussi/quantstats

[![Python version](https://img.shields.io/badge/python-3.6+-blue.svg?style=flat)](https://pypi.python.org/pypi/quantstats)
[![Python version](https://img.shields.io/badge/python-3.10+-blue.svg?style=flat)](https://pypi.python.org/pypi/quantstats)
[![PyPi version](https://img.shields.io/pypi/v/quantstats.svg?maxAge=60)](https://pypi.python.org/pypi/quantstats)
[![PyPi status](https://img.shields.io/pypi/status/quantstats.svg?maxAge=60)](https://pypi.python.org/pypi/quantstats)
[![PyPi downloads](https://img.shields.io/pypi/dm/quantstats.svg?maxAge=2592000&label=installs&color=%2327B1FF)](https://pypi.python.org/pypi/quantstats)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ranaroussi/quantstats)
[![Star this repo](https://img.shields.io/github/stars/ranaroussi/quantstats.svg?style=social&label=Star&maxAge=60)](https://github.com/ranaroussi/quantstats)

@@ -249,2 +250,22 @@ [![Follow me on twitter](https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60)](https://twitter.com/aroussi)

### Important: Period-Based vs Trade-Based Metrics
QuantStats analyzes **return series** (daily, weekly, monthly returns), not discrete trade data. This means:
- **Win Rate** = percentage of periods with positive returns
- **Consecutive Wins/Losses** = consecutive positive/negative return periods
- **Payoff Ratio** = average winning period return / average losing period return
- **Profit Factor** = sum of positive returns / sum of negative returns
These metrics are **valid and useful** for:
- Systematic/algorithmic strategies with regular rebalancing
- Analyzing return-series behavior over time
- Comparing strategies on a period-by-period basis
For **discretionary traders** with multi-day trades, these period-based metrics may differ from trade-level statistics. A single 5-day trade might span 3 positive days and 2 negative days - QuantStats would count these as 3 "wins" and 2 "losses" at the daily level.
This is consistent with how all return-based analytics work (Sharpe ratio, Sortino ratio, drawdown analysis, etc.) - they operate on return periods, not discrete trade entries/exits.
---
In the meantime, you can get insights as to optional parameters for each method, by using Python's `help` method:

@@ -280,11 +301,11 @@

* [Python](https://www.python.org) >= 3.5+
* [pandas](https://github.com/pydata/pandas) (tested to work with >=0.24.0)
* [numpy](http://www.numpy.org) >= 1.15.0
* [scipy](https://www.scipy.org) >= 1.2.0
* [matplotlib](https://matplotlib.org) >= 3.0.0
* [seaborn](https://seaborn.pydata.org) >= 0.9.0
* [tabulate](https://bitbucket.org/astanin/python-tabulate) >= 0.8.0
* [yfinance](https://github.com/ranaroussi/yfinance) >= 0.1.38
* [plotly](https://plot.ly/) >= 3.4.1 (optional, for using `plots.to_plotly()`)
* [Python](https://www.python.org) >= 3.10
* [pandas](https://github.com/pydata/pandas) >= 1.5.0
* [numpy](http://www.numpy.org) >= 1.24.0
* [scipy](https://www.scipy.org) >= 1.11.0
* [matplotlib](https://matplotlib.org) >= 3.7.0
* [seaborn](https://seaborn.pydata.org) >= 0.13.0
* [tabulate](https://bitbucket.org/astanin/python-tabulate) >= 0.9.0
* [yfinance](https://github.com/ranaroussi/yfinance) >= 0.2.40
* [plotly](https://plot.ly/) >= 5.0.0 (optional, for using `plots.to_plotly()`)

@@ -291,0 +312,0 @@ ## Questions?

@@ -24,3 +24,2 @@ #!/usr/bin/env python

from ._compat import safe_yfinance_download
from . import stats as _stats
from ._compat import safe_concat, safe_resample

@@ -317,2 +316,4 @@ import inspect

"""
from . import stats as _stats # deferred import to avoid circular dependency
# Clean returns data by filling NaN and replacing infinite values

@@ -436,2 +437,4 @@ returns = returns.copy().fillna(0).replace([_np.inf, -_np.inf], float("NaN"))

if compounded:
from . import stats as _stats # deferred import to avoid circular dependency
# Use compounded returns calculation

@@ -438,0 +441,0 @@ return returns.groupby(groupby).apply(_stats.comp)

@@ -1,1 +0,1 @@

version = "0.0.78"
version = "0.0.79"
+31
-10

@@ -1,5 +0,6 @@

[![Python version](https://img.shields.io/badge/python-3.6+-blue.svg?style=flat)](https://pypi.python.org/pypi/quantstats)
[![Python version](https://img.shields.io/badge/python-3.10+-blue.svg?style=flat)](https://pypi.python.org/pypi/quantstats)
[![PyPi version](https://img.shields.io/pypi/v/quantstats.svg?maxAge=60)](https://pypi.python.org/pypi/quantstats)
[![PyPi status](https://img.shields.io/pypi/status/quantstats.svg?maxAge=60)](https://pypi.python.org/pypi/quantstats)
[![PyPi downloads](https://img.shields.io/pypi/dm/quantstats.svg?maxAge=2592000&label=installs&color=%2327B1FF)](https://pypi.python.org/pypi/quantstats)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ranaroussi/quantstats)
[![Star this repo](https://img.shields.io/github/stars/ranaroussi/quantstats.svg?style=social&label=Star&maxAge=60)](https://github.com/ranaroussi/quantstats)

@@ -200,2 +201,22 @@ [![Follow me on twitter](https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60)](https://twitter.com/aroussi)

### Important: Period-Based vs Trade-Based Metrics
QuantStats analyzes **return series** (daily, weekly, monthly returns), not discrete trade data. This means:
- **Win Rate** = percentage of periods with positive returns
- **Consecutive Wins/Losses** = consecutive positive/negative return periods
- **Payoff Ratio** = average winning period return / average losing period return
- **Profit Factor** = sum of positive returns / sum of negative returns
These metrics are **valid and useful** for:
- Systematic/algorithmic strategies with regular rebalancing
- Analyzing return-series behavior over time
- Comparing strategies on a period-by-period basis
For **discretionary traders** with multi-day trades, these period-based metrics may differ from trade-level statistics. A single 5-day trade might span 3 positive days and 2 negative days - QuantStats would count these as 3 "wins" and 2 "losses" at the daily level.
This is consistent with how all return-based analytics work (Sharpe ratio, Sortino ratio, drawdown analysis, etc.) - they operate on return periods, not discrete trade entries/exits.
---
In the meantime, you can get insights as to optional parameters for each method, by using Python's `help` method:

@@ -231,11 +252,11 @@

* [Python](https://www.python.org) >= 3.5+
* [pandas](https://github.com/pydata/pandas) (tested to work with >=0.24.0)
* [numpy](http://www.numpy.org) >= 1.15.0
* [scipy](https://www.scipy.org) >= 1.2.0
* [matplotlib](https://matplotlib.org) >= 3.0.0
* [seaborn](https://seaborn.pydata.org) >= 0.9.0
* [tabulate](https://bitbucket.org/astanin/python-tabulate) >= 0.8.0
* [yfinance](https://github.com/ranaroussi/yfinance) >= 0.1.38
* [plotly](https://plot.ly/) >= 3.4.1 (optional, for using `plots.to_plotly()`)
* [Python](https://www.python.org) >= 3.10
* [pandas](https://github.com/pydata/pandas) >= 1.5.0
* [numpy](http://www.numpy.org) >= 1.24.0
* [scipy](https://www.scipy.org) >= 1.11.0
* [matplotlib](https://matplotlib.org) >= 3.7.0
* [seaborn](https://seaborn.pydata.org) >= 0.13.0
* [tabulate](https://bitbucket.org/astanin/python-tabulate) >= 0.9.0
* [yfinance](https://github.com/ranaroussi/yfinance) >= 0.2.40
* [plotly](https://plot.ly/) >= 5.0.0 (optional, for using `plots.to_plotly()`)

@@ -242,0 +263,0 @@ ## Questions?