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: optimize risk parity portfolio
  
  This method solves the following optimization problem
      min_w sum_i [w_i - (w' S w) / ((S w)_i * N)]**2
      s.t. w >= 0, sum(w) == 1
  where `S` is the covariance matrix and `N` is the number of stocks.
docstr_tok: ["optimize","risk","parity","portfolio","This","method","solves","the","following","optimization","problem","min_w","sum_i","[","w_i","-","(","w","'","S","w",")","\/","(","(","S","w",")","_i","*","N",")","]","*","*","2","s.t",".","w",">","=","0",",","sum","(","w",")","==","1","where","`","S","`","is","the","covariance","matrix","and","`","N","`","is","the","number","of","stocks","."]
code: def _optimize_rp(
      self, S: np.ndarray, w0: Optional[np.ndarray] = None
  ) -> np.ndarray:
      """optimize risk parity portfolio
  
      This method solves the following optimization problem
          min_w sum_i [w_i - (w' S w) / ((S w)_i * N)]**2
          s.t. w >= 0, sum(w) == 1
      where `S` is the covariance matrix and `N` is the number of stocks.
      """
      return self._solve(
          len(S), self._get_objective_rp(S), *self._get_constrains(w0)
      )
  
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 7 for calling the PortfolioOptimizer obj's underlying member method code with example usage: obj._optimize_rp(S, w0) and returns: self