arro
arro is a small quantitative-finance library for calculating return and
risk metrics from periodic return series.
Input contract
Metric functions currently accept a pandas.Series whose:
- values are finite decimal returns, such as
0.01for 1%; - index is a unique, ascending
pandas.DatetimeIndex; - values contain no missing data; and
- returns are never below
-1.0, because an unlevered investment cannot lose more than 100% of its value.
The metric layer is intentionally strict. Data-provider integrations should normalize prices and timestamps before calling these functions rather than silently repairing malformed data during a calculation.
import pandas as pd
import arro
returns = pd.Series(
[0.01, -0.02, 0.015, 0.003, -0.005],
index=pd.date_range("2024-01-01", periods=5, freq="B"),
)
print(arro.cumulative_return(returns))
print(arro.annualized_return(returns))
print(arro.volatility(returns))
print(arro.sharpe_ratio(returns, rf=0.04))
print(arro.sortino_ratio(returns, rf=0.04))
print(arro.max_drawdown(returns))
print(arro.calmar_ratio(returns))
Prices versus returns
arro metrics operate on returns, not prices. Convert a price series with
Pandas before calculating metrics:
returns = prices.pct_change().dropna()
For adjusted equity data, use an adjusted price field so stock splits and distributions do not appear as investment losses. The correct field depends on the provider and its adjustment settings.
Annualization
When periods_per_year is omitted, arro infers these regular frequencies:
| Frequency | Periods per year |
|---|---|
| Business day or day | 252 |
| Week | 52 |
| Month | 12 |
| Quarter | 4 |
| Year | 1 |
Pass periods_per_year explicitly for irregular or intraday data:
arro.volatility(minute_returns, periods_per_year=252 * 390)
Daily timestamps are ambiguous: US equity analytics normally use 252, while
continuously traded assets may use 365. Use
periods_per_year=365 for daily crypto data when that matches the intended
methodology.
Metric conventions
- Annualized return uses geometric compounding.
- Volatility and Sharpe use sample standard deviation (
ddof=1). rfis an effective annual rate and is compounded into a periodic rate.- Sortino uses all observations when calculating target downside deviation.
- Maximum drawdown is returned as a negative decimal.
- Calmar divides annualized return by the absolute maximum drawdown.
Development
Install development dependencies and run:
python3 -m pytest
Pytest is configured to import code from src, avoiding accidental use of a
globally installed arro package.
Metadata
Release files for arro 0.1.5
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 |
|---|---|---|---|---|
| arro-0.1.5.tar.gz | 7.8 kB | Without provenance | Details for arro-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arro-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for arro-0.1.5-py3-none-any.whl |
Total release size: 13.5 kB
Release files / arro-0.1.5.tar.gz
| Download URL | arro-0.1.5.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d9a2c2885b87c6e5f28bd9b7aee9100dabba9a7ef4bc1ad3569162a0221885a
|
|
BLAKE2b-256 checksum How to use checksums |
a5898d88ff940a7d82480d5c4b660c9b191ecedcd3751ad30823073285f3ca2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / arro-0.1.5-py3-none-any.whl
| Download URL | arro-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
069cce6117e6841751ac61d7b7f300f6001d55b6e7783a8e8f40a9115c7efb20
|
|
BLAKE2b-256 checksum How to use checksums |
9b940f037dd23865a6c56ed4be7882acfd132ad4cf5c6e879aaa02657787e485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for arro 0.1.5
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.