Online selection rules: mirror descent, its schedules and its gradient transforms

MirrorDescent is the first-order rule. At each period it takes one mirror descent step on the gradient, in the divergence of its projection geometry. Each constructor is named after the method of one paper. ExponentiatedGradient uses the entropic geometry, and GradientProjection uses the Euclidean one. EGE, EGR and EGA are the exponentiated gradient with momentum, with root-mean-square scaling and with adaptive moments.

In place of a fixed step size eta, a rule can hold a learning-rate schedule. InverseSquareRootRate and SelfConfidentRate set the step size at each period. DoublingTrickRate restarts the rule at each stage. WindowedBestRate runs the exponentiated gradient at each rate of a set, and takes the rate with the most wealth over a window. MAEG and AEG are the two adaptive strategies of the paper that defines WindowedBestRate. A gradient transform, such as GradientMomentum, rescales the gradient before the step. The rule steps on log wealth, LogWealth, by default, or on a risk measure over the last rows, RiskLoss.

PortfolioOptimisers.AbstractGradientTransform — Type
abstract type AbstractGradientTransform <: AbstractAlgorithm

Abstract supertype for the Gradient Transforms, which change the gradient of a first-order rule before its mirror step.

A MirrorDescent rule applies its transform to the gradient of every period. The momentum transforms of Li, Zheng, Chen, Wang and Xu (2022) change the exponent of the multiplicative update, and do not change the form of the update.

Interfaces

In order to implement a new transform, subtype AbstractGradientTransform and implement:

  • gradient_state_seed(grad::AbstractGradientTransform, w::AbstractVector): The carrier the transform keeps on the Rule State before the first row, or nothing, the default. w is the Start Allocation, and the carrier takes its length and its element type.
  • transform_gradient!(grad::AbstractGradientTransform, gs, g::AbstractVector) -> AbstractVector: The transformed gradient of the period, computed from the raw gradient g. It writes the carrier gs in place.

The head's state already slices and copies a carrier that is nothing, a vector or a pair of vectors. A carrier of another shape needs its own methods of the two private helpers gradient_state_view and copy_gradient_state.

Related

source
PortfolioOptimisers.InverseSquareRootRate — Type
struct InverseSquareRootRate{T1<:Real} <: AbstractLearningRateSchedule

Shrinks the learning rate with the square root of the period count, and needs no horizon.

The schedule reads the period count and nothing else. It is the schedule of Zinkevich (2003, Theorem 1) for online gradient descent, which gives an $O(\sqrt{T})$ regret under the Euclidean map. At $c = \sqrt{\log N / (2 N)}$ it is the anytime Soft-Bayes rate of Orseau, Lattimore and Legg (2017, Theorem 10).

Under the entropic map, Helmbold, Schapire, Singer and Warmuth (1998, Theorem 4.1) tune a fixed rate, $\eta = 2 r \sqrt{2 \log N / T}$. That rate needs the horizon $T$ and a lower bound $r$ on each price relative as a fraction of the largest one of its period. An online rule knows neither, so the library states that rate here and does not implement it as a schedule.

Mathematical definition

\[\begin{align} \eta_t &= \frac{c}{\sqrt{t}}\,. \end{align}\]

Where:

  • $\eta_t$: Learning rate of the update at period $t$.
  • $c > 0$: Scale of the rate.
  • $t$: Period index, counted from one.

Fields

  • c: The scale of the rate, the numerator of $c / \sqrt{t}$.

Constructors

InverseSquareRootRate(; c::Real = 1) -> InverseSquareRootRate

Keywords correspond to the struct's fields.

Validation

  • c > 0. A DomainError is thrown otherwise.

Examples

julia> InverseSquareRootRate()InverseSquareRootRate  c ┴ Int64: 1

Related

References

  • [152] M. Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In: Proceedings of the 20th International Conference on Machine Learning, 928–936 (2003).
  • [187] L. Orseau, T. Lattimore and S. Legg. Soft-Bayes: Prod for mixtures of experts with log-loss. In: Proceedings of the 28th International Conference on Algorithmic Learning Theory, PMLR 76, 372–399 (2017).
source
PortfolioOptimisers.DoublingTrickRate — Type
struct DoublingTrickRate{T1<:Integer} <: AbstractLearningRateSchedule

Runs the rule in stages of growing length, and restarts it at the Start Allocation after the last period of each stage.

This is the doubling trick of Helmbold, Schapire, Singer and Warmuth (1998, Corollary 4.3) for the exponentiated gradient with the uniform mix. Each stage sets its uniform-mix share and its rate from its own length, as their Theorem 4.2 sets them from the horizon. The schedule sets both, so a MirrorDescent that holds it does not read its own alpha.

From the uniform Start Allocation, the staged rule is universal. For every sequence of non-negative price relatives, with no lower bound on them, its regret against every constant rebalanced portfolio over $T$ periods is at most $6 N^2 \log N (1 + (T / (2 N^2 \log N))^{3/4})$. The bound holds under the entropic map. Under another map the schedule restarts the rule and sets its rate, and no bound is known.

Mathematical definition

\[\begin{align} T_0 &= \lceil 2 N^2 \log N \rceil\,, \\ T_i &= \lceil 2^i N^2 \log N \rceil\,, \quad i > 0\,, \\ \alpha_i &= \left( \frac{N^2 \log N}{8 T_i} \right)^{1/4}\,, \\ \eta_i &= \sqrt{\frac{8 \alpha_i^2 \log N}{N^2 T_i}}\,. \end{align}\]

Where:

  • $N$: Number of assets.
  • $i$: Stage index, counted from zero.
  • $T_i$: Length of stage $i$, in periods.
  • $\alpha_i$: Uniform-mix share of every period of stage $i$.
  • $\eta_i$: Learning rate of every period of stage $i$.

Stages $0$ and $1$ have the same length. At $T_i \geq 2 N^2 \log N$ the share is at most $1/2$, the range the theorem needs.

Algorithm

At period t the schedule runs these steps.

  1. Find the stage that holds t with doubling_stage, giving its length len and its last period fin.
  2. Compute the stage's share $\alpha_i$ from len. The rule reads it in place of its own alpha.
  3. Compute the stage's rate $\eta_i$ from the share and len.
  4. When t == fin, name a restart. The rule's update of period t then returns the Start Allocation, and puts its carrier back at its seed. The period count stays, because the stages are cumulative.

Fields

  • N: The number of assets. The stage lengths, the shares and the rates depend on it.

Constructors

DoublingTrickRate(; N::Integer) -> DoublingTrickRate

Keywords correspond to the struct's fields. N is the number of assets the rule moves over, or the number of experts when the rule weights a mixture. It has no default, because the stage lengths depend on it.

Validation

  • N >= 2. A DomainError is thrown otherwise, because $\log 1 = 0$ gives a stage of no periods.

Examples

julia> DoublingTrickRate(; N = 4)DoublingTrickRate  N ┴ Int64: 4

Related

References

  • [178] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. On-line portfolio selection using multiplicative updates. Mathematical Finance 8, 325–347 (1998).
source
PortfolioOptimisers.SelfConfidentRate — Type
struct SelfConfidentRate{T1<:Real} <: AbstractLearningRateSchedule

Reads the learning rate from the running excess of each period's best asset over the played allocation.

This is the self-confident rate of Orseau, Lattimore and Legg (2017, Theorem 6). The rule's carrier keeps the excess for the schedule, beside $\log N$. The excess is measured at the allocation the rule played, so under a MirrorDescent with a positive alpha it reads the mix.

Theorem 6 bounds the regret of the Soft-Bayes step, ExpectationMaximisation, against every constant rebalanced portfolio. At the fixed rate $\sqrt{2 \log N / C_1}$, with $C_1$ the excess of the whole run, the bound is $\min\{C_1, \sqrt{2 C_1 \log N} + 2 T \log N / C_1\}$. It is small when one asset is the best predictor for long stretches. The paper notes that the excess never falls, so the rate can be read online from the running excess, but it states no bound for that online rate. Under a MirrorDescent the rate is read online in the same way, and no bound is known either.

Under the online form of the Soft-Bayes step, this rate caps the pull towards the Start Allocation at $\sqrt{t / (t + 1)}$, as the paper advises (correction_ratio_cap). Without the cap, the rate stays almost constant while the mixture predicts well, and a weight can then decay exponentially.

The rate is capped at eta_max, because the excess is zero before the first row. The theorem needs a rate in $(0, 1)$, and the paper states no cap, so the default cap is the end of that interval.

Mathematical definition

\[\begin{align} C_{1, t} &= \sum_{s = 1}^{t} \left( \max_i \frac{x_{s, i}}{\langle \boldsymbol{w}_s, \boldsymbol{x}_s \rangle} - 1 \right)\,, \\ \eta_t &= \min\left( \sqrt{\frac{2 \log N}{C_{1, t-1}}}, \eta_{\max} \right)\,. \end{align}\]

Where:

  • $C_{1, t}$: First-order excess through period $t$, zero at $t = 0$.
  • $x_{s, i}$: Price relative of asset $i$ in period $s$.
  • $\boldsymbol{x}_s$: Price relative vector of period $s$.
  • $\boldsymbol{w}_s$: Allocation the rule played in period $s$.
  • $\eta_t$: Learning rate of the update at period $t$.
  • $\eta_{\max} > 0$: Cap on the rate.
  • $N$: Number of assets.

Each term of $C_{1, t}$ is non-negative, because the largest price relative is at least their mean under $\boldsymbol{w}_s$. So the excess never falls, and the rate never rises. While the excess is zero, the rate is $\eta_{\max}$.

Algorithm

  1. Before the first row, seed the statistic s = [0, log(N)].
  2. Read the rate of period t from s: eta_max while s[1] is not positive, and $\eta_t$ otherwise.
  3. After the rule's step of period t, add maximum(x ./ dot(w, x)) - 1 to s[1], with w the allocation the rule played in period t and x its price relative.

Fields

  • eta_max: The cap on the rate, answered while the running excess is zero and whenever the formula exceeds it.

Constructors

SelfConfidentRate(; eta_max::Real = 1) -> SelfConfidentRate

Keywords correspond to the struct's fields.

Validation

  • eta_max > 0. A DomainError is thrown otherwise.

Examples

julia> SelfConfidentRate()SelfConfidentRate  eta_max ┴ Int64: 1

Related

References

  • [187] L. Orseau, T. Lattimore and S. Legg. Soft-Bayes: Prod for mixtures of experts with log-loss. In: Proceedings of the 28th International Conference on Algorithmic Learning Theory, PMLR 76, 372–399 (2017).
source
PortfolioOptimisers.WindowedBestRate — Type
struct WindowedBestRate{T1<:(AbstractVector{<:Real}), T2<:(Union{Nothing, var"#s7441"} where var"#s7441"<:Integer)} <: AbstractLearningRateSchedule

Chooses the learning rate of each period from a set of rates, by the recent wealth of one exponentiated-gradient run per rate.

This is the moving-window adaptive rate of Zhang, Lin, Zheng and Yang (2022). Each rate in etas names an expert, the exponentiated gradient run at that rate from the Start Allocation. The rate of the period is the rate of the expert with the largest wealth over the last window periods. When window is nothing, the schedule compares the wealth over the whole history. The paper calls the first rule MAEG and the second AEG.

The experts are a statistic of the run, and the rule never plays them. Each expert takes the paper's plain entropic step over the simplex, from the rule's Start Allocation, whatever the rule's own geometry, Allocation Set, uniform mix, Gradient Transform and objective. The rule applies the chosen rate to its own step. So on another geometry the schedule chooses the rate by a replay of the exponentiated gradient.

The paper takes the rate set 0.001:0.001:0.2 from the practice of Helmbold, Schapire, Singer and Warmuth (1998). It chose the window 30 over 7 on its own data. Over windows from 2 to 50, it reports that the final wealth stays within a small range, and that the window must stay within a reasonable range. A period costs one entropic step per rate and one sum over the ring, which is O((N + w) K) at K rates. The online form of ExpectationMaximisation refuses this schedule by name, because that form also reads the rate of the next period.

Mathematical definition

\[\begin{align} t' &= \max(1, t - w + 1)\,, \\ S_t(\eta) &= \prod_{\tau = t'}^{t} \langle \boldsymbol{b}_\tau(\eta), \boldsymbol{x}_\tau \rangle\,, \\ \eta_t &= \underset{\eta \in H}{\arg\max} \; S_t(\eta)\,. \end{align}\]

Where:

  • $H$: Set of rates, the field etas.
  • $w$: Window, in periods. Under the whole history $t' = 1$.
  • $\boldsymbol{b}_\tau(\eta)$: Allocation of the expert at rate $\eta$ in period $\tau$.
  • $\boldsymbol{x}_t$: Price relative vector of period $t$, each asset's price over its price one period earlier.
  • $S_t(\eta)$: Wealth of the expert at rate $\eta$ over the window that ends at period $t$.
  • $\eta_t$: Learning rate of the update at period $t$.
  • $t$: Period index, counted from one.

The rate of the update at period $t$ reads $\boldsymbol{x}_t$. It is the paper's $\eta_{t+1}$, which forms $\boldsymbol{b}_{t+1}$ from $\boldsymbol{b}_t$ and $\boldsymbol{x}_t$. At a tie the first rate of etas wins.

Algorithm

  1. Before the first row, seed the state: every column of B is the Start Allocation, and L is zero, with window rows, or one row under the whole history.
  2. The schedule answers true to reads_period_row, so the rule writes the state before it reads the rate. At period n, find the row row of L with ring_row.
  3. For the expert b at each rate eta, compute its period return r = dot(b, x). Write log(r) into L[row, k]: overwrite it under a window, and add it to the running sum under the whole history.
  4. Step b to b .* exp.(eta .* x ./ r), and divide it by its sum.
  5. Sum each column of L, and take the rate of the column with the largest sum. The sum is in logs, so the comparison never overflows.

Fields

  • etas: The rates the experts run at, one exponentiated-gradient run each.
  • window: The number of periods over which the schedule compares the experts' wealth. nothing compares the whole history.

Constructors

WindowedBestRate(; etas::AbstractVector{<:Real} = 0.001:0.001:0.2, window::Option{<:Integer} = 30) -> WindowedBestRate

Keywords correspond to the struct's fields.

Validation

  • etas: non-empty, and every element is positive and finite.
  • window >= 1 when it is a number. A DomainError is thrown otherwise.

Examples

julia> WindowedBestRate()WindowedBestRate    etas ┼ 200-element StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}  window ┴ Int64: 30

Related

References

  • [198] Y. Zhang, H. Lin, L. Zheng and X. Yang. Adaptive online portfolio strategy based on exponential gradient updates. Journal of Combinatorial Optimization 43(3), 672–696 (2022).
  • [178] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. On-line portfolio selection using multiplicative updates. Mathematical Finance 8, 325–347 (1998).
source
PortfolioOptimisers.GradientMomentum — Type
struct GradientMomentum{T1<:Real} <: AbstractGradientTransform

Replaces the gradient with its exponential moving average, which gives the step a momentum.

This is Eq. 7 of Li, Zheng, Chen, Wang and Xu (2022). Under the entropic map it is the paper's EGE, and its Theorem 1 gives the regret $O(\sqrt{T \log N})$ of the exponentiated gradient.

Mathematical definition

\[\begin{align} \boldsymbol{v}_{t+1} &= \gamma_1 \boldsymbol{v}_t + (1 - \gamma_1) \boldsymbol{g}_t\,, \\ \hat{\boldsymbol{g}}_t &= \boldsymbol{v}_{t+1}\,. \end{align}\]

Where:

  • $\boldsymbol{v}_t$: Gradient average before period $t$, zero at $t = 1$.
  • $\gamma_1$: Momentum decay, the weight the gradient average keeps on its past, in $[0, 1)$.
  • $\boldsymbol{g}_t$: Gradient of the loss of period $t$, taken at the iterate.
  • $\hat{\boldsymbol{g}}_t$: Transformed gradient of period $t$, the vector the mirror step reads.

The average starts at zero, so the first transformed gradient is $(1 - \gamma_1) \boldsymbol{g}_1$. The paper applies no bias correction, and neither does this transform.

Fields

  • gamma1: The decay of the moving average of the gradient, in [0, 1).

Constructors

GradientMomentum(; gamma1::Real = 0.99) -> GradientMomentum

Keywords correspond to the struct's fields. The default is the paper's.

Validation

  • 0 <= gamma1 < 1. A DomainError is thrown otherwise.

Examples

julia> GradientMomentum()GradientMomentum  gamma1 ┴ Float64: 0.99

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.RootMeanSquareGradient — Type
struct RootMeanSquareGradient{T1<:Real, T2<:Real} <: AbstractGradientTransform

Divides the gradient by the root of a moving average of its square, per asset.

This is Eq. 8 of Li, Zheng, Chen, Wang and Xu (2022). Under the entropic map it is the paper's EGR.

At the default $\gamma_2 = 0$, which the paper recommends, the rule under LogWealth stays at its Start Allocation, up to the offset $\epsilon$. At $\gamma_2 = 0$ the transformed gradient is the sign of the gradient, up to $\epsilon$. Every entry of the log-wealth gradient is negative, so the step moves every asset by the same amount, and the normalisation undoes it. The rule is then the constant rebalanced portfolio at its Start Allocation, not buy-and-hold. A positive $\gamma_2$ gives the average a memory, and the rule then moves.

Mathematical definition

\[\begin{align} \boldsymbol{m}_{t+1} &= \gamma_2 \boldsymbol{m}_t + (1 - \gamma_2) \boldsymbol{g}_t^2\,, \\ \hat{\boldsymbol{g}}_t &= \frac{\boldsymbol{g}_t}{\sqrt{\boldsymbol{m}_{t+1}} + \epsilon}\,. \end{align}\]

Where:

  • $\boldsymbol{m}_t$: Squared-gradient average before period $t$, the square taken per asset, zero at $t = 1$.
  • $\gamma_2$: Squared-gradient decay, the weight the squared-gradient average keeps on its past, in $[0, 1)$.
  • $\boldsymbol{g}_t$: Gradient of the loss of period $t$, taken at the iterate.
  • $\hat{\boldsymbol{g}}_t$: Transformed gradient of period $t$, the vector the mirror step reads.
  • $\epsilon$: Positive offset added to the root of the squared-gradient average before the division.

The square, the root and the division are per asset. At $\gamma_2 = 0$, $\hat{\boldsymbol{g}}_t = \boldsymbol{g}_t / (\lvert \boldsymbol{g}_t \rvert + \epsilon)$.

Fields

  • gamma2: The decay of the moving average of the squared gradient, in [0, 1).
  • eps: The constant added to the root of the average before the division.

Constructors

RootMeanSquareGradient(; gamma2::Real = 0, eps::Real = 1e-8) -> RootMeanSquareGradient

Keywords correspond to the struct's fields. The defaults are the paper's.

Validation

  • 0 <= gamma2 < 1, eps > 0. A DomainError is thrown otherwise.

Examples

julia> RootMeanSquareGradient()RootMeanSquareGradient  gamma2 ┼ Int64: 0     eps ┴ Float64: 1.0e-8

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.AdaptiveMomentGradient — Type
struct AdaptiveMomentGradient{T1<:Real, T2<:Real, T3<:Real} <: AbstractGradientTransform

Divides the moving average of the gradient by the root of the moving average of its square, per asset.

This is Eq. 9 of Li, Zheng, Chen, Wang and Xu (2022), with both averages of GradientMomentum and RootMeanSquareGradient and no bias correction. Under the entropic map it is the paper's EGA.

Mathematical definition

\[\begin{align} \boldsymbol{v}_{t+1} &= \gamma_1 \boldsymbol{v}_t + (1 - \gamma_1) \boldsymbol{g}_t\,, \\ \boldsymbol{m}_{t+1} &= \gamma_2 \boldsymbol{m}_t + (1 - \gamma_2) \boldsymbol{g}_t^2\,, \\ \hat{\boldsymbol{g}}_t &= \frac{\boldsymbol{v}_{t+1}}{\sqrt{\boldsymbol{m}_{t+1}} + \epsilon}\,. \end{align}\]

Where:

  • $\boldsymbol{v}_t$: Gradient average before period $t$, zero at $t = 1$.
  • $\boldsymbol{m}_t$: Squared-gradient average before period $t$, the square taken per asset, zero at $t = 1$.
  • $\gamma_1$: Momentum decay, the weight the gradient average keeps on its past, in $[0, 1)$.
  • $\gamma_2$: Squared-gradient decay, the weight the squared-gradient average keeps on its past, in $[0, 1)$.
  • $\boldsymbol{g}_t$: Gradient of the loss of period $t$, taken at the iterate.
  • $\hat{\boldsymbol{g}}_t$: Transformed gradient of period $t$, the vector the mirror step reads.
  • $\epsilon$: Positive offset added to the root of the squared-gradient average before the division.

At the default $\gamma_2 = 0$, which the paper recommends, the divisor is $\lvert \boldsymbol{g}_t \rvert + \epsilon$. The step then reads the momentum in units of the size of the current gradient.

Fields

  • gamma1: The decay of the moving average of the gradient, in [0, 1).
  • gamma2: The decay of the moving average of the squared gradient, in [0, 1).
  • eps: The constant added to the root of the second average before the division.

Constructors

AdaptiveMomentGradient(; gamma1::Real = 0.99, gamma2::Real = 0, eps::Real = 1e-8) -> AdaptiveMomentGradient

Keywords correspond to the struct's fields. The defaults are the paper's.

Validation

  • 0 <= gamma1 < 1, 0 <= gamma2 < 1, eps > 0. A DomainError is thrown otherwise.

Examples

julia> AdaptiveMomentGradient()AdaptiveMomentGradient  gamma1 ┼ Float64: 0.99  gamma2 ┼ Int64: 0     eps ┴ Float64: 1.0e-8

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.AbstractOnlineObjective — Type
abstract type AbstractOnlineObjective <: AbstractAlgorithm

Abstract supertype for the objectives of a first-order Online Selection Rule.

The objective is the loss of each period. The mirror step reads the gradient of that loss at the iterate.

Interfaces

In order to implement a new objective, subtype AbstractOnlineObjective and implement:

  • loss_gradient(obj::AbstractOnlineObjective, u::AbstractVector, x::AbstractVector, rows) -> AbstractVector: The gradient of the period's loss at the iterate u. It reads the period's price relative x and the rows the head holds, which are nothing when the objective reads no rows.
  • rows_needed(obj::AbstractOnlineObjective) -> Union{Nothing, Integer}: The number of rows the objective reads at a step, 0 when it reads none. The rule that holds the objective answers this number as its own.

Related

source
PortfolioOptimisers.LogWealth — Type
struct LogWealth <: AbstractOnlineObjective

Takes the negative log of the period's wealth as the loss of a first-order Online Selection Rule.

It reads the period's price relative and no rows. It is the default objective of MirrorDescent, and the objective of every rule that the docstring of MirrorDescent cites.

Mathematical definition

\[\begin{align} \ell_t(\boldsymbol{w}) &= -\log \langle \boldsymbol{w}, \boldsymbol{x}_t \rangle\,, \\ \boldsymbol{g}_t &= \nabla \ell_t(\boldsymbol{w}_t) = -\frac{\boldsymbol{x}_t}{\langle \boldsymbol{w}_t, \boldsymbol{x}_t \rangle}\,. \end{align}\]

Where:

  • $\ell_t$: Loss of period $t$.
  • $\boldsymbol{w}$: Allocation at which the loss is evaluated.
  • $\boldsymbol{x}_t$: Price relative vector of period $t$, each asset's price over its price one period earlier.
  • $\boldsymbol{w}_t$: Iterate of the rule at period $t$, the allocation its update reads.
  • $\boldsymbol{g}_t$: Gradient of the loss of period $t$, taken at the iterate.

Examples

julia> LogWealth()LogWealth()

Related

source
PortfolioOptimisers.RiskLoss — Type
struct RiskLoss{T1<:(Union{var"#s7444", var"#s7443"} where {var"#s7444"<:AbstractBaseRiskMeasure, var"#s7443"<:(AbstractVector{<:AbstractBaseRiskMeasure})}), T2<:Integer, T3<:Scalariser, T4<:AbstractPriorEstimator} <: AbstractOnlineObjective

Takes a risk measure over the last window rows the head holds as the loss of a first-order Online Selection Rule.

The Risk Loss replaces log wealth as the objective. r is one risk measure or a vector of them. The Risk Loss reads returns and not price relatives, because a risk measure reads returns. At every step the prior pe is fitted on the window, and the measure is resolved against that prior. So a Variance reads the covariance of the window, and a measure that holds its own matrix keeps it. The rule takes one step per period towards the minimiser of the measure, which it estimates again each period.

sca scalarises a vector of measures at the settings.scale of each measure. So [MeanReturn(), Variance()], with a negative scale on the mean, gives one step on the mean-variance utility.

A prior fitted on one row has no covariance. So the loss starts when the head holds two rows, and the step before that leaves the iterate unchanged. The head's rows buffer holds at most window rows, so the first window - 1 steps read a shorter window.

A risk gradient is small, so a rule on a Risk Loss needs a much larger rate than a log-wealth rule. A variance gradient $2 \boldsymbol{\Sigma} \boldsymbol{w}$ has the size of one period's variance. Take 1000 periods of returns randn(StableRNG(7), 1000, 4) .* [0.01 0.02 0.03 0.04], a window of 20 and the uniform allocation. Over every window, the log-wealth gradient is then between 1100 and 6400 times larger than the variance gradient. The entropic rule on Variance at the log-wealth default eta = 0.05 ends 0.005 from its uniform start, and the minimum-variance allocation is 0.45 away. At eta = 100 the rule ends within 0.06 of that allocation.

The prior is fitted on the head's rows carrier as a batch prior is fitted on any carrier. The carrier holds NaN where there was no return, and the active mask beside it. So under a time-varying panel the prior reduces to the Coverage Universe of the window, and answers NaN at an asset that the window does not cover. The loss reads its gradient on the Investable Mask of that result, and writes zero at every other leg. The window holds no data about such a leg, so the loss does not move it, and the projection alone places it. A plain pe therefore never meets a constant column. A leg unlisted for a part of the window is outside the Coverage Universe of a plain prior until the window clears that part. A mask-aware prior takes the leg in after its own warm-up.

The regret theorems of the first-order rules need a convex loss. So they hold here for the measures that are convex in the weights: Variance, StandardDeviation, ConditionalValueatRisk, EntropicValueatRisk, WorstRealisation, Range, MaximumDrawdown, AverageDrawdown, ConditionalDrawdownatRisk, EntropicDrawdownatRisk, the low-order moment measures, and MeanReturn, which is linear. A quantile measure such as ValueatRisk or DrawdownatRisk, a kurtosis, a skewness and a ratio are not convex, and on them the step is a heuristic with no bound. At a kink of a convex measure, a finite-difference gradient is the chord across the kink, near a subgradient, as risk_gradient states.

Mathematical definition

\[\begin{align} \ell_t(\boldsymbol{w}) &= \rho(\boldsymbol{w}; \mathbf{X}_t)\,, \\ \boldsymbol{g}_t &= \nabla_{\boldsymbol{w}} \rho(\boldsymbol{w}_t; \mathbf{X}_t)\,. \end{align}\]

Where:

  • $\ell_t$: Loss of period $t$.
  • $\rho$: Risk measure, resolved against the prior fitted on $\mathbf{X}_t$. A vector of measures is their scalarisation.
  • $\mathbf{X}_t$: Returns of the last $\min(t, W)$ periods through period $t$, with $W$ the field window.
  • $\boldsymbol{w}_t$: Iterate of the rule at period $t$, the allocation its update reads.
  • $\boldsymbol{g}_t$: Gradient of the loss of period $t$, taken at the iterate.

risk_gradient computes $\boldsymbol{g}_t$, in closed form where the library states one and by a finite difference otherwise. loss_gradient states the steps.

Fields

  • r: Risk measure or vector of risk measures.
  • window: The number of rows of the head's returns buffer that the loss reads.
  • sca: Scalariser for combining multiple risk measures.
  • pe: Prior estimator.

Constructors

RiskLoss(;    r::BaseRM_VecBaseRM = Variance(),    window::Integer = 20,    sca::Scalariser = SumScalariser(),    pe::AbstractPriorEstimator = EmpiricalPrior()) -> RiskLoss

Keywords correspond to the struct's fields.

Validation

  • window >= 2. A DomainError is thrown otherwise, because a prior fitted on one row has no covariance, and the loss never reads a window of one row.

Examples

julia> RiskLoss()RiskLoss       r ┼ Variance         │   settings ┼ RiskMeasureSettings         │            │   scale ┼ Float64: 1.0         │            │      ub ┼ nothing         │            │     rke ┴ Bool: true         │      sigma ┼ nothing         │       chol ┼ nothing         │         rc ┼ nothing         │        alg ┴ SquaredSOCRiskExpr()  window ┼ Int64: 20     sca ┼ SumScalariser()      pe ┼ EmpiricalPrior         │           ce ┼ PortfolioOptimisersCovariance         │              │   ce ┼ Covariance         │              │      │    me ┼ SimpleExpectedReturns         │              │      │       │   w ┴ nothing         │              │      │    ce ┼ GeneralCovariance         │              │      │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)         │              │      │       │    w ┴ nothing         │              │      │   alg ┼ FullMoment()         │              │      │     w ┴ nothing         │              │   mp ┼ MatrixProcessing         │              │      │     pdm ┼ Posdef         │              │      │         │      alg ┼ UnionAll: NearestCorrelationMatrix.Newton         │              │      │         │   kwargs ┴ @NamedTuple{}: NamedTuple()         │              │      │      dn ┼ nothing         │              │      │      dt ┼ nothing         │              │      │     alg ┼ nothing         │              │      │   order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)         │           me ┼ SimpleExpectedReturns         │              │   w ┴ nothing         │      horizon ┼ nothing         │   fill_limit ┴ nothing

Related

source
PortfolioOptimisers.MirrorDescent — Type
struct MirrorDescent{T1<:(Union{var"#s7439", var"#s7438"} where {var"#s7439"<:Real, var"#s7438"<:AbstractLearningRateSchedule}), T2<:(Union{var"#s7436", var"#s7435", var"#s7434", var"#s7433"} where {var"#s7436"<:EuclideanProjection, var"#s7435"<:EntropicProjection, var"#s7434"<:TsallisProjection, var"#s7433"<:LogBarrierProjection}), T3<:Real, T4<:AbstractOnlineObjective, T5<:AbstractGradientTransform} <: AbstractOnlinePortfolioSelectionAlgorithm

Takes one mirror-descent step on the period's gradient, then projects the result back onto the Allocation Set.

This is the first-order Online Selection Rule of the family. The step and the projection both use the divergence of the rule's Projection Geometry.

Each geometry gives a published rule.

  • Under EntropicProjection the step is the multiplicative update of Helmbold, Schapire, Singer and Warmuth (1998), the exponentiated gradient. Its regret is $O(\sqrt{T \log N})$ at $\eta = 2 r \sqrt{2 \log N / T}$, when every price relative is at least $r$ times the largest one of its period.
  • Under EuclideanProjection the step is additive, and the projection onto the simplex follows it. This is the online gradient descent of Zinkevich (2003), with regret $O(\sqrt{T N})$. It is also the gradient projection of Helmbold and co-authors (1997), except that the 1997 paper assumes the projection and does not enforce it.
  • Under TsallisProjection and LogBarrierProjection the step is the barrier step of Abernethy, Lee and Tewari (2015), Zimmert and Seldin (2021) and Orseau, Lattimore and Legg (2017, §7). On the default set each projection is a scalar root.

The Euclidean map admits every Allocation Set the head admits. The other three maps are defined on the positive orthant, so they refuse a set with a negative lower bound. The tuned rates of the theorems need the horizon, which an online rule does not know, so the library states them as formulas only. The anytime rates are InverseSquareRootRate, SelfConfidentRate and DoublingTrickRate, on eta.

alpha is the uniform mix of Helmbold and co-authors (1998, Theorem 4.2). The update reads the mixed price relatives at the unmixed iterate, and the head plays the mix of the new iterate. mixed_relatives states how the mix scales to the paper's relatives, which have a period maximum of one. The carrier holds the unmixed iterate, so the rule never inverts the mix. At alpha = 0 the played allocation is the iterate, and the rule is the plain step. The mix is a convex shift and not a projection, so every geometry admits it. The theorem, $O(T^{3/4})$ regret at $\alpha = (N^2 \log N / (8 T))^{1/4}$ with no lower bound on the price relatives, holds under the entropic map. The doubling trick of Corollary 4.3 sets $\alpha$ and $\eta$ per stage, and its share takes precedence over alpha. The rule plays the Start Allocation unmixed in the first period, as every rule does.

The mix lies in the Allocation Set when the uniform allocation does. Otherwise reprojection projects it onto the set again, in the rule's geometry. A bounded set that excludes the uniform allocation, a turnover ceiling and a MIP kind are such sets. On the default set the reprojection costs nothing.

A schedule can name a restart. The update of that period then returns the Start Allocation, re-entered onto the set from the book the fund holds by reprojection. The update puts the carrier back at its seed, and the averages of the Gradient Transform restart with it. The period count stays, because the stages are cumulative.

The rule can also serve inside a mixture. As the weighting of an ExpertMixture, it moves the weight over the experts on their period returns. As an expert of a mixture under BlendPoint, the rule reads its gradient at the blend that the mixture played, and steps from its own iterate. The seven-argument online_update! hands it that Gradient Point. This is the shared gradient of Zhang, Lu and Zhou (2018) and of Zhao, Zhang, Zhang and Zhou (2020). On the head, and under OwnPoint, the point is the iterate.

obj is the loss. LogWealth is the loss of every rule above. A RiskLoss is a risk measure over the last window rows the head holds. The rule reads as many rows as its objective. Only the log-wealth gradient reads the mixed price relatives, because a risk measure reads returns and not price relatives. The mix of the played allocation applies under both.

Mathematical definition

\[\begin{align} \tilde{\boldsymbol{x}}_t &= \left(1 - \frac{\alpha}{N}\right) \boldsymbol{x}_t + \frac{\alpha}{N} \max_i x_{t, i} \boldsymbol{1}\,, \\ \boldsymbol{w}_{t+1} &= \underset{\boldsymbol{w} \in \mathcal{W}}{\arg\min} \; \eta_t \langle \hat{\boldsymbol{g}}_t, \boldsymbol{w} \rangle + D_\Psi(\boldsymbol{w}, \boldsymbol{w}_t) = \mathrm{Proj}_\Psi\left( \nabla \Psi^* \left( \nabla \Psi(\boldsymbol{w}_t) - \eta_t \hat{\boldsymbol{g}}_t \right) \right)\,, \\ \tilde{\boldsymbol{w}}_{t+1} &= (1 - \alpha) \boldsymbol{w}_{t+1} + \frac{\alpha}{N} \boldsymbol{1}\,. \end{align}\]

Where:

  • $\boldsymbol{x}_t$: Price relative vector of period $t$, each asset's price over its price one period earlier.
  • $x_{t, i}$: Price relative of asset $i$ in period $t$.
  • $\tilde{\boldsymbol{x}}_t$: Mixed price relative vector of period $t$. The log-wealth gradient reads it in place of $\boldsymbol{x}_t$.
  • $\alpha$: Uniform-mix share, in $[0, 1)$.
  • $N$: Number of assets.
  • $\boldsymbol{1}$: Vector of ones.
  • $\boldsymbol{w}_t$: Iterate of the rule at period $t$, the allocation its update reads.
  • $\hat{\boldsymbol{g}}_t$: Transformed gradient of period $t$, the vector the mirror step reads. It is the Gradient Transform of $\boldsymbol{g}_t$, the gradient of the loss.
  • $\eta_t$: Learning rate of the update at period $t$.
  • $\mathcal{W}$: Allocation Set.
  • $\Psi$: Potential of the Projection Geometry.
  • $D_\Psi$: Bregman divergence of $\Psi$.
  • $\Psi^*$: Convex conjugate of $\Psi$.
  • $\mathrm{Proj}_\Psi$: Projection onto $\mathcal{W}$ in the divergence $D_\Psi$.
  • $\tilde{\boldsymbol{w}}_{t+1}$: Allocation the head plays in period $t + 1$.

Under the entropic map the step is $w_{t+1, i} \propto w_{t, i} \exp(-\eta_t \hat{g}_{t, i})$. Under the Euclidean map it is $\mathrm{Proj}_{\mathcal{W}}(\boldsymbol{w}_t - \eta_t \hat{\boldsymbol{g}}_t)$. At $\alpha = 0$, $\tilde{\boldsymbol{x}}_t = \boldsymbol{x}_t$ and $\tilde{\boldsymbol{w}}_{t+1} = \boldsymbol{w}_{t+1}$.

Algorithm

The seven-argument online_update! runs these steps at the period's row x. The six-argument form calls it with the iterate as the Gradient Point point.

  1. Set the period t = st.n + 1, and the Price-Adjusted Allocation wh of the book w after the row.
  2. When the schedule names a restart at t, re-enter the Start Allocation st.w0 onto the set from wh with reprojection. Put the statistic and the carrier of the Gradient Transform back at their seeds, keep t, and return that allocation. Stop.
  3. When the schedule reads the period's row, write its statistic from w and x.
  4. Read the rate eta and the share alpha of period t. A schedule's share takes precedence over the field alpha.
  5. Mix the price relatives into xm with mixed_relatives.
  6. Take the gradient g of the loss at point, from xm and the head's rows.
  7. Transform g with the Gradient Transform, which updates its carrier.
  8. Take the mirror step q from the iterate st.u, on eta times the transformed gradient.
  9. Project q onto the set from wh, which gives the new iterate u.
  10. When the schedule reads the past alone, write its statistic from w and x.
  11. Form the played allocation from u with played_allocation. When alpha is positive, project it with reprojection.
  12. Return the new state and the played allocation.

Fields

  • eta: The learning rate, a number or a Learning-Rate Schedule. A larger rate reacts faster and is less stable.
  • proj: The Projection Geometry the rule projects its raw step onto the Allocation Set in; the slot's type bound names the geometries the rule's theorem covers.
  • alpha: The uniform-mix share, in [0, 1). At 0 the rule takes the plain step.
  • obj: The objective whose gradient the rule reads, log wealth or a Risk Loss over the head's rows.
  • grad: The Gradient Transform applied before the mirror step.

Constructors

MirrorDescent(;    eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05,    proj::Union{<:EuclideanProjection, <:EntropicProjection, <:TsallisProjection, <:LogBarrierProjection} = EntropicProjection(),    alpha::Real = 0,    obj::AbstractOnlineObjective = LogWealth(),    grad::AbstractGradientTransform = PlainGradient()) -> MirrorDescent

Keywords correspond to the struct's fields. The proj slot takes only the geometries whose projection onto the default set is a scalar root. ExponentiatedGradient fills it with the entropic map, and GradientProjection with the Euclidean map.

Validation

  • If eta is a number: eta > 0. A DomainError is thrown otherwise.
  • 0 <= alpha < 1. A DomainError is thrown otherwise.

Examples

julia> MirrorDescent()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┴ PlainGradient()

Related

References

  • [178] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. On-line portfolio selection using multiplicative updates. Mathematical Finance 8, 325–347 (1998).
  • [192] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. A comparison of new and old algorithms for a mixture estimation problem. Machine Learning 27(1), 97–119 (1997).
  • [152] M. Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In: Proceedings of the 20th International Conference on Machine Learning, 928–936 (2003).
  • [185] J. D. Abernethy, C. Lee and A. Tewari. Fighting bandits with a new kind of smoothness. In: Advances in Neural Information Processing Systems 28 (2015).
  • [186] J. Zimmert and Y. Seldin. Tsallis-INF: An optimal algorithm for stochastic and adversarial bandits. Journal of Machine Learning Research 22(28), 1–49 (2021).
  • [187] L. Orseau, T. Lattimore and S. Legg. Soft-Bayes: Prod for mixtures of experts with log-loss. In: Proceedings of the 28th International Conference on Algorithmic Learning Theory, PMLR 76, 372–399 (2017).
source
PortfolioOptimisers.gradient_state_seed — Function
gradient_state_seed(grad::PlainGradient, w::AbstractVector)
gradient_state_seed(grad::GradientMomentum, w::AbstractVector)
gradient_state_seed(grad::RootMeanSquareGradient, w::AbstractVector)
gradient_state_seed(grad::AdaptiveMomentGradient, w::AbstractVector)

Seeds the carrier that a Gradient Transform keeps on the Rule State before the first row.

The seed is nothing for PlainGradient, the zero average for GradientMomentum, the zero squared average for RootMeanSquareGradient, and the pair of both for AdaptiveMomentGradient.

Related

source
PortfolioOptimisers.transform_gradient! — Function
transform_gradient!(grad::PlainGradient, gs, g::AbstractVector)
transform_gradient!(grad::GradientMomentum, v::AbstractVector, g::AbstractVector)
transform_gradient!(grad::RootMeanSquareGradient, m::AbstractVector, g::AbstractVector)
transform_gradient!(grad::AdaptiveMomentGradient, gs::Tuple, g::AbstractVector)

Computes the transformed gradient of the period, and writes the updated carrier in place.

PlainGradient returns g itself. GradientMomentum returns a copy of the updated average v. RootMeanSquareGradient returns g over the root of the updated squared average m, plus eps. AdaptiveMomentGradient returns the updated v over that root plus eps. The type docstrings state the formulas.

Related

source
PortfolioOptimisers.loss_gradient — Function
loss_gradient(obj::LogWealth, u::AbstractVector, x::AbstractVector, rows)
loss_gradient(obj::RiskLoss, u::AbstractVector, x::AbstractVector, rows)

Computes the gradient of the period's loss at the iterate u.

For LogWealth the gradient reads the price relative x alone. For a RiskLoss it reads the rows carrier rows. The type docstrings state the two losses and their gradients.

Algorithm

The LogWealth method returns -x ./ dot(u, x). The RiskLoss method runs these steps.

  1. When rows is nothing, or holds fewer than two rows, return the zero vector.
  2. Fit the prior pr of the loss on rows, as a batch prior is fitted, on the rows of the carrier and its Asset Panel. The prior answers NaN at an asset outside its Coverage Universe.
  3. Read the Investable Mask of pr.
  4. Compute the gradient of the measure on that mask with investable_risk_gradient. It is zero at every other leg.

Related

source
PortfolioOptimisers.ExponentiatedGradient — Function
ExponentiatedGradient(; eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05, alpha::Real = 0, obj::AbstractOnlineObjective = LogWealth(), grad::AbstractGradientTransform = PlainGradient())

Builds the exponentiated gradient of Helmbold, Schapire, Singer and Warmuth (1998), a MirrorDescent rule under EntropicProjection (EG).

The rule moves weight towards the assets that just did well. Its regret is $O(\sqrt{T \log N})$ at a rate tuned to the horizon, and under the uniform mix alpha with the doubling trick it is universal. The default rate is the paper's $0.05$. In its §5.2, rates from $0.01$ to $0.15$ all do well, and a rate above one loses money on the two-stock example. As the weighting of an ExpertMixture, the rule takes the online gradient step over the vector of expert returns.

Mathematical definition

Under LogWealth, at alpha = 0 and with no Gradient Transform,

\[\begin{align} w_{t+1, i} &= \frac{w_{t, i} \exp(\eta_t x_{t, i} / \langle \boldsymbol{w}_t, \boldsymbol{x}_t \rangle)}{\sum_j w_{t, j} \exp(\eta_t x_{t, j} / \langle \boldsymbol{w}_t, \boldsymbol{x}_t \rangle)}\,. \end{align}\]

Where:

  • $w_{t, i}$: Weight of asset $i$ in the iterate of period $t$.
  • $x_{t, i}$: Price relative of asset $i$ in period $t$.
  • $\boldsymbol{w}_t$: Iterate of the rule at period $t$, the allocation its update reads.
  • $\boldsymbol{x}_t$: Price relative vector of period $t$, each asset's price over its price one period earlier.
  • $\eta_t$: Learning rate of the update at period $t$.

The normalisation is the entropic projection onto the simplex.

Examples

julia> ExponentiatedGradient()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┴ PlainGradient()

Related

References

  • [178] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. On-line portfolio selection using multiplicative updates. Mathematical Finance 8, 325–347 (1998).
source
PortfolioOptimisers.GradientProjection — Function
GradientProjection(; eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05, alpha::Real = 0, obj::AbstractOnlineObjective = LogWealth(), grad::AbstractGradientTransform = PlainGradient())

Builds the gradient projection of Helmbold, Schapire, Singer and Warmuth (1997), a MirrorDescent rule under EuclideanProjection (GP, OGD).

On the simplex this is the online gradient descent of Zinkevich (2003). The 1997 paper subtracts the mean of the gradient to keep the budget, and assumes that the weights stay non-negative. The projection keeps the budget and enforces the sign, and on the simplex it is Zinkevich's fixed-rate step. The regret is $O(\sqrt{T})$ at $\eta \propto 1 / \sqrt{T}$, and InverseSquareRootRate is the anytime rate. Neither paper states a rate for the portfolio problem, so the default is the rate of ExponentiatedGradient.

Mathematical definition

Under LogWealth, at alpha = 0 and with no Gradient Transform,

\[\begin{align} \boldsymbol{w}_{t+1} &= \mathrm{Proj}_{\mathcal{W}}\left( \boldsymbol{w}_t + \eta_t \frac{\boldsymbol{x}_t}{\langle \boldsymbol{w}_t, \boldsymbol{x}_t \rangle} \right)\,. \end{align}\]

Where:

  • $\boldsymbol{w}_t$: Iterate of the rule at period $t$, the allocation its update reads.
  • $\boldsymbol{x}_t$: Price relative vector of period $t$, each asset's price over its price one period earlier.
  • $\eta_t$: Learning rate of the update at period $t$.
  • $\mathrm{Proj}_{\mathcal{W}}$: Euclidean projection onto the Allocation Set $\mathcal{W}$.

On the simplex, the projection sets to zero every entry that the step leaves below the projection's threshold.

Examples

julia> GradientProjection()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EuclideanProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┴ PlainGradient()

Related

References

  • [192] D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. A comparison of new and old algorithms for a mixture estimation problem. Machine Learning 27(1), 97–119 (1997).
  • [152] M. Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In: Proceedings of the 20th International Conference on Machine Learning, 928–936 (2003).
source
PortfolioOptimisers.EGE — Function
EGE(; eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05, gamma1::Real = 0.99, alpha::Real = 0)

Builds the exponentiated gradient with the momentum of an exponential moving average, ExponentiatedGradient under GradientMomentum (EGE).

This is the EGE of Li, Zheng, Chen, Wang and Xu (2022). The paper's rate is the rate $2 r \sqrt{2 \log N / T}$ of Helmbold and co-authors, with the doubling trick when the horizon is unknown. DoublingTrickRate on eta gives that trick. The default rate is the rate of ExponentiatedGradient.

Examples

julia> EGE()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┼ GradientMomentum        │   gamma1 ┴ Float64: 0.99

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.EGR — Function
EGR(; eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05, gamma2::Real = 0, eps::Real = 1e-8, alpha::Real = 0)

Builds the exponentiated gradient with a root-mean-square scale on the gradient, ExponentiatedGradient under RootMeanSquareGradient (EGR).

This is the EGR of Li, Zheng, Chen, Wang and Xu (2022). At the default gamma2 = 0, which the paper recommends, the rule stays at its Start Allocation, up to eps. The transformed gradient is then the sign of the gradient, the same at every asset, so the update moves nothing, and the rule is the constant rebalanced portfolio at its Start Allocation. RootMeanSquareGradient states why.

Examples

julia> EGR()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┼ RootMeanSquareGradient        │   gamma2 ┼ Int64: 0        │      eps ┴ Float64: 1.0e-8

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.EGA — Function
EGA(; eta::Union{<:Real, <:AbstractLearningRateSchedule} = 0.05, gamma1::Real = 0.99, gamma2::Real = 0, eps::Real = 1e-8, alpha::Real = 0)

Builds the exponentiated gradient with an adaptive-moment scale on the gradient, ExponentiatedGradient under AdaptiveMomentGradient (EGA).

This is the EGA of Li, Zheng, Chen, Wang and Xu (2022).

Examples

julia> EGA()MirrorDescent    eta ┼ Float64: 0.05   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┼ AdaptiveMomentGradient        │   gamma1 ┼ Float64: 0.99        │   gamma2 ┼ Int64: 0        │      eps ┴ Float64: 1.0e-8

Related

References

  • [199] Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).
source
PortfolioOptimisers.MAEG — Function
MAEG(; etas::AbstractVector{<:Real} = 0.001:0.001:0.2, window::Integer = 30, alpha::Real = 0)

Builds the moving-window adaptive exponential gradient, ExponentiatedGradient under a WindowedBestRate over window periods (MAEG).

This is the MAEG of Zhang, Lin, Zheng and Yang (2022). The defaults are the paper's, the rate set of Helmbold, Schapire, Singer and Warmuth (1998) and the window 30, which the paper chose over 7.

Examples

julia> MAEG(; etas = [0.05, 0.1], window = 5)MirrorDescent    eta ┼ WindowedBestRate        │     etas ┼ Vector{Float64}: [0.05, 0.1]        │   window ┴ Int64: 5   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┴ PlainGradient()

Related

References

  • [198] Y. Zhang, H. Lin, L. Zheng and X. Yang. Adaptive online portfolio strategy based on exponential gradient updates. Journal of Combinatorial Optimization 43(3), 672–696 (2022).
source
PortfolioOptimisers.AEG — Function
AEG(; etas::AbstractVector{<:Real} = 0.001:0.001:0.2, alpha::Real = 0)

Builds the adaptive exponential gradient, ExponentiatedGradient under a WindowedBestRate over the whole history (AEG).

This is the AEG of Zhang, Lin, Zheng and Yang (2022), the special case of MAEG whose window is the horizon.

Examples

julia> AEG(; etas = [0.05, 0.1])MirrorDescent    eta ┼ WindowedBestRate        │     etas ┼ Vector{Float64}: [0.05, 0.1]        │   window ┴ nothing   proj ┼ EntropicProjection()  alpha ┼ Int64: 0    obj ┼ LogWealth()   grad ┴ PlainGradient()

Related

References

  • [198] Y. Zhang, H. Lin, L. Zheng and X. Yang. Adaptive online portfolio strategy based on exponential gradient updates. Journal of Combinatorial Optimization 43(3), 672–696 (2022).
source

References

[152]
M. Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In: Proceedings of the 20th International Conference on Machine Learning (2003); pp. 928–936.
[178]
D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. On-line portfolio selection using multiplicative updates. Mathematical Finance 8, 325–347 (1998).
[185]
J. D. Abernethy, C. Lee and A. Tewari. Fighting bandits with a new kind of smoothness. In: Advances in Neural Information Processing Systems, Vol. 28 (2015).
[186]
J. Zimmert and Y. Seldin. Tsallis-INF: An optimal algorithm for stochastic and adversarial bandits. Journal of Machine Learning Research 22, 1–49 (2021).
[187]
L. Orseau, T. Lattimore and S. Legg. Soft-Bayes: Prod for mixtures of experts with log-loss. In: Proceedings of the 28th International Conference on Algorithmic Learning Theory, Vol. 76 of Proceedings of Machine Learning Research (2017); pp. 372–399.
[192]
D. P. Helmbold, R. E. Schapire, Y. Singer and M. K. Warmuth. A comparison of new and old algorithms for a mixture estimation problem. Machine Learning 27, 97–119 (1997).
[198]
Y. Zhang, H. Lin, L. Zheng and X. Yang. Adaptive online portfolio strategy based on exponential gradient updates. Journal of Combinatorial Optimization 43, 672–696 (2022).
[199]
Y. Li, X. Zheng, C. Chen, J. Wang and S. Xu. Exponential gradient with momentum for online portfolio selection. Expert Systems with Applications 187, 115889 (2022).