Skip to main content

MarkoWizard

A modern Python library for Markowitz portfolio optimization and analysis.

PyPI Python 3.10+ License: MIT

📖 Full documentation

Previously known as Diversificador. The original portfolio-analysis web app built with Dash is no longer maintained, but it is preserved on the dash-deprecated branch for reference.

Features

  • Markowitz Mean-Variance Optimization — Compute the efficient frontier using scipy.optimize
  • Capital Allocation Line — Mix risky portfolios with risk-free assets
  • Visualization — Plotly-based charts for efficient frontier, allocation pie, CAL, correlation heatmaps, and price timelines
  • Data Fetching — Built-in helpers for downloading market data via yfinance
  • Web Application — FastAPI backend with a dark-themed interactive frontend

Installation

pip install markowizard

That's everything the library needs: optimization (scipy), market-data fetching (yfinance), and visualization (plotly). No optional extras.

Quick Start (Library)

from markowizard import MarkowitzOptimizer, CapitalAllocator
from markowizard.data import fetch_prices, compute_monthly_returns
from markowizard.visualization import efficiency_frontier_plot

# Fetch prices and compute monthly returns (decimal form, e.g. 0.01 = 1%)...
prices = fetch_prices(["AAPL", "MSFT", "GOOGL", "SPY"], period="5y")
returns = compute_monthly_returns(prices)
# ...or bring your own returns DataFrame (assets as columns).

# Optimize
optimizer = MarkowitzOptimizer(returns)
portfolios = optimizer.optimize()

# Compute Sharpe ratios (provide monthly risk-free rate)
risk_free_rate = 0.005  # 0.5% per month
portfolios = optimizer.compute_sharpe(risk_free_rate)

# Plot the efficient frontier
fig = efficiency_frontier_plot(portfolios, highlight_portfolio=50)
fig.show()

# Best portfolio (maximum Sharpe ratio)
best = optimizer.max_sharpe_portfolio()
print(best)

# Capital allocation line
allocator = CapitalAllocator(best, risk_free_rate)
cal_points = allocator.capital_allocation_line(steps=21)

Web Application

An interactive web UI (FastAPI + a dark-themed frontend) lives in backend/ and frontend/. It is not part of the PyPI package — run it from the container image or a clone.

Using Docker

docker run -p 8000:8000 ghcr.io/outliersanalytics/markowizard:latest

From a clone

git clone https://github.com/OutliersAnalytics/MarkoWizard
cd MarkoWizard
uv run --with-requirements backend/requirements.txt uvicorn backend.main:app --port 8000

Open http://localhost:8000 — the app auto-submits with default tickers on load.

It exposes a single endpoint, POST /api/analyze; see the Web Application docs for the request/response shape.

API Reference

Full reference for every public class and function — MarkowitzOptimizer, CapitalAllocator, the visualization chart functions, and the data fetch helpers — lives in the documentation site.

Development

See CONTRIBUTING.md for setup instructions and contribution guidelines.

License

MIT

Metadata

Release files for markowizard 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markowizard 0.2.1
File Size Uploaded
markowizard-0.2.1.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markowizard 0.2.1
File Interpreter ABI Platform
markowizard-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / markowizard-0.2.1.tar.gz

Download URL markowizard-0.2.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
231efe38e6a8a860f9f0bbc38c0d5713875d98ecfb927215429fbb46da563a03
BLAKE2b-256 checksum
How to use checksums
e1fd7eaba45f33366780305ac6c780fc6cc6ceb287198bff403f1ee0ccbd4473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / markowizard-0.2.1-py3-none-any.whl

Download URL markowizard-0.2.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85d2060738726153a8ad98a5a2c468368bf60630a429b298111abaed6d91f1ee
BLAKE2b-256 checksum
How to use checksums
a8b4b06d1461ed9781e1f3f05cceb4b459d93c9120a07718ca8fa19f3e0b8dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page