[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.

Overview

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.

OnlinePortfolioSelection.jl

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:

Motivation

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.

Acknowledgment

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.

13 Likes

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.

Hi!
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:

Projects Status

I was hanging around the “Package Announcement” topic and got curious about my package announcement post. So, I checked the post and got happy. Considering the “CORN-U” and “CORN-K” as variants of the “CORN” algorithm, six different benchmarks in the context of the OPS were implemented when I announced this package. By today, I have implemented twenty more algorithms in this field of study including novel algorithms, such as DMR, ODLEM, and MRvol. Still, it’s a great journey! I remember E-mailing the author of the “MRvol” model regarding a rare case that might happen, which they did not consider by that day. I became aware of it by running my implementation (which is available in the package) and tracking the error’s root. I implemented their incredible research 4 or 5 days after its proofreading version was put online.


I am very pleased that I was able to assist them in consolidating their material and improving their explanations. I updated the implementation to align it with their instructions regarding the rare case that I found.
The DMR got online on 17th Nov and today I completed its implementation and included it in the latest release of the package. NO OTHER PACKAGE in the whole universe has implemented this number of OPS algorithms as an open-sourced project, and I’m thrilled to announce that OnlinePortfolioSelection.jl is the only open-source project in this field of study that is being updated as new algorithms arrive and entails this number of algorithms by this day. I hope this can help researchers in this field of study. Just wanted to write about my feelings here after several releases.

Acknowledgments

I want to thank Mr. @odow, Mr. @Oscar_Smith, Mr. @eliascarv, Mr. @goerz, Mr. @Dan, and others who have helped me by kindly answering my questions. They may not have collaborated directly with the project, but I would not able to make it if they had not taught me about my mistakes.

Last words

I’m not done with this project, and a huge amount of documentation improvements will be made in the upcoming months as a necessary improvement besides implementing more algorithms. The only thing that I’m missing here is the lack of other contributors to this project. Anyway, I hope to make a meaningful contribution to the Julia ecosystem and leave a lasting impact.

If you have any suggestions, any recommendations regarding the improvement of the project, I would highly appreciate it if you could tell me about it. Love and peace.

4 Likes