Markowitzify
Markowitzify is a lightweight Python library for portfolio optimization (portfolio) and technical-analysis helpers (stonks).
It includes:
- Portfolio analytics: Markowitz optimization, NCO optimization, Sharpe ratio, Hurst exponent, Monte Carlo simulation, trend scan.
- Stonks analytics: Fractal indicator, Bollinger bands, RSI, signal generation, and basic strategy backtesting.
Installation
pip install markowitzify
For local development:
pip install -e ".[dev]"
Optional market-data provider extras:
pip install -e ".[data]"
Quickstart (offline-safe)
import numpy as np
import pandas as pd
import markowitzify
import helper_monkey as hm
rng = np.random.default_rng(42)
returns = rng.normal(0.0005, 0.01, size=(200, 4))
prices = 100 * np.exp(np.cumsum(returns, axis=0))
df = pd.DataFrame(prices, columns=["AAA", "BBB", "CCC", "DDD"])
p = markowitzify.portfolio()
p.portfolio = df
p.cov = hm.cov_matrix(df)
p.markowitz()
print(p.optimal)
p.NCO()
print(p.nco)
API Overview
portfolio
p = markowitzify.portfolio(API_KEY=None, verbose=False)
Key methods/attributes:
build_portfolio(TKR_list, time_delta, end_date=None, datareader=True, provider="auto")provider="auto"prefersyfinanceif installed, otherwisepandas_datareader.
build_TSP()(depends on external endpoint availability).import_portfolio(input_path, filename="portfolio.csv", dates_kw="date")markowitz()→ setsp.optimalNCO()/optimize_nco()→ setsp.ncohurst(),sharpe_ratio(),simulate(),trend()
stonks
s = markowitzify.stonks("AAPL", provider="auto")
Key methods/attributes:
fractal()bollinger()RSI()signal()strategize()
Testing / Contributing
Run checks locally:
ruff check .
pytest -q
Notes and limitations
- External market APIs/providers may change or break over time.
- Tests are intentionally offline and do not rely on Yahoo/MarketStack/TSP network calls.
- MarketStack-based portfolio building requires a valid API key.
Metadata
Release files for markowitzify 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 |
|---|---|---|---|---|
| markowitzify-0.1.0.tar.gz | 21.6 kB | Without provenance | Details for markowitzify-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| markowitzify-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for markowitzify-0.1.0-py3-none-any.whl |
Total release size: 41.6 kB
Release files / markowitzify-0.1.0.tar.gz
| Download URL | markowitzify-0.1.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c77922ddaadffa8cc7a28b37576fb2446dfcfc2c073909a528891f6bcae93c36
|
|
BLAKE2b-256 checksum How to use checksums |
a20992bf8063261178189ff7a9cd3a0f0ca8e820baf94bf5a552c1ce5b36fcc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / markowitzify-0.1.0-py3-none-any.whl
| Download URL | markowitzify-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a8a4bacded00cb4e8840ee8970294b845eedc43695ddebf93607b0b708dfe08
|
|
BLAKE2b-256 checksum How to use checksums |
d73e126747c74775dccc232f17405dc99ec2d3298d76fe9e61a7e1575fd383bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for markowitzify 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.