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 CustomCriterion loss, which is left for the user to define.

compute_l2_concentration_loss(portfolios, labels)

Compute the L2Concentration loss, which measures the concentration of a portfolio based on the L2 norm of consecutive portfolio weight differences.

compute_l2_diversification_loss(portfolios, ...)

Compute the L2Diversification loss, which measures the diversification of a portfolio based on the L2 norm of consecutive portfolio weight differences.

compute_log_wealth_l2_concentration_loss(...)

Compute the LogWealthL2Concentration loss, which extends the LogWealth loss by incorporating concentration measures.

compute_log_wealth_l2_diversification_loss(...)

Compute the LogWealthL2Diversification loss, which extends the LogWealth loss by incorporating diversification measures.

compute_log_wealth_loss(portfolios, labels)

Compute the LogWealth loss, which calculates the negative mean logarithm of the portfolio's daily returns.

compute_sharpe_ratio_loss(portfolios, labels)

Compute the SharpeRatio loss, which evaluates the risk-adjusted return of the portfolios using the Sharpe Ratio.

compute_volatility_loss(portfolios, labels)

Compute the Volatility loss, which measures the volatility of the portfolios based on the standard deviation of daily returns.

compute_custom_criterion_loss(portfolios, labels)[source]

Compute the CustomCriterion loss, 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:

CustomCriterion loss tensor, representing the user-defined loss criterion.

Return type:

Tensor

compute_l2_concentration_loss(portfolios, labels)[source]

Compute the L2Concentration loss, 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:

L2Concentration loss 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 L2Diversification loss, 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:

L2Diversification loss 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 LogWealthL2Concentration loss, which extends the LogWealth loss 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:

LogWealthL2Concentration loss tensor, a modified version of LogWealth loss with concentration metrics included.

Return type:

Tensor

compute_log_wealth_l2_diversification_loss(portfolios, labels)[source]

Compute the LogWealthL2Diversification loss, which extends the LogWealth loss 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:

LogWealthL2Diversification loss tensor, a modified version of LogWealth loss with diversification metrics included.

Return type:

Tensor

compute_log_wealth_loss(portfolios, labels)[source]

Compute the LogWealth loss, 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:

LogWealth loss tensor, representing the negative mean logarithm of the portfolio’s daily returns.

Return type:

Tensor

compute_sharpe_ratio_loss(portfolios, labels)[source]

Compute the SharpeRatio loss, 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:

SharpeRatio loss tensor, indicating the negative Sharpe Ratio value for the portfolios.

Return type:

Tensor

compute_volatility_loss(portfolios, labels)[source]

Compute the Volatility loss, 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:

Volatility loss tensor, representing the volatility of the portfolios based on the standard deviation of daily returns.

Return type:

Tensor