Skip to main content

Qiskit Finance: A library of quantum computing finance experiments

Project description

Qiskit Finance

License

Qiskit Finance is an open-source framework that contains uncertainty components for stock/securities problems, Ising translators for portfolio optimizations and data providers to source real or random data to finance experiments.

Installation

We encourage installing Qiskit Finance via the pip tool (a python package manager).

pip install qiskit-finance

pip will handle all dependencies automatically and you will always install the latest (and well-tested) version.

If you want to work on the very latest work-in-progress versions, either to try features ahead of their official release or if you want to contribute to Finance, then you can install from source. To do this follow the instructions in the documentation.


Creating Your First Finance Programming Experiment in Qiskit

Now that Qiskit Finance is installed, it's time to begin working with the finance module. Let's try an experiment using Amplitude Estimation algorithm to evaluate a fixed income asset with uncertain interest rates.

import numpy as np
from qiskit import BasicAer
from qiskit.algorithms import AmplitudeEstimation
from qiskit_finance.circuit.library import NormalDistribution
from qiskit_finance.applications import FixedIncomePricing

# Create a suitable multivariate distribution
num_qubits = [2, 2]
bounds = [(0, 0.12), (0, 0.24)]
mvnd = NormalDistribution(
    num_qubits, mu=[0.12, 0.24], sigma=0.01 * np.eye(2), bounds=bounds
)

# Create fixed income component
fixed_income = FixedIncomePricing(
    num_qubits,
    np.eye(2),
    np.zeros(2),
    cash_flow=[1.0, 2.0],
    rescaling_factor=0.125,
    bounds=bounds,
    uncertainty_model=mvnd,
)

# the FixedIncomeExpectedValue provides us with the necessary rescalings

# create the A operator for amplitude estimation
problem = fixed_income.to_estimation_problem()

# Set number of evaluation qubits (samples)
num_eval_qubits = 5

# Construct and run amplitude estimation
q_i = BasicAer.get_backend("statevector_simulator")
algo = AmplitudeEstimation(num_eval_qubits=num_eval_qubits, quantum_instance=q_i)
result = algo.estimate(problem)

print(f"Estimated value:\t{fixed_income.interpret(result):.4f}")
print(f"Probability:    \t{result.max_probability:.4f}")

When running the above the estimated value result should be 2.46 and probability 0.8487.

Further examples

Learning path notebooks may be found in the finance tutorials section of the documentation and are a great place to start.


Contribution Guidelines

If you'd like to contribute to Qiskit, please take a look at our contribution guidelines. This project adheres to Qiskit's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please join the Qiskit Slack community and for discussion and simple questions. For questions that are more suited for a forum, we use the Qiskit tag in Stack Overflow.

Authors and Citation

Finance was inspired, authored and brought about by the collective work of a team of researchers. Finance continues to grow with the help and work of many people, who contribute to the project at different levels. If you use Qiskit, please cite as per the provided BibTeX file.

Please note that if you do not like the way your name is cited in the BibTex file then consult the information found in the .mailmap file.

License

This project uses the Apache License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qiskit-finance-0.3.1.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

qiskit_finance-0.3.1-py3-none-any.whl (51.0 kB view details)

Uploaded Python 3

File details

Details for the file qiskit-finance-0.3.1.tar.gz.

File metadata

  • Download URL: qiskit-finance-0.3.1.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for qiskit-finance-0.3.1.tar.gz
Algorithm Hash digest
SHA256 aa8355ba87fbc8e8115be2f08396f9701bffbebeeb32c1decca67b5aaec6729e
MD5 44bf9b1248f87a9f9311a051d3d61a3b
BLAKE2b-256 47fb92b7276b27715f7080ec63d1302cbf209df8dca56c34a55b8306bc8ad3d9

See more details on using hashes here.

File details

Details for the file qiskit_finance-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: qiskit_finance-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 51.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for qiskit_finance-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c0ca1f18d02039188409f407bdef255af60cdaf0b7ef8c36ae7e2e4abd5bf7c
MD5 12d11b698a1089a60f80f59d7bcb53cb
BLAKE2b-256 a40334081edbf3e2a8b665725042fccc1cc0b08296fc815e21838b693616dbc1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page