Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

olps-benchmarks

Online Portfolio Selection (OLPS) algorithms and benchmarks, implemented following Online Portfolio Selection: Principles and Algorithms (Li & Hoi).

Structure

  • data.py — downloads adjusted close prices (via yfinance) and converts them into price relatives x[t,i] = price[t,i] / price[t-1,i].
  • strategies/base.pyStrategy, the abstract base class all algorithms implement (Algorithm A.1). Strategies are stateless: update(history) is a pure function of the price-relative history up to t-1 and returns the portfolio b_t.
  • strategies/bah.py — Buy-and-Hold (Chapter 3.1): invests once at t=1 and never rebalances, so its weights drift with relative asset performance.

Setup

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

Example

from data import get_price_relatives
from strategies.bah import BAH

price_relatives = get_price_relatives(
    tickers=["AAPL", "MSFT"], start="2023-01-01", end="2024-01-01"
)

strategy = BAH(n_assets=price_relatives.shape[1])
b_t = strategy.get_portfolio(price_relatives.values[:10])

Status

Early stage — data pipeline and BAH strategy in place. More OLPS algorithms (CRP, UP, EG, ONS, ...) to follow.

About

Online Portfolio Selection (OLPS) algorithms and benchmarks in Python, following Li & Hoi's 'Online Portfolio Selection: Principles and Algorithms'. Early stage: data pipeline and Buy-and-Hold in place, CRP/UP/EG/ONS to follow.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages