Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 3.65 KB

README.md

File metadata and controls

64 lines (46 loc) · 3.65 KB

Okama examples

Jupyter notebooks in this directory demonstrate the basic use of okama.

  1. howto Main features of the okama package: Asset, AssetList, and Portfolio objects.

  2. index funds performance Compare ETFs and mutual funds with their benchmarks. Review tracking difference, tracking error, beta, and correlation.

  3. investment portfolios Learn about portfolio properties and compare multiple portfolios with each other.

  4. investment portfolios with DCF Study portfolio strategies with cash flows, including withdrawals and contributions. Backtest the portfolio and forecast longevity with Monte Carlo simulation.

  5. macroeconomics Analyze historical inflation, key rates, and other macroeconomic indicators.

  6. efficient frontier single period Use EfficientFrontierSingle for classic Markowitz frontiers where all portfolios are rebalanced monthly.

  7. efficient frontier multi-period Explore multi-period optimization with custom rebalancing frequencies or portfolios without rebalancing.

  8. backtesting distribution Backtest portfolio return distributions with Jarque-Bera, Kolmogorov-Smirnov, and related diagnostics for normal, lognormal, and other probability distributions.

  9. financial database Query the okama database for stocks, ETFs, mutual funds, indexes, currencies, and macroeconomic data.

  10. forecasting Forecast portfolio performance with normal, lognormal, Student's t, and historical distributions.

  11. rebalancing portfolio Compare calendar-based, threshold-based, and hybrid portfolio rebalancing strategies.

Running the notebooks

Install uv, clone the repository, then run these commands from its root:

uv sync
uv run jupyter lab

Select the worktree's .venv Python interpreter in your editor. The default contributor interpreter is Python 3.14; the notebooks also support Python 3.12 for Google Colab. Local installation cells leave the editable worktree package in place. In Colab, those cells install the public package with %pip in the current kernel; uv is not required there.

For automated execution, create a temporary kernel for this worktree instead of using a kernel registered by another clone:

kernel_root=$(mktemp -d)
uv run python -m ipykernel install --prefix "$kernel_root" --name python3 --display-name "Python 3"
JUPYTER_PATH="$kernel_root/share/jupyter" uv run --no-sync pytest --nbmake --nbmake-kernel=python3 examples -q

The notebooks query the data API, so integration execution needs network access. The temporary kernel directory can be removed after the tests finish. Existing user kernels do not need to be replaced.