Proteus Optimisation Package (POP): Domain-agnostic stochastic optimization engine for PAL variables
Project description
Domain-agnostic stochastic optimization engine for PAL (Proteus Actuarial Library) variables.
Features
- 🎯 Metric-Centric Design: Unified framework for objectives and constraints
- 📊 Multiple Metric Types: Mean, Std, SpreadVaR, plus composite metrics (Ratio, Product, Sum, Difference)
- 🔗 Composite Metrics: Build complex metrics like Sharpe ratios, risk-adjusted returns
- 🎲 Dual Data Support: StochasticScalar (aggregated) and FreqSevSims (frequency-severity)
- ⚖️ Flexible Constraints: Portfolio-level and occurrence-level constraints
- 📈 Efficient Frontiers: Parallel constraint variation for risk-return tradeoff analysis
- ✅ Type-Safe API: Pydantic models with comprehensive validation
Installation
From PyPI
pip install proteusllp-optimisation-package
From Local Source (Development)
pip install -e /proteus-optimisation-package
Quick Start
from pop import (
ObjectiveSpec, OptimizationInput, SimpleConstraint,
MeanMetric, StdMetric, optimize
)
from pal.variables import ProteusVariable
from pal import StochasticScalar
# Create PAL variable with return simulations
returns = ProteusVariable("item", {
"stock_a": StochasticScalar([0.10, 0.12, 0.08]),
"stock_b": StochasticScalar([0.15, 0.18, 0.12])
})
# Define objective: maximize expected return
objective = ObjectiveSpec(
objective_value=returns,
metric=MeanMetric(),
direction="maximize"
)
# Add risk constraint: limit portfolio std dev
risk_constraint = SimpleConstraint(
constraint_value=returns,
metric=StdMetric(),
threshold=0.15,
direction="cap",
name="max_risk"
)
# Create optimization problem
opt_input = OptimizationInput(
item_ids=["stock_a", "stock_b"],
current_shares={"stock_a": 100.0, "stock_b": 100.0},
objective=objective,
simple_constraints=[risk_constraint]
)
# Run optimization
result = optimize(opt_input.preprocess())
print(f"Optimal shares: {result.optimal_shares}")
print(f"Expected return: {result.objective_value:.4f}")
Documentation
Full documentation is available at proteusllp-optimisation-package.readthedocs.io.
Requirements
- Python 3.13+
- PAL (Proteus Analytics Library) >=0.2.8
- NumPy >=2.2
- SciPy >=1.15
- Pydantic >=2.0
- cvxopt
Development
Setup
# Clone the repository
git clone https://github.com/ProteusLLP/proteusllp-optimisation-package.git
cd proteusllp-optimisation-package
# Open in VS Code - will prompt to reopen in devcontainer
code . # Runs 'pdm install' automatically
# Or install locally with PDM
pdm install
Running Checks
# Run tests
pytest tests/ -v
# Run static analysis (lint, format, security, deadcode)
make static-analysis
# Run typecheck separately (has known issues with PAL's dynamic types)
make typecheck
Note on Type Checking: Pyright type checking is temporarily excluded from CI due to PAL's dynamic typing patterns. PAL adds attributes like .occurrence, .sim_index, and .n_sims at runtime, which pyright cannot fully infer. All tests pass, confirming functional correctness.
License
MIT License - see LICENSE file for details.
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file proteusllp_optimisation_package-0.1.3.tar.gz.
File metadata
- Download URL: proteusllp_optimisation_package-0.1.3.tar.gz
- Upload date:
- Size: 60.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed746a0dbbe97ef208cbafe3808fdd941734910a7a1c55a3d0713ac6611b154f
|
|
| MD5 |
271660e17e0df86db62f7707c5c176cc
|
|
| BLAKE2b-256 |
f3608bfee792fb14da838bc069ff642047b09e7d13585ba55e89ff0bab2d7420
|
Provenance
The following attestation bundles were made for proteusllp_optimisation_package-0.1.3.tar.gz:
Publisher:
ci.yaml on ProteusLLP/proteusllp-optimisation-package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
proteusllp_optimisation_package-0.1.3.tar.gz -
Subject digest:
ed746a0dbbe97ef208cbafe3808fdd941734910a7a1c55a3d0713ac6611b154f - Sigstore transparency entry: 804588380
- Sigstore integration time:
-
Permalink:
ProteusLLP/proteusllp-optimisation-package@7edfba7f8e31b5478aee00a9a465c6b1b569f871 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/ProteusLLP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@7edfba7f8e31b5478aee00a9a465c6b1b569f871 -
Trigger Event:
release
-
Statement type:
File details
Details for the file proteusllp_optimisation_package-0.1.3-py3-none-any.whl.
File metadata
- Download URL: proteusllp_optimisation_package-0.1.3-py3-none-any.whl
- Upload date:
- Size: 37.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56b5ba37d4c66e269f191c1979478342f88cf0d1a5a7984371acedd1410095d
|
|
| MD5 |
37a5eed2a672c620f41f66bf159e53d8
|
|
| BLAKE2b-256 |
10234db8c7a5d2d86a33504f6b95430f84d321beee03c7225c1ec633d2bb8d0f
|
Provenance
The following attestation bundles were made for proteusllp_optimisation_package-0.1.3-py3-none-any.whl:
Publisher:
ci.yaml on ProteusLLP/proteusllp-optimisation-package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
proteusllp_optimisation_package-0.1.3-py3-none-any.whl -
Subject digest:
f56b5ba37d4c66e269f191c1979478342f88cf0d1a5a7984371acedd1410095d - Sigstore transparency entry: 804588383
- Sigstore integration time:
-
Permalink:
ProteusLLP/proteusllp-optimisation-package@7edfba7f8e31b5478aee00a9a465c6b1b569f871 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/ProteusLLP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@7edfba7f8e31b5478aee00a9a465c6b1b569f871 -
Trigger Event:
release
-
Statement type: