Skip to content
13

Implied Volatility

PortfolioOptimisers.ImpliedVolatilityAlgorithm Type
julia
abstract type ImpliedVolatilityAlgorithm <: AbstractAlgorithm

Abstract supertype for all implied volatility algorithms in PortfolioOptimisers.jl.

All concrete and/or abstract types implementing implied volatility estimation algorithms should be subtypes of ImpliedVolatilityAlgorithm.

Related

source
PortfolioOptimisers.ImpliedVolatilityRegression Type
julia
struct ImpliedVolatilityRegression{__T_ve, __T_ws, __T_re} <: ImpliedVolatilityAlgorithm

Implied volatility algorithm that predicts realised volatility via regression on implied volatility.

ImpliedVolatilityRegression fits a regression model relating implied and realised volatility over rolling windows, then uses the fitted model to predict the next period's realised volatility from the most recent implied volatility observation.

Fields

  • ve: Variance estimator.

  • ws: Window size for computing rolling realised volatility.

  • re: Regression model target.

Constructors

julia
ImpliedVolatilityRegression(;
    ve::AbstractVarianceEstimator = SimpleVariance(),
    ws::Number = 20,
    re::AbstractRegressionTarget = LinearModel()
) -> ImpliedVolatilityRegression

Keywords correspond to the struct's fields.

Validation

  • ws > 2.

Related

source
PortfolioOptimisers.ImpliedVolatilityPremium Type
julia
struct ImpliedVolatilityPremium <: ImpliedVolatilityAlgorithm

Implied volatility algorithm that scales implied volatility by a user-supplied premium factor.

The premium factor can be a scalar or a vector (one per asset) and is used to convert raw implied volatilities into predicted realised volatilities.

Related

source
PortfolioOptimisers.ImpliedVolatility Type
julia
struct ImpliedVolatility{__T_ce, __T_mp, __T_alg, __T_af} <: AbstractCovarianceEstimator

Covariance estimator based on implied volatility scaling.

ImpliedVolatility computes a covariance matrix by combining a base correlation estimator with predicted realised volatilities derived from implied volatility data. It supports two algorithms: ImpliedVolatilityRegression, which fits a regression model to predict realised volatility from implied volatility, and ImpliedVolatilityPremium, which scales implied volatility by a user-supplied factor.

Fields

  • ce: Covariance estimator.

  • mp: Matrix processing estimator.

  • alg: Implied volatility algorithm for predicting realised volatility.

  • af: Annualisation factor for converting annualised implied volatility to the data frequency.

Constructors

julia
ImpliedVolatility(;
    ce::StatsBase.CovarianceEstimator = Covariance(),
    mp::AbstractMatrixProcessingEstimator = DenoiseDetoneAlgMatrixProcessing(),
    alg::ImpliedVolatilityAlgorithm = ImpliedVolatilityRegression(),
    af::Number = 252
) -> ImpliedVolatility

Keywords correspond to the struct's fields.

Validation

  • af > 0.

Related

source
PortfolioOptimisers.factory Method
julia
factory(ce::ImpliedVolatility, w::ObsWeights) -> ImpliedVolatility

Return a new ImpliedVolatility estimator with observation weights w applied to the underlying covariance estimator.

Arguments

  • ce: Covariance estimator.

  • w: Observation weights vector observations × 1.

Returns

  • ce: New covariance estimator of the same type as the argument, with the new weights applied.

Related

source
PortfolioOptimisers.realised_vol Function
julia
realised_vol(ce::AbstractVarianceEstimator, X::MatNum, ws::Integer,
             chunk::Option{<:Integer} = nothing, T::Option{<:Integer} = nothing,
             N::Option{<:Integer} = nothing)

Compute realised volatility over non-overlapping rolling windows.

This function reshapes the last chunk * ws rows of X into blocks of size ws and computes the standard deviation within each block using the estimator ce. The result is a matrix of size (chunk, N) representing rolling realised volatilities.

Arguments

  • ce: Variance estimator used to compute standard deviations within each window.

  • X: Data matrix of asset returns (observations × assets).

  • ws: Window size (number of observations per block).

  • chunk: Number of windows (computed as div(T, ws) if not provided).

  • T: Total number of observations (inferred from X if not provided).

  • N: Number of assets (inferred from X if not provided).

Returns

  • rv::Matrix{<:Number}: Rolling realised volatility matrix (chunks × assets).

Related

source
PortfolioOptimisers.implied_vol Function
julia
implied_vol(X::MatNum, ws::Integer, chunk::Option{<:Integer} = nothing,
            T::Option{<:Integer} = nothing, N::Option{<:Integer} = nothing)

Extract non-overlapping implied volatility observations from X at the end of each rolling window.

This function selects rows of X at positions corresponding to the end of each rolling window of size ws, starting from row T - (chunk - 1) * ws and sampling every ws rows. It returns a view of shape (chunk, N) containing end-of-window implied volatility values.

Arguments

  • X: Implied volatility matrix (observations × assets).

  • ws: Window size (number of observations per block).

  • chunk: Number of windows (computed as div(T, ws) if not provided).

  • T: Total number of observations (inferred from X if not provided).

  • N: Number of assets (inferred from X if not provided).

Returns

  • iv::SubArray: End-of-window implied volatility matrix (chunks × assets).

Related

source
PortfolioOptimisers.predict_realised_vols Method
julia
predict_realised_vols(alg::ImpliedVolatilityPremium, iv::MatNum, ::Any, ivpa::Nothing)

Error method: ImpliedVolatilityPremium requires an implied volatility premium adjustment factor.

Throws an ArgumentError because ImpliedVolatilityPremium requires ivpa to be a <:Number or <:VecNum.

Arguments

  • alg: Implied volatility premium algorithm.

  • iv: Implied volatility matrix (unused).

  • ivpa::Nothing: Implied volatility premium adjustment (must not be nothing).

Related

source
PortfolioOptimisers.predict_realised_vols Method
julia
predict_realised_vols(::ImpliedVolatilityPremium, iv::MatNum, ::Any,
                      ivpa::Num_VecNum)

Predict realised volatilities by scaling the latest implied volatility row by the premium adjustment factor.

Arguments

  • ::ImpliedVolatilityPremium: Implied volatility premium algorithm.

  • iv: Implied volatility matrix (chunks × assets); the last row is used.

  • ivpa: Implied volatility premium adjustment factor (scalar or vector).

Returns

  • rv::AbstractArray: Predicted realised volatilities (last row of iv divided by ivpa).

Related

source
PortfolioOptimisers.predict_realised_vols Method
julia
predict_realised_vols(alg::ImpliedVolatilityRegression, iv::MatNum, X::MatNum, ::Any)

Predict realised volatilities using a regression model fitted on implied and realised volatility.

For each asset, this function fits a regression model relating lagged implied volatility and lagged realised volatility (computed from rolling windows of X) to the next-period realised volatility. The fitted model is then used to predict the next-period realised volatility from the most recent data.

Arguments

  • alg: Implied volatility regression algorithm specifying the window size and regression target.

  • iv: Implied volatility matrix (observations × assets).

  • X: Asset returns matrix (observations × assets) used to compute realised volatility.

  • ::Any: Ignored (placeholder for ivpa).

Returns

  • rv_p::Vector{<:Number}: Predicted next-period realised volatilities (one per asset).

Validation

  • chunk > 2 (i.e., there must be more than 2 windows of data to fit the regression).

Related

source
Statistics.cov Method
julia
Statistics.cov(ce::ImpliedVolatility, X::MatNum; dims::Int = 1, mean = nothing,
               iv::MatNum, ivpa::Option{<:Num_VecNum} = nothing, kwargs...)

Compute the covariance matrix using implied volatility scaling.

This method computes the correlation matrix of X using the base estimator in ce, then predicts realised volatilities from iv using the implied volatility algorithm in ce.alg. The predicted realised volatilities are used to convert the correlation matrix to a covariance matrix, which is then post-processed by the matrix processing estimator ce.mp.

Arguments

  • ce: Implied volatility covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • mean: Optional pre-computed mean (passed to the base estimator).

  • iv: Implied volatility matrix (observations × assets).

  • ivpa: Optional implied volatility premium adjustment factor (required for ImpliedVolatilityPremium).

  • kwargs...: Additional keyword arguments passed to the base estimator.

Returns

  • sigma::MatNum: Covariance matrix features x features.

Related

source
Statistics.cor Method
julia
Statistics.cor(ce::ImpliedVolatility, X::MatNum; dims::Int = 1, mean = nothing,
               iv::MatNum, ivpa::Option{<:Num_VecNum} = nothing, kwargs...)

Compute the correlation matrix using implied volatility scaling.

This method computes the correlation matrix of X using the base estimator in ce, then predicts realised volatilities from iv using the implied volatility algorithm in ce.alg. The predicted realised volatilities are used to convert the correlation matrix to a covariance and back to a correlation matrix, which is then post-processed by the matrix processing estimator ce.mp.

Arguments

  • ce: Implied volatility covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • mean: Optional pre-computed mean (passed to the base estimator).

  • iv: Implied volatility matrix (observations × assets).

  • ivpa: Optional implied volatility premium adjustment factor (required for ImpliedVolatilityPremium).

  • kwargs...: Additional keyword arguments passed to the base estimator.

Returns

  • rho::MatNum: Correlation matrix features x features.

Related

source