[ANN] OnlinePortfolioSelection.jl

OnlinePortfolioSelection.jl is intended to provide the Julia implementation of the online portfolio selection (OPS) algorithms in a fully type-stable manner. The package is designed to be used only for research purposes, not for actual trading, and is still under development, and hopefully, more algorithms will be added gradually. However, some of the most prominent OPS algorithms are already implemented in the package and can be used by users.


Throughout the past decade, online portfolio selection (OPS) has been a topic of interest in the context of computational finance. The OPS problem is concerned with the sequential allocation of wealth to a set of assets over a time horizon and continuously updating the portfolio when new information arrives. The goal is to maximize the final wealth of the investor by using the information available at each time step. The OPS problem has a wide range of applications in finance, including algorithmic trading, automated portfolio management, and automated market making. Furthermore, researchers are developing AI-oriented OPS strategies in their recent studies to achieve higher investment returns. Generally, OPS algorithms can be categorized into five groups:

  1. Follow the Winner (FW)
  2. Follow the Loser (FL)
  3. Pattern-Matching (PM)
  4. Meta-Learning (ML)
  5. Market (M)

Follow the Winner (FW)

These strategies (AKA Follow the Leader) are based on the idea that the best asset in the past will continue to be the best in the future. Universal Portfolios (UP), Exponential Gradient (EG), and Gradient Projection (GP) are the most well-known FW algorithms.

Follow the Loser (FL)

These strategies are based on the idea that the malfunctioning assets in the past will tend to perform well in the future. Reweighted Price Relative Tracking (RPRT), On-Line Portfolio Selection with Moving Average Reversion (OLMAR), and Anti-Correlation (Anticor) are the most prominent FL algorithms.

Pattern-Matching (PM)

These strategies are based on the idea that the historical price patterns will repeat in the future. The most well-known PM algorithms are Correlation Driven Nonparametric Learning (CORN), Dynamic RIsk CORrelation-driven Non-parametric algorithm (DRICORN), B^{NN}, B^H, and B^S.

Meta-Learning (ML)

These strategies aim to define several experts and then combine their portfolios to achieve a final portfolio. It’s been discussed that the best convex combination of experts is always better than the individual experts. Online Gradient Update (OGU), Online Newton Update (ONU), continuous aggregating exponential gradient (CAEG), and combination weights based on online gradient descent (CW-OGD) are the most well-known meta-learning algorithms.

Market (M)

These algorithms (AKA Benchmark) are often adopted as the baseline algorithms to compare the performance of other algorithms. A trivial strategy is Buy-And-Hold (BAH), which is also called the Market strategy. This strategy invests equally in d assets at the beginning and remains unchanged. Best Stock (BS) and Constant Rebalanced Portfolio (CRP) are other well-known market strategies.


For now, the following algorithms are implemented or being under development in the package:

Algorithm Strategy Stable Dev
CORN-U Pattern-Matching :heavy_check_mark:
CORN-K Pattern-Matching :heavy_check_mark:
DRICORN-K Pattern-Matching :heavy_check_mark:
CRP Benchmark (Market) :heavy_check_mark:
UP Follow the Winner :heavy_check_mark:
EG Follow the Winner :heavy_check_mark:
RPRT Follow the Loser :heavy_check_mark:
BS Benchmark (Market) :heavy_check_mark:

Hopefully, novel algorithms will be added to the package in the future after implementing the prominent ones. Hence, contributions to this open-source project are highly appreciated. :partying_face:


Since my M.Sc. thesis is in the field of OPS, I thought it would be a worthwhile idea to implement some of the benchmark methods to use them to perform benchmarking experiments to compare the performance of my proposed method with the existing methods in the literature. Afterward, I thought it would be a good idea to bundle the repo as an open-source package and share it with the community so that other researchers can use the methods for their research purposes and put time into developing novel strategies rather than implementing the existing ones. Furthermore, because of my interest in the OPS field, I will continue to develop the package and add more algorithms to it. I hope this package will be useful for the community and will be used by other researchers in the field.


I highly appreciate the Julia community for their great support in Julia’s discourse forum. My special thanks go to @odow for their great support and kind help.


Looks cool. Do you have any idea how those strategies relate to “universal portfolios”?

EDIT: Duh. You have it already. I just overlooked it. Again, cool.

Thank you for your nice words.

Yes :sweat_smile:, I’ve provided a brief overview of the algorithm in the documentation. However, I can dig in more details if you ask to.

I’m glad that you found it cool :slight_smile: