Skip to main content

Qiskit Finance

License

Qiskit Finance is an open-source framework that contains uncertainty components for stock/securities problems, applications, such as portfolio optimization, 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.primitives import Sampler
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
sampler = Sampler()
algo = AmplitudeEstimation(num_eval_qubits=num_eval_qubits, sampler=sampler)
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.

License

This project uses the Apache License 2.0.

Metadata

Release files for qiskit-finance 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qiskit-finance 0.4.1
File Size Uploaded
qiskit-finance-0.4.1.tar.gz 40.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qiskit-finance 0.4.1
File Interpreter ABI Platform
qiskit_finance-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 91.4 kB

Release files / qiskit-finance-0.4.1.tar.gz

Download URL qiskit-finance-0.4.1.tar.gz
Size 40.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd9559775918f79f4c5f31577a73cf5f135d1911e6601ebcc1ade3901949908d
BLAKE2b-256 checksum
How to use checksums
0659d67fd31c54068606e22f28ccdfae8e9354039184b71ded4bd2e89a7c0207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / qiskit_finance-0.4.1-py3-none-any.whl

Download URL qiskit_finance-0.4.1-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1aa46d1bfc1813144d504b1da3dbb7a45c14686b430be160952179d4f4dbdf60
BLAKE2b-256 checksum
How to use checksums
694fd4a8f06b2d20b6054822f4ebf63be21ac2f39aee84266bdd2318950048d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page