Note
In the following table, the abbreviations FL, FW, PM, and ML stand for Follow the Loser, Follow the Winner, Pattern-Matching, and Meta-Learning, respectively.
№ | Algorithm | Strategy | № | Algorithm | Strategy | № | Algorithm | Strategy |
---|---|---|---|---|---|---|---|---|
1 | CORN | PM | 12 | PAMR | FL | 23 | TPPT | Combination of Strategies |
2 | DRICORN-K | PM | 13 | PPT | FW | 24 | GWR | FL |
3 | BCRP | Benchmark (Market) | 14 | CWMR | FL | 25 | ONS | Benchmark (Market) |
4 | UP | Benchmark (Market) | 15 | CAEG | ML | 26 | DMR | FL |
5 | EG | FW | 16 | OLDEM | PM | 27 | RMR | FL |
6 | BS | Benchmark (Market) | 17 | AICTR | FW | 28 | SSPO | FW |
7 | RPRT | FL | 18 | EGM | FW | 29 | WAEG | ML |
8 | Anticor | FL | 19 | OLMAR | FL | 30 | MAEG | ML |
9 | 1/N | Benchmark (Market) | 20 | Bᴷ | PM | 31 | SPOLC | FL |
10 | CW-OGD | ML | 21 | LOAD | Combination of Strategies | 32 | TCO | FL |
11 | ClusLog | PM | 22 | MRvol | Combination of Strategies | 33 |
Row № | Metric | Abbreviation |
---|---|---|
1 | Cumulative Wealth | CW (Also known as |
2 | Mean Excess Return | MER |
3 | Information Ratio | IR |
4 | Annualized Percentage Yield | APY |
5 | Annualized Standard Deviation | |
6 | Annualized Sharpe Ratio | SR |
7 | Maximum Drawdown | MDD |
8 | Calmar Ratio | CR |
9 | Average Turnover | AT |
Further information about the metrics can be found in the documentation.
This package is designed exclusively for research purposes and explicitly not for investment use. The author(s) hold no responsibility for any financial losses or damages incurred from using this package for investment or financial purposes.
The most recent stable version of the package can be installed by entering the following command in the Julia REPL after typing ]
:
pkg> add OnlinePortfolioSelection
or
julia> using Pkg; Pkg.add("OnlinePortfolioSelection")
]
:
pkg> dev OnlinePortfolioSelection
julia> using OnlinePortfolioSelection
julia> opsmethods()
OPSAlgorithm
, which encompasses the following fields:
julia> fieldnames(OPSAlgorithm)
(:n_assets, :b, :alg)
n_assets
: conveying the number of assets.b
: containing the corresponding weights of each asset in each investment period.alg
: representing the name of the algorithm that resulted in the output.
To obtain more information about a specific strategy, you can type ?
in the REPL and then call the name of the strategy. For example, to access more details about the 'CORN-K' strategy, run the following command:
help?> cornk
juila> using OnlinePortfolioSelection
# Generate a random price matrix. The rows are the assets, and the columns represent the time.
julia> adj_close_random = rand(10, 100);
# Set the parameters of the strategy
julia> hor = 10; # The investment horizon
julia> nexp = 5; # The number of experts
julia> ml_tw = 3; # The maximum length of the time windows to be examined
julia> ml_cor = 5; # The maximum number of correlation coefficients to be examined
# Run the algorithm
julia> m_cornk = cornk(adj_close_random, hor, nexp, ml_tw, ml_cor)
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit https://github.com/coin-or/Ipopt
******************************************************************************
# Get weights
julia> m_cornk.b
10×10 Matrix{Float64}:
0.088856 0.147974 … 0.00084875 0.223069
0.0 0.0 0.00347507 0.0
0.101514 0.000792416 0.00100889 0.0553558
0.00913491 0.0805729 0.00100889 0.10233
0.683795 0.0 0.31303 0.0
0.00913491 0.0 … 0.0 0.0407096
0.0350864 0.0208009 0.251554 0.239765
0.0 0.219552 0.395477 0.0
0.0232303 0.349871 0.0131345 0.163805
0.0492489 0.180437 0.0204634 0.174965
$ pip install julia
And then run the following commands in Python:
>>> import julia
>>> julia.install()
...
Precompiling PyCall...
Precompiling PyCall... DONE
PyCall is installed and built successfully.
>>> from julia import Pkg
>>> Pkg.add("OnlinePortfolioSelection")
>>> from julia import OnlinePortfolioSelection as OPS
# Generate a random relatvive price matrix. The rows are the assets, and the columns represent the time.
>>> import numpy as np
>>> rel_pr = np.random.rand(3, 100)
>>> rel_vol = np.random.rand(3, 100)
>>> horizon = 10; Wₘᵢₙ = 4; Wₘₐₓ = 10; λ = 0.05; η = 0.01;
>>> model = OPS.mrvol(rel_pr, rel_vol, horizon, Wₘᵢₙ, Wₘₐₓ, λ, η)
>>> model.b
array([[0.33333333, 0.36104291, 0.3814967 , 0.26303273, 0.16525094,
0.23471654, 0.28741473, 0.34746891, 0.41769629, 0.34582386],
[0.33333333, 0.35745995, 0.24895616, 0.30306051, 0.36527706,
0.2817696 , 0.36959982, 0.43371551, 0.48357232, 0.51374896],
[0.33333333, 0.28149714, 0.36954713, 0.43390676, 0.469472 ,
0.48351386, 0.34298546, 0.21881558, 0.09873139, 0.14042718]])
>>> type(model.b)
<class 'numpy.ndarray'>
>>> model.b.sum(axis=0)
array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])
>>> model.alg
'MRvol'
>>> model.n_assets
3
- Implement
$B^{NN}$ - Adopt hierarchical clustering for ClusLog algorithm
- Implement CRP
- Implement
$B^H$ - etc.