qiskit.finance.applications.ising.portfolio_diversification
portfolio diversification
Functions
get_operator (rho, n, q) | Converts an instance of portfolio optimization into a list of Paulis. |
get_portfoliodiversification_solution (rho, …) | Tries to obtain a feasible solution (in vector form) of an instance of portfolio diversification from the results dictionary. |
get_portfoliodiversification_value (rho, n, …) | Evaluates an objective function of an instance of portfolio diversification and its solution (in vector form). |
get_operator
get_operator(rho, n, q)
Converts an instance of portfolio optimization into a list of Paulis.
Parameters
- rho (numpy.ndarray) – an asset-to-asset similarity matrix, such as the covariance matrix.
- n (integer) – the number of assets.
- q (integer) – the number of clusters of assets to output.
Returns
operator for the Hamiltonian
Return type
get_portfoliodiversification_solution
get_portfoliodiversification_solution(rho, n, q, result)
Tries to obtain a feasible solution (in vector form) of an instance of portfolio diversification from the results dictionary.
Parameters
- rho (numpy.ndarray) – an asset-to-asset similarity matrix, such as the covariance matrix.
- n (integer) – the number of assets.
- q (integer) – the number of clusters of assets to output.
- result (dictionary) – a dictionary obtained by QAOA.run or VQE.run containing key ‘eigvecs’.
Returns
a vector describing the solution.
Return type
numpy.ndarray
get_portfoliodiversification_value
get_portfoliodiversification_value(rho, n, q, x_state)
Evaluates an objective function of an instance of portfolio diversification and its solution (in vector form).
Parameters
- rho (numpy.ndarray) – an asset-to-asset similarity matrix, such as the covariance matrix.
- n (integer) – the number of assets.
- q (integer) – the number of clusters of assets to output.
- x_state (numpy.ndarray) – a vector describing the solution.
Returns
cost of the solution.
Return type
float