Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the Option Pricing notebook to use classiq constructs #37

Closed
orsa-classiq opened this issue May 1, 2024 · 8 comments
Closed
Assignees
Labels
good first issue Good for newcomers quantum intermediate Requires some basic knowledge in quantum computing Unitary Hack

Comments

@orsa-classiq
Copy link
Collaborator

orsa-classiq commented May 1, 2024

Using quantum computers for pricing financial derivatives has the promise for quadratic speedup.

In this issue we will improve the current option-pricing notebook, implementing algorithm for european call options, based on the paper Option Pricing using Quantum Computers. The goal is to use native language constructs instead of the current construct_finance_model black box function in the existing implementation.

to complete this issue, follow the following steps:

  1. Open the option pricing notebook and go over the code and explanations.
  2. Remove the usage of the construct_finance_model, function_input in the model creation. You will later on use native language functions Instead.
  3. We use a log-normal distribution for the asset. You can use the current parameters, such as num_qubits, mu, sigma, threshold. A bonus is to derive them from financial parameters. Use the prepare_state function on calculated lognormal distribution with the parameters, and some truncation value (5 sigma). This can be computed classically and passed to the prepare_state as an array of probabilities.
  4. For the payoff, use the *= syntax, see amplitude loading example. Pay attention for needed remapping of the variables and normalization, as done in the paper. Here, in difference from the article, the implementation is exact and not approximated.
  5. For the amplitude estimation, you can use the iqae execution scheme, that uses the iterative amplitude estimation, and the built-in grover_operator. See quantum_counting for example.
  6. Verify the execution results of the algorithm with a classical computation. Add assert validation to the code.
  7. Wherever needed, add Markdown cells with explanations and mathematical formulations.
  8. After finishing with the notebook, make sure you keep the write_qmod(qmod, "option_pricing.qmod") line. Run the notebook, and you will automatically update the .qmod file for this example.
  9. Make sure the notebook looks well, does not have any typos / mistakes, and is running properly.
  10. Follow the contribution guidelines to open a pull request.

If you have any questions or comments, you can ask them here in the issue, or in our slack community, and the Classiq team will be happy to assist.

Happy quantum coding!

@orsa-classiq orsa-classiq added good first issue Good for newcomers quantum intermediate Requires some basic knowledge in quantum computing labels May 1, 2024
@Qubit1718
Copy link
Contributor

Hi @orsa-classiq & @amir-naveh,

I would like to work on this issue. May I please know what exactly do you mean by "native language constructs"? I am assuming that the functions needs to be changed to classiq 0.42.0 version. Please correct me if I am wrong. I look forward to hearing from you soon :)

@orsa-classiq
Copy link
Collaborator Author

Hi @Qubit1718, we will be really glad if you take it :)

By 'native language constructs' we mean using a main function, as you did in the hw_aware_sytnthesis notebook
You can see that currently the notebook contains a construct_finance_model that directly returns pre-built qmod, and we want it to be transparent.

@Qubit1718
Copy link
Contributor

You mean the construct_finance_model and function_input need to be rewritten as main functions? Could you please also let me know what would be a better starting point to understand the working of construct_finance_model and function_input :))

@orsa-classiq
Copy link
Collaborator Author

You can just ignore this function, and re-write the notebook from scratch. I refer you to the mentioned paper for understanding of the algorithm.
You need to create a single model (i.e single main function), within you use the amplitude-estimation algorithm, for the European Call options.

@Qubit1718
Copy link
Contributor

Got it, @orsa-classiq. I'll start reading the paper and post it to you if I have any further questions. Thanks!

@orsa-classiq
Copy link
Collaborator Author

@Qubit1718 are you still working on this?

@amir-naveh
Copy link
Member

@orsa-classiq , @Qubit1718 - let me know if this is still open, otherwise I will close. Thanks

@orsa-classiq
Copy link
Collaborator Author

will be released on v0.44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers quantum intermediate Requires some basic knowledge in quantum computing Unitary Hack
Projects
None yet
3 participants