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: risk-parity optimization objective
  
  Optimization objective
      min_w sum_i [w_i - (w' S w) / ((S w)_i * N)]**2
docstr_tok: ["risk-parity","optimization","objective","Optimization","objective","min_w","sum_i","[","w_i","-","(","w","'","S","w",")","\/","(","(","S","w",")","_i","*","N",")","]","*","*","2"]
code: def _get_objective_rp(self, S: np.ndarray) -> Callable:
      """risk-parity optimization objective
  
      Optimization objective
          min_w sum_i [w_i - (w' S w) / ((S w)_i * N)]**2
      """
  
      def func(x):
          N = len(x)
          Sx = S @ x
          xSx = x @ Sx
          return np.sum((x - xSx / Sx / N) ** 2)
  
      return func
  
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 10 for calling the PortfolioOptimizer obj's underlying member method code with example usage: obj._get_objective_rp(S) and returns: func, np