class_docstr: An object designed to perform optimisations based on minimising a cost/objective function.
  It can find parameters for portfolios with
  
  - minimum volatility
  - maximum Sharpe ratio
  - minimum volatility for a given target return
  - maximum Sharpe ratio for a given target volatility
  
  It also provides functions to compute the Efficient Frontier between a range
  of Returns, plot the Efficient Frontier, plot the optimal portfolios
  (minimum Volatility and maximum Sharpe Ratio).
class_docstr_tok: ["An","object","designed","to","perform","optimisations","based","on","minimising","a","cost\/objective","function",".","It","can","find","parameters","for","portfolios","with","-","minimum","volatility","-","maximum","Sharpe","ratio","-","minimum","volatility","for","a","given","target","return","-","maximum","Sharpe","ratio","for","a","given","target","volatility","It","also","provides","functions","to","compute","the","Efficient","Frontier","between","a","range","of","Returns",",","plot","the","Efficient","Frontier",",","plot","the","optimal","portfolios","(","minimum","Volatility","and","maximum","Sharpe","Ratio",")","."]
docstr: :param mean_returns: A Series of individual expected returns for all stocks
  
  :param cov_matrix: Covariance matrix of returns
  
  :param risk_free_rate: Risk free rate, default: 0.005
  :type risk_free_rate: :py:data:`~.finquant.data_types.FLOAT`
  
  :param freq: Number of trading days in a year, default: 252
  :type freq: :py:data:`~.finquant.data_types.INT`
  
  :param method: Type of solver method to use (default: SLSQP), must be one of:
  
       - 'Nelder-Mead'
       - 'Powell'
       - 'CG'
       - 'BFGS'
       - 'Newton-CG'
       - 'L-BFGS-B'
       - 'TNC'
       - 'COBYLA'
       - 'SLSQP'
       - 'trust-constr'
       - 'dogleg'
       - 'trust-ncg'
       - 'trust-exact'
       - 'trust-krylov'
  
       all of which are officially supported by scipy.optimize.minimize
docstr_tok: [":","param","mean_returns",":","A","Series","of","individual","expected","returns","for","all","stocks",":","param","cov_matrix",":","Covariance","matrix","of","returns",":","param","risk_free_rate",":","Risk","free","rate",",","default",":","0.005",":","type","risk_free_rate",":",":","py",":","data",":","`","~.finquant.data_types.FLOAT","`",":","param","freq",":","Number","of","trading","days","in","a","year",",","default",":","252",":","type","freq",":",":","py",":","data",":","`","~.finquant.data_types.INT","`",":","param","method",":","Type","of","solver","method","to","use","(","default",":","SLSQP",")",",","must","be","one","of",":","-","'Nelder-Mead'","-","'Powell'","-","'CG'","-","'BFGS'","-","'Newton-CG'","-","'","L-BFGS-B'","-","'TNC'","-","'COBYLA'","-","'SLSQP'","-","'trust-constr'","-","'dogleg'","-","'trust-ncg'","-","'trust-exact'","-","'trust-krylov'","all","of","which","are","officially","supported","by","scipy.optimize.minimize"]
code: def __init__(
      self,
      mean_returns: pd.Series,
      cov_matrix: pd.DataFrame,
      risk_free_rate: FLOAT = 0.005,
      freq: INT = 252,
      method: str = "SLSQP",
  ):
      """
      :param mean_returns: A Series of individual expected returns for all stocks
  
      :param cov_matrix: Covariance matrix of returns
  
      :param risk_free_rate: Risk free rate, default: 0.005
      :type risk_free_rate: :py:data:`~.finquant.data_types.FLOAT`
  
      :param freq: Number of trading days in a year, default: 252
      :type freq: :py:data:`~.finquant.data_types.INT`
  
      :param method: Type of solver method to use (default: SLSQP), must be one of:
  
           - 'Nelder-Mead'
           - 'Powell'
           - 'CG'
           - 'BFGS'
           - 'Newton-CG'
           - 'L-BFGS-B'
           - 'TNC'
           - 'COBYLA'
           - 'SLSQP'
           - 'trust-constr'
           - 'dogleg'
           - 'trust-ncg'
           - 'trust-exact'
           - 'trust-krylov'
  
           all of which are officially supported by scipy.optimize.minimize
      """
      # Type validations:
      type_validation(
          returns_series=mean_returns,
          cov_matrix=cov_matrix,
          risk_free_rate=risk_free_rate,
          freq=freq,
          method=method,
      )
      supported_methods = [
          "Nelder-Mead",
          "Powell",
          "CG",
          "BFGS",
          "Newton-CG",
          "L-BFGS-B",
          "TNC",
          "COBYLA",
          "SLSQP",
          "trust-constr",
          "dogleg",
          "trust-ncg",
          "trust-exact",
          "trust-krylov",
      ]
      if method not in supported_methods:
          raise ValueError(
              "method is not supported by scipy.optimize.minimize."
          )
  
      # instance variables
      self.mean_returns = mean_returns
      self.cov_matrix = cov_matrix
      self.risk_free_rate = risk_free_rate
      self.freq = freq
      self.method = method
      self.names = list(mean_returns.index)
      self.num_stocks = len(self.names)
      self.last_optimisation = ""
  
      # set numerical parameters
      bound = (0, 1)
      self.bounds = tuple(bound for _ in range(self.num_stocks))
      self.x_0 = np.array(
          self.num_stocks * [1.0 / self.num_stocks], dtype=np.float64
      )
      self.constraints = {
          "type": "eq",
          "fun": lambda x: np.sum(x) - 1.0,
      }
  
      # placeholder for optimised values/weights
      self.weights = np.empty(0, dtype=np.float64)
      self.df_weights = pd.DataFrame()
      self.efrontier = np.empty((0, 2), dtype=np.float64)
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import matplotlib.pylab
  import numpy
  import pandas
  import scipy.optimize
  import finquant.minimise_fun
  from finquant.data_types import ARRAY_OR_DATAFRAME, ARRAY_OR_LIST, FLOAT, INT, NUMERIC
  from finquant.quants import annualised_portfolio_quantities
  from finquant.type_utilities import type_validation
label_desc: Use image node_id 1 to create a new EfficientFrontier object  with example: obj = EfficientFrontier(mean_returns, cov_matrix, risk_free_rate, freq, method)