class_docstr: Portfolio Optimizer
  
  The following optimization algorithms are supported:
      - `gmv`: Global Minimum Variance Portfolio
      - `mvo`: Mean Variance Optimized Portfolio
      - `rp`: Risk Parity
      - `inv`: Inverse Volatility
  
  Note:
      This optimizer always assumes full investment and no-shorting.
class_docstr_tok: ["Portfolio","Optimizer","The","following","optimization","algorithms","are","supported",":","-","`","gmv","`",":","Global","Minimum","Variance","Portfolio","-","`","mvo","`",":","Mean","Variance","Optimized","Portfolio","-","`","rp","`",":","Risk","Parity","-","`","inv","`",":","Inverse","Volatility","Note",":","This","optimizer","always","assumes","full","investment","and","no-shorting","."]
docstr: Args:
      method (str): portfolio optimization method
      lamb (float): risk aversion parameter (larger `lamb` means more focus on return)
      delta (float): turnover rate limit
      alpha (float): l2 norm regularizer
      scale_return (bool): if to scale alpha to match the volatility of the covariance matrix
      tol (float): tolerance for optimization termination
docstr_tok: ["Args",":","method","(","str",")",":","portfolio","optimization","method","lamb","(","float",")",":","risk","aversion","parameter","(","larger","`","lamb","`","means","more","focus","on","return",")","delta","(","float",")",":","turnover","rate","limit","alpha","(","float",")",":","l2","norm","regularizer","scale_return","(","bool",")",":","if","to","scale","alpha","to","match","the","volatility","of","the","covariance","matrix","tol","(","float",")",":","tolerance","for","optimization","termination"]
code: def __init__(
      self,
      method: str = "inv",
      lamb: float = 0,
      delta: float = 0,
      alpha: float = 0.0,
      scale_return: bool = True,
      tol: float = 1e-8,
  ):
      """
      Args:
          method (str): portfolio optimization method
          lamb (float): risk aversion parameter (larger `lamb` means more focus on return)
          delta (float): turnover rate limit
          alpha (float): l2 norm regularizer
          scale_return (bool): if to scale alpha to match the volatility of the covariance matrix
          tol (float): tolerance for optimization termination
      """
      assert method in [
          self.OPT_GMV,
          self.OPT_MVO,
          self.OPT_RP,
          self.OPT_INV,
      ], f"method `{method}` is not supported"
      self.method = method
  
      assert (
          lamb >= 0
      ), f"risk aversion parameter `lamb` should be positive"
      self.lamb = lamb
  
      assert delta >= 0, f"turnover limit `delta` should be positive"
      self.delta = delta
  
      assert (
          alpha >= 0
      ), f"l2 norm regularizer `alpha` should be positive"
      self.alpha = alpha
  
      self.tol = tol
      self.scale_return = scale_return
  
file_path: qlib/qlib/contrib/strategy/optimizer/optimizer.py
imports: import warnings
  import numpy
  import pandas
  import scipy.optimize
  from typing import Optional, Union, Callable, List
  from .base import BaseOptimizer
label_desc: Use image node_id 1 to create a new PortfolioOptimizer object from inherited base classes: BaseOptimizer with example: obj = PortfolioOptimizer(method, lamb, delta, alpha, scale_return, tol)