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(rho, n, q)[source]

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

WeightedPauliOperator

get_portfoliodiversification_solution(rho, n, q, result)[source]

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(rho, n, q, x_state)[source]

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