Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The information provided by OPES is for educational, research and informational
| | Maximum Sharpe Ratio |
| **Principled Heuristics** | Uniform (1/N) |
| | Risk Parity |
| | Hierarchical Risk Parity |
| | Inverse Volatility |
| | Softmax Mean |
| | Maximum Diversification |
Expand Down Expand Up @@ -106,7 +107,7 @@ Alternatively, you are also welcome to install directly from the GitHub reposito

```bash
git clone https://github.com/opes-core/opes.git
cd opes
cd opes-main
pip install .
```

Expand Down Expand Up @@ -162,7 +163,7 @@ asset_data = yf.download(
kelly_portfolio = Kelly(fraction=0.8, reg="l2", strength=0.001)

# Compute portfolio weights with custom weight bounds
kelly_portfolio.optimize(data, weight_bounds=(0.05, 0.8))
kelly_portfolio.optimize(asset_data, weight_bounds=(0.05, 0.8))

# Clean negligible allocations
cleaned_weights = kelly_portfolio.clean_weights(threshold=1e-6)
Expand All @@ -171,7 +172,7 @@ cleaned_weights = kelly_portfolio.clean_weights(threshold=1e-6)
print(cleaned_weights)
```

This showcases the simplicty of the module. However there are far more diverse features you can still explore. If you're looking for more examples, preferably some of them with *"context"*, I recommend you check out the [examples](https://opes.pages.dev/examples/good_strategy/) page within the documentation.
This showcases the simplicity of the module. However there are far more diverse features you can still explore. If you're looking for more examples, preferably some of them with *"context"*, I recommend you check out the [examples](https://opes.pages.dev/examples/good_strategy/) page within the documentation.

---

Expand Down Expand Up @@ -201,7 +202,6 @@ Also it eats up RAM like pac-man.
These features are still in the works and may or may not appear in later updates:

| **Objective Name (Category)** |
| ------------------------------------------------ |
| Hierarchical Risk Parity (Principled Heuristics) |
| ------------------------------------------------ |
| Online Newton Step (Online Learning) |
| ADA-BARRONS (Online Learning) |
4 changes: 2 additions & 2 deletions docs/docs/backtesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def plot_wealth(
OPES ships with a basic plotting utility for visualizing portfolio wealth over time.

This method exists for quick inspection and debugging, not for deep performance analysis.
It visualizes cumulative wealth for one or multiple strategies using their periodic
returns. It also provides a breakeven reference line and optional saving of the plot to
It visualizes cumulative wealth for one or multiple strategies using their periodic
returns. It also provides a breakeven reference line and optional saving of the plot to
a file.

!!! tip "Recommendation:"
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ OPES is a research-oriented and experimentation-focused Python module for portfo
!!! example "Demo"
```python
# Demonstration of portfolio optimization using the Kelly Criterion
# 'data' represents OHLCV market data grouped by ticker symbols
# `return_data` represents OHLCV market data grouped by ticker symbols

from opes.objectives import Kelly

# Initialize a Kelly portfolio with fractional exposure and L2 regularization
kelly_portfolio = Kelly(fraction=0.8, reg="l2", strength=0.01)

# Compute portfolio weights with custom bounds and clean negligible allocations
kelly_portfolio.optimize(data, weight_bounds=(0.05, 0.8))
kelly_portfolio.optimize(return_data, weight_bounds=(0.05, 0.8))
cleaned_weights = kelly_portfolio.clean_weights(threshold=1e-6)

# Output the final portfolio weights
Expand Down
85 changes: 60 additions & 25 deletions docs/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,94 @@ This page guides you through installing OPES for experimentation & research.
!!! warning "Warning:"
OPES is currently under development. While it is relatively stable for experimentation, some features may change or break. Use at your own discretion and always verify results when testing.

## Prerequisites

- Python 3.10+ (tested up to 3.12)
- `pip` package manager

---

## Procedure

### 1. Install OPES
Python 3.10+ is required for `opes` to run (although it *may* work on some lower versions). `opes` is tested upto Python 3.14. To install a stable release of `opes`, `pip` is recommended for convenience.

You can install OPES easily via PyPI:
### Installation

You can install OPES easily via PyPI using `pip`.

```bash
pip install opes
```

This will fetch the latest stable release and all required dependencies.

You are also welcome to install the module directly from GitHub:
This will fetch the latest stable release and all required dependencies. Alternatively, you are also welcome to install the module directly from GitHub.

```bash
git clone https://github.com/opes-core/opes.git
cd opes-main
pip install -e .
pip install .
```

!!! note "Note:"
The `-e` flag installs OPES in editable mode, so any changes you make to the source code are reflected immediately without reinstalling. This is great for developers or those tinkering with advanced features.
You can also install in editable mode if you plan on making any changes to the source code.

```bash
# After cloning and in the root of the project
pip install -e .
```

---

### 2. Verify the Installation
### Verification

After installation, make sure everything works by opening Python and importing OPES:
After installation, make sure everything works by opening Python and importing `opes`.

```python
>>> import opes
>>> opes.__version__
'1.0.0'
>>> '0.10.0' # May not be the current version but you get the idea
```

If no errors appear, OPES is ready to use.
You can also verify your installation by using `pip`.

```bash
pip show opes
```

If no errors appear, `opes` is ready to use.

---

## Dependencies
## Getting Started

OPES requires the following Python modules:
`opes` is designed to be minimalistic and easy to use and learn for any user. Here is an example script which implements my favorite portfolio, the Kelly Criterion.

```python
# I recommend you use yfinance for testing.
# However for serious research, using an external, faster API would be more fruitful.
import yfinance as yf

# Importing our Kelly class
from opes.objectives import Kelly

# ---------- FETCHING DATA ----------
# Obtaining ticker data
# Basic yfinance stuff
TICKERS = ["AAPL", "NVDA", "PFE", "TSLA", "BRK-B", "SHV", "TLT"]
asset_data = yf.download(
tickers=TICKERS,
start="2010-01-01",
end="2020-01-01",
group_by="ticker",
auto_adjust=True
)

# ---------- OPES USAGE ----------
# Initialize a Kelly portfolio with fractional exposure and L2 regularization
# Fractional exposure produces less risky weights and L2 regularization contributes in penalizing concentration
kelly_portfolio = Kelly(fraction=0.8, reg="l2", strength=0.001)

# Compute portfolio weights with custom weight bounds
kelly_portfolio.optimize(asset_data, weight_bounds=(0.05, 0.8))

# Clean negligible allocations
cleaned_weights = kelly_portfolio.clean_weights(threshold=1e-6)

# Output the final portfolio weights
print(cleaned_weights)
```

| Module name | Minimum version | Maximum version |
| --------------- | --------------- | --------------- |
| **NumPy** | 2.2.6 | < 3.0 |
| **pandas** | 2.3.3 | < 3.0 |
| **SciPy** | 1.15.2 | < 2.0 |
| **matplotlib** | 3.10.1 | < 4.0 |
This showcases the simplicity of the module. However there are far more diverse features you can still explore. If you're looking for more examples, preferably some of them with *"context"*, I recommend you check out the [examples](./examples/good_strategy.md) page within the documentation.
10 changes: 5 additions & 5 deletions docs/docs/objectives/dro.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ $$
!!! example "Example:"
```python
# Importing the dro Kelly module
from opes.objectives.distributionally_robust import KLRobustKelly
from opes.objectives import KLRobustKelly

# Let this be your ticker data
training_data = some_data()
Expand Down Expand Up @@ -289,7 +289,7 @@ Uses the log-sum-exp technique to solve for numerical stability.
!!! example "Example:"
```python
# Importing the dro maximum mean module
from opes.objectives.distributionally_robust import KLRobustMaxMean
from opes.objectives import KLRobustMaxMean

# Let this be your ticker data
training_data = some_data()
Expand Down Expand Up @@ -449,7 +449,7 @@ $$
!!! example "Example:"
```python
# Importing the dro maximum mean module
from opes.objectives.distributionally_robust import WassRobustMaxMean
from opes.objectives import WassRobustMaxMean

# Let this be your ticker data
training_data = some_data()
Expand Down Expand Up @@ -623,7 +623,7 @@ $$
!!! example "Example:"
```python
# Importing the dro mean-variance module
from opes.objectives.distributionally_robust import WassRobustMeanVariance
from opes.objectives import WassRobustMeanVariance

# Let this be your ticker data
training_data = some_data()
Expand Down Expand Up @@ -792,7 +792,7 @@ $$
!!! example "Example:"
```python
# Importing the dro minimum variance module
from opes.objectives.distributionally_robust import WassRobustMinVariance
from opes.objectives import WassRobustMinVariance

# Let this be your ticker data
training_data = some_data()
Expand Down
Loading