finol.optimization_layer.CriterionSelector¶
- class finol.optimization_layer.CriterionSelector[source]¶
Class to select and compute loss criterion for portfolio selection.
Methods
compute_custom_criterion_loss(portfolios, labels)Compute the
CustomCriterionloss, which is left for the user to define.compute_l2_concentration_loss(portfolios, labels)Compute the
L2Concentrationloss, which measures the concentration of a portfolio based on the L2 norm of consecutive portfolio weight differences.compute_l2_diversification_loss(portfolios, ...)Compute the
L2Diversificationloss, which measures the diversification of a portfolio based on the L2 norm of consecutive portfolio weight differences.Compute the
LogWealthL2Concentrationloss, which extends theLogWealthloss by incorporating concentration measures.Compute the
LogWealthL2Diversificationloss, which extends theLogWealthloss by incorporating diversification measures.compute_log_wealth_loss(portfolios, labels)Compute the
LogWealthloss, which calculates the negative mean logarithm of the portfolio's daily returns.compute_sharpe_ratio_loss(portfolios, labels)Compute the
SharpeRatioloss, which evaluates the risk-adjusted return of the portfolios using the Sharpe Ratio.compute_volatility_loss(portfolios, labels)Compute the
Volatilityloss, which measures the volatility of the portfolios based on the standard deviation of daily returns.- compute_custom_criterion_loss(portfolios, labels)[source]¶
Compute the
CustomCriterionloss, which is left for the user to define.This loss function is a placeholder for the user to implement their own custom loss criterion.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
CustomCriterionloss tensor, representing the user-defined loss criterion.- Return type:
Tensor
- compute_l2_concentration_loss(portfolios, labels)[source]¶
Compute the
L2Concentrationloss, which measures the concentration of a portfolio based on the L2 norm of consecutive portfolio weight differences.This loss function calculates the negative mean L2 norm of the differences between consecutive portfolio weight vectors.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
L2Concentrationloss tensor, indicating the degree of concentration based on the negative mean L2 norm of portfolio weight differences.- Return type:
Tensor
- compute_l2_diversification_loss(portfolios, labels)[source]¶
Compute the
L2Diversificationloss, which measures the diversification of a portfolio based on the L2 norm of consecutive portfolio weight differences.This loss function calculates the mean L2 norm of the differences between consecutive portfolio weight vectors.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
L2Diversificationloss tensor, indicating the degree of diversification based on the L2 norm of portfolio weight differences.- Return type:
Tensor
- compute_log_wealth_l2_concentration_loss(portfolios, labels)[source]¶
Compute the
LogWealthL2Concentrationloss, which extends theLogWealthloss by incorporating concentration measures.- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
LogWealthL2Concentrationloss tensor, a modified version ofLogWealthloss with concentration metrics included.- Return type:
Tensor
- compute_log_wealth_l2_diversification_loss(portfolios, labels)[source]¶
Compute the
LogWealthL2Diversificationloss, which extends theLogWealthloss by incorporating diversification measures.This loss function calculates the negative mean logarithm of the portfolio’s daily returns while considering diversification metrics.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
LogWealthL2Diversificationloss tensor, a modified version ofLogWealthloss with diversification metrics included.- Return type:
Tensor
- compute_log_wealth_loss(portfolios, labels)[source]¶
Compute the
LogWealthloss, which calculates the negative mean logarithm of the portfolio’s daily returns.- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
LogWealthloss tensor, representing the negative mean logarithm of the portfolio’s daily returns.- Return type:
Tensor
- compute_sharpe_ratio_loss(portfolios, labels)[source]¶
Compute the
SharpeRatioloss, which evaluates the risk-adjusted return of the portfolios using the Sharpe Ratio.This loss function calculates the negative Sharpe Ratio, which is the ratio of the mean excess return to the standard deviation of the excess return.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
SharpeRatioloss tensor, indicating the negative Sharpe Ratio value for the portfolios.- Return type:
Tensor
- compute_volatility_loss(portfolios, labels)[source]¶
Compute the
Volatilityloss, which measures the volatility of the portfolios based on the standard deviation of daily returns.This loss function calculates the standard deviation of the daily portfolio returns.
- Parameters:
portfolios (Tensor) – Portfolio weights tensor of shape (batch_size, num_assets).
labels (Tensor) – Label tensor representing asset returns of shape (batch_size, num_assets).
- Returns:
Volatilityloss tensor, representing the volatility of the portfolios based on the standard deviation of daily returns.- Return type:
Tensor