Creating a Quantum Computing Portfolio Segment Using Variational Quantum Eigensolver
Published: 2023-09-13 12:06:56

In the field of quantum computing, Qudoor started the research and development of distributed ion trap quantum computer in 2020, and the research and development of ion trap chip, precision laser system, qubit photoelectric measurement and control system, high-speed electronic timing and control system, quantum programming language, quantum cloud, quantum computing library, quantum application and other systems is also continuing. In 2021, it launched China's first ion trap quantum computer engineering machine AbaQ-1, laying a solid foundation for the 100-bit distributed ion trap quantum computer with a quantum volume of more than 100 million planned to be completed in 2023. In terms of quantum computing applications, it has established cooperative relations with domestic leading enterprises in the fields of insurance, securities, new drug research and development, encryption and decryption. To realize the deep binding of industry applications and build a market ecology.


## Disclaimer: 

The information provided in this article is for informational purposes only and should not be considered as financial advice. The author is not a licensed financial advisor. Readers should consult with a qualified professional before making any investment decisions. Investing involves risk, and past performance is not indicative of future results. The author assume no responsibility for any financial losses resulting from the use of this information.

The rapid advancement of quantum computing presents enticing possibilities and potential applications across a range of industries. As investors explore opportunities in this emerging sector, the development of a well-optimized investment portfolio segment becomes indispensable. This article delves into the process of constructing a quantum computing investment portfolio segment using variational quantum eigensolver algorithm. While the majority of the article maintains a non-technical approach, I have dedicated the final section to a closer examination of the underlying code used to create this portfolio segment.

## Metric Research:

In finance, sigma (σ) and mu (μ) are often used to represent standard deviations and means in statistics, as described in the previous answer. However, in quantum computing and quantum wiring, sigma and mu no longer represent the same concepts, but are related to quantum states and quantum gate operations. The following explains what they mean in quantum computing and why the expected value of a quantum circuit can be calculated from these two pieces of data.

1. Sigma (σ) : In quantum computing, σ is often used to represent a form of the Pauli matrix, for example, σ_x, σ_y, and σ_z. These matrices are fundamental operators in quantum computing that describe the rotation and measurement of quantum bits (qubits). The σ matrix is related to operations and measurements in the quantum circuit, not the dispersion of the data

2. Mu (μ) : In quantum computing, μ is not usually used to represent a specific concept. It is not directly related to the expected value in quantum computing, but is used to represent the complex amplitudes of quantum states. A quantum state is a state that describes a qubit, which is a linear combination that includes the amplitudes of different ground states.

The expected value calculation of quantum circuits is usually related to the Pauli matrix and the inner product (also known as the expected value) of quantum states. The expected value can be expressed as follows:
E(O)= <Ψ∣O∣Ψ>
Where E(O) represents the expected value of the operator O, |Ψ⟩ represents the quantum state, and O represents a Pauli matrix or other quantum operator. This expected value represents the average measurement obtained by applying the operator O for a given quantum state

## The Algorithm:

The VQE (Variational Quantum Eigensolver) algorithm is an approximate solution method based on quantum computing, commonly used to solve problems in quantum chemistry and materials science. Although it is not specifically designed for the financial sector, it can use the power of quantum computing to solve portfolio optimization problems in the financial sector.

First, the portfolio optimization problem is transformed into a problem in quantum computing. In finance, the goal of portfolio questions is usually to maximize returns or minimize risks, while taking into account the weighting of various assets.

The Hamiltonian is a quantum mechanical concept that describes the total energy of a system and can be used to represent portfolio problems. By constructing a Hamiltonian, the goal of the portfolio problem is transformed into a problem of finding the smallest eigenvalue (ground state energy), where the eigenvalue corresponds to the target value of the optimal portfolio.

In order to simulate the Hamiltonian, an appropriate quantum circuit structure is selected. This circuit usually consists of a series of quantum gate operations that can adjust the parameters in the circuit to optimize the portfolio problem.

Use a quantum computer or simulator to run the VQE algorithm. The VQE algorithm uses a classical computer to continuously adjust the circuit parameters to approximate the minimum eigenvalue of the Hamiltonian as closely as possible. This process may require several iterations until satisfactory accuracy is reached or an optimal solution is found.

Once the VQE algorithm finds the minimum eigenvalue, it can decode the corresponding quantum states and parameters. These parameters can be translated into asset weights in the financial portfolio, so as to obtain the optimal portfolio allocation.

Finally, the performance of the obtained portfolio allocation is evaluated, including return, risk and other indicators. If needed, the configuration can be further optimized to meet specific investment objectives and constraints.

## Amazon Braket:

Amazon Braket is a fully managed quantum computing service designed to help accelerate scientific research and software development in quantum computing. Users can develop quantum programs using Amazon Braket SDK through local Jupyter Notebook/IDE or Amazon console, and call Amazon Cloud Technology to provide quantum hardware or simulation resources to run quantum computing programs.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hweu5h6kcpxqy6d1nz0l.png)



Below is how configure to use Ionq on AWS:
1.	Click “Security credentials”, create access keys and keep the status “Active”


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg57v6z39f7uki5tok41.png)



2.	Before using Boto3, you need to set up authentication credentials for your AWS account using either the [IAM Console](https://console.aws.amazon.com/iam/home) or the AWS CLI. You can either choose an existing user or create a new one.
For instructions about how to create a user using the IAM Console, [see Creating IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console). Once the user has been created, see [Managing access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey) to learn how to create and retrieve the keys used to authenticate the user.
If you have the [AWS CLI](http://aws.amazon.com/cli/) installed, then you can use the aws configure command to configure your credentials file:
aws configure
Alternatively, you can create the credentials file yourself. By default, its location is ~/.aws/credentials. At a minimum, the credentials file should specify the access key and secret access key. In this example, the key and secret key for the account are specified in the default profile:
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
You may also want to add a default region to the AWS configuration file, which is located by default at ~/.aws/config:
[default]
region=us-east-1
Alternatively, you can pass a region_name when creating clients and resources.
You have now configured credentials for the default profile as well as a default region to use when creating connections. See Configuration for in-depth configuration sources and options.
3.	After run a circuit on aws device, below page will display all Quantum Tasks, click anyone


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwe0whs8i104rzuawtu9.png)


4.	Click “See results in XX”, you will see the results of the corresponding tasks


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/teokyo3bcieqbwu8lyel.png)




5.	Results.json is the result json file of the task, you can click to download

## The Code:

This section is designed for the technical reader which might have an interest in the code behind the creation of our portfolio segment. The first step of the analysis was to collect the relevant stock data. The sample raw data can be seen as follow:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uv3hq0weymtgca547f7y.png)


I then aggerated the data using the following code:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/teyja31mt7onpjswzui1.png)

The resulting aggregated data used for the optimization can be seen:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tf5mjyfoq2ax6ye5y8k.png)


Below is the code for the variational quantum eigensolver:


## The result:

Based on the optimization process, the final portfolio allocation is as follows:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm5zx9y5ozdlvfvz14lb.png)

## About US：

Qudoor Quantum Technology (Beijing) Co., LTD. (hereinafter referred to as Quanta) was officially initiated by overseas returnees in January 2019, headquartered in Beijing Zhongguancun Software Park, focusing on quantum communication equipment manufacturing and quantum computer full-stack development, relying on the technical team's 20 years of superior technology accumulation and rich product experience in the field of quantum information technology. Become the first domestic scientific and technological innovative enterprise with both quantum computing and quantum communication core technology reserves and product research and development capabilities, and will design and build a new generation of quantum Internet in the future.



作者：
Keith Yan（丘秉宜）中国首位亚马逊云科技 Community Hero

Liu li（刘利）启科量子 C++工程师

Cheng Shuang（程骦）启科量子 Python工程师

Huang zonggui（黄宗贵）启科量子 前端开发工程师