Opvious Python SDK
Project description
Opvious Python SDK
![Pypi badge](https://pypi-camo.freetls.fastly.net/dc506e98b1d565d7461b38a4af381a403b26c1de/68747470733a2f2f62616467652e667572792e696f2f70792f6f7076696f75732e737667)
An optimization SDK for solving linear, mixed-integer, and quadratic models
import opvious
client = opvious.Client.from_environment()
# Solve a portfolio selection optimization model
response = await client.run_solve(
specification=opvious.LocalSpecification.inline(
r"""
We find an allocation of assets which minimizes risk while satisfying
a minimum expected return:
+ A collection of assets: $\S^d_{asset}: A$
+ Covariances: $\S^p_{covariance}: c \in \mathbb{R}^{A \times A}$
+ Expected return: $\S^p_{expectedReturn}: m \in \mathbb{R}^A$
+ Minimum desired return: $\S^p_{desiredReturn}: r \in \mathbb{R}$
The only output is the allocation per asset
$\S^v_{allocation}: \alpha \in [0,1]^A$ chosen to minimize risk:
$\S^o_{risk}: \min \sum_{a, b \in A} c_{a,b} \alpha_a \alpha_b$.
Subject to the following constraints:
+ $\S^c_{atLeastMinimumReturn}: \sum_{a \in A} m_a \alpha_a \geq r$
+ $\S^c_{totalAllocation}: \sum_{a \in A} \alpha_a = 1$
"""
),
parameters={
"covariance": {
("AAPL", "AAPL"): 0.08,
# ...
},
"expectedReturn": {
"AAPL": 0.07,
# ..
},
"desiredReturn": 0.05,
},
assert_feasible=True,
)
optimal_allocation = response.outputs.variable("allocation")
Take a look at https://opvious.readthedocs.io for the full documentation or these notebooks to see it in action.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
opvious-0.12.0rc6.tar.gz
(96.1 kB
view hashes)
Built Distribution
Close
Hashes for opvious-0.12.0rc6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ae54f9f3514199cf1a558fea10adc1a6970013ae87be98bc8a0dec6e7f7b21 |
|
MD5 | 4261de393d378ef44738eee2e3f798f8 |
|
BLAKE2b-256 | f96b562e241c7e5e77e6d87cc1729e2c487be9bf24a6d65b847d66e7d487b7ac |