class_docstr: Shrinkage Covariance Estimator
  
  This estimator will shrink the sample covariance matrix towards
  an identify matrix:
      S_hat = (1 - alpha) * S + alpha * F
  where `alpha` is the shrink parameter and `F` is the shrinking target.
  
  The following shrinking parameters (`alpha`) are supported:
      - `lw` [1][2][3]: use Ledoit-Wolf shrinking parameter.
      - `oas` [4]: use Oracle Approximating Shrinkage shrinking parameter.
      - float: directly specify the shrink parameter, should be between [0, 1].
  
  The following shrinking targets (`F`) are supported:
      - `const_var` [1][4][5]: assume stocks have the same constant variance and zero correlation.
      - `const_corr` [2][6]: assume stocks have different variance but equal correlation.
      - `single_factor` [3][7]: assume single factor model as the shrinking target.
      - np.ndarray: provide the shrinking targets directly.
  
  Note:
      - The optimal shrinking parameter depends on the selection of the shrinking target.
          Currently, `oas` is not supported for `const_corr` and `single_factor`.
      - Remember to set `nan_option` to `fill` or `mask` if your data has missing values.
  
  References:
      [1] Ledoit, O., & Wolf, M. (2004). A well-conditioned estimator for large-dimensional covariance matrices.
          Journal of Multivariate Analysis, 88(2), 365–411. https://doi.org/10.1016/S0047-259X(03)00096-4
      [2] Ledoit, O., & Wolf, M. (2004). Honey, I shrunk the sample covariance matrix.
          Journal of Portfolio Management, 30(4), 1–22. https://doi.org/10.3905/jpm.2004.110
      [3] Ledoit, O., & Wolf, M. (2003). Improved estimation of the covariance matrix of stock returns
          with an application to portfolio selection.
          Journal of Empirical Finance, 10(5), 603–621. https://doi.org/10.1016/S0927-5398(03)00007-0
      [4] Chen, Y., Wiesel, A., Eldar, Y. C., & Hero, A. O. (2010). Shrinkage algorithms for MMSE covariance
          estimation. IEEE Transactions on Signal Processing, 58(10), 5016–5029.
          https://doi.org/10.1109/TSP.2010.2053029
      [5] https://www.econ.uzh.ch/dam/jcr:ffffffff-935a-b0d6-0000-00007f64e5b9/cov1para.m.zip
      [6] https://www.econ.uzh.ch/dam/jcr:ffffffff-935a-b0d6-ffff-ffffde5e2d4e/covCor.m.zip
      [7] https://www.econ.uzh.ch/dam/jcr:ffffffff-935a-b0d6-0000-0000648dfc98/covMarket.m.zip
class_docstr_tok: ["Shrinkage","Covariance","Estimator","This","estimator","will","shrink","the","sample","covariance","matrix","towards","an","identify","matrix",":","S_hat","=","(","1","-","alpha",")","*","S","+","alpha","*","F","where","`","alpha","`","is","the","shrink","parameter","and","`","F","`","is","the","shrinking","target",".","The","following","shrinking","parameters","(","`","alpha","`",")","are","supported",":","-","`","lw","`","[","1","]","[","2","]","[","3","]",":","use","Ledoit-Wolf","shrinking","parameter",".","-","`","oas","`","[","4","]",":","use","Oracle","Approximating","Shrinkage","shrinking","parameter",".","-","float",":","directly","specify","the","shrink","parameter",",","should","be","between","[","0",",","1","]",".","The","following","shrinking","targets","(","`","F","`",")","are","supported",":","-","`","const_var","`","[","1","]","[","4","]","[","5","]",":","assume","stocks","have","the","same","constant","variance","and","zero","correlation",".","-","`","const_corr","`","[","2","]","[","6","]",":","assume","stocks","have","different","variance","but","equal","correlation",".","-","`","single_factor","`","[","3","]","[","7","]",":","assume","single","factor","model","as","the","shrinking","target",".","-","np.ndarray",":","provide","the","shrinking","targets","directly",".","Note",":","-","The","optimal","shrinking","parameter","depends","on","the","selection","of","the","shrinking","target",".","Currently",",","`","oas","`","is","not","supported","for","`","const_corr","`","and","`","single_factor","`",".","-","Remember","to","set","`","nan_option","`","to","`","fill","`","or","`","mask","`","if","your","data","has","missing","values",".","References",":","[","1","]","Ledoit",",","O.",",","&","Wolf",",","M.","(","2004",")",".","A","well-conditioned","estimator","for","large-dimensional","covariance","matrices",".","Journal","of","Multivariate","Analysis",",","88","(","2",")",",","365\u2013411",".","https",":","\/\/doi.org\/10.1016\/S0047-259X","(","03",")","00096-4","[","2","]","Ledoit",",","O.",",","&","Wolf",",","M.","(","2004",")",".","Honey",",","I","shrunk","the","sample","covariance","matrix",".","Journal","of","Portfolio","Management",",","30","(","4",")",",","1\u201322",".","https",":","\/\/doi.org\/10.3905\/jpm.2004.110","[","3","]","Ledoit",",","O.",",","&","Wolf",",","M.","(","2003",")",".","Improved","estimation","of","the","covariance","matrix","of","stock","returns","with","an","application","to","portfolio","selection",".","Journal","of","Empirical","Finance",",","10","(","5",")",",","603\u2013621",".","https",":","\/\/doi.org\/10.1016\/S0927-5398","(","03",")","00007-0","[","4","]","Chen",",","Y.",",","Wiesel",",","A.",",","Eldar",",","Y.","C.",",","&","Hero",",","A.","O",".","(","2010",")",".","Shrinkage","algorithms","for","MMSE","covariance","estimation",".","IEEE","Transactions","on","Signal","Processing",",","58","(","10",")",",","5016\u20135029",".","https",":","\/\/doi.org\/10.1109\/TSP.2010.2053029","[","5","]","https",":","\/\/www.econ.uzh.ch\/dam\/jcr",":","ffffffff-935a-b0d6-0000-00007f64e5b9\/cov1para.m.zip","[","6","]","https",":","\/\/www.econ.uzh.ch\/dam\/jcr",":","ffffffff-935a-b0d6-ffff-ffffde5e2d4e\/covCor.m.zip","[","7","]","https",":","\/\/www.econ.uzh.ch\/dam\/jcr",":","ffffffff-935a-b0d6-0000-0000648dfc98\/covMarket.m.zip"]
docstr: get shrinking parameter `alpha`
  
  Note:
      The Ledoit-Wolf shrinking parameter estimator consists of three different methods.
docstr_tok: ["get","shrinking","parameter","`","alpha","`","Note",":","The","Ledoit-Wolf","shrinking","parameter","estimator","consists","of","three","different","methods","."]
code: def _get_shrink_param(
      self, X: np.ndarray, S: np.ndarray, F: np.ndarray
  ) -> float:
      """get shrinking parameter `alpha`
  
      Note:
          The Ledoit-Wolf shrinking parameter estimator consists of three different methods.
      """
      if self.alpha == self.SHR_OAS:
          return self._get_shrink_param_oas(X, S, F)
      elif self.alpha == self.SHR_LW:
          if self.target == self.TGT_CONST_VAR:
              return self._get_shrink_param_lw_const_var(X, S, F)
          if self.target == self.TGT_CONST_CORR:
              return self._get_shrink_param_lw_const_corr(X, S, F)
          if self.target == self.TGT_SINGLE_FACTOR:
              return self._get_shrink_param_lw_single_factor(X, S, F)
      return self.alpha
  
file_path: qlib/qlib/model/riskmodel/shrink.py
imports: import numpy
  from typing import Union
  from qlib.model.riskmodel import RiskModel
label_desc: Use image node_id 7 for calling the ShrinkCovEstimator obj's underlying member method code with example usage: obj._get_shrink_param(X, S, F) and returns: self, self, self, self, self