paddle_quantum.finance.pricing
Tools for QMC, option pricing and credit analysis.
- paddle_quantum.finance.pricing.qae_cir(oracle, num_ancilla)
Create a QAE circuit based on the
oracle
given.- Parameters:
oracle (Tensor) – input oracle.
num_ancilla (int) – number of ancilla qubits used.
- Returns:
a circuit used for quantum amplitude estimation.
- Return type:
- paddle_quantum.finance.pricing.qae_alg(oracle, num_ancilla)
Quantum amplitude estimation (QAE) algorithm
- Parameters:
oracle (Tensor) – an \(n\)-qubit oracle \(\mathcal{A}\).
num_ancilla (int) – number of ancilla qubits used.
- Returns:
a QAE circuit and \(|\sin(2\pi\theta)|\)
- Return type:
Tuple[Circuit, Tensor]
Note
\(\mathcal{A}\) satisfies
\[\mathcal{A}|0^{\otimes n}\rangle=\cos(2\pi\theta)|0\rangle|\psi\rangle+\sin(2\pi\theta)|1\rangle|\phi\rangle.\]
- paddle_quantum.finance.pricing.qmc_alg(fcn, list_prob, num_ancilla=6)
Quantum Monte Carlo (QMC) algorithm.
- Parameters:
fcn (Callable[[float], float]) – real-valued function \(f\) applied to a random variable \(X\).
list_prob (List[float]) – probability distribution of \(X\), where the j-th probability corresponds to the j-th outcome.
num_ancilla (int) – number of ancilla qubits used. Defaults to be
6
.
- Returns:
a QAE circuit and an estimation of \(\mathbb{E}[f(X)]\).
- Return type:
Tuple[Circuit, Tensor]
- class paddle_quantum.finance.pricing.EuroOptionEstimator(initial_price, strike_price, interest_rate, volatility, maturity_date, degree_of_estimation=5)
Bases:
object
European option pricing estimator.
- Parameters:
initial_price (float) – initial price of the asset.
strike_price (float) – pre-fixed price of the asset.
interest_rate (float) – risk-free interest rate.
volatility (float) – dispersion of returns for the asset.
maturity_date (float) – date when option is expired.
degree_of_estimation (int | None) – degree of price estimation. Defaults to be
5
.
Note
Option price is evaluated under the [Black-Scholes-Merton model](https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model).
- estimate()
Estimate the European option price using Quantum Monte Carlo (QMC) methods.
- Returns:
Risk-neutral price of the given asset.
- Return type:
float
- plot(dpi=200)
Plot the quantum circuit used in pricing.
- Parameters:
dpi (int) – image clarity of the plotted circuit. Defaults to be
200
.
- class paddle_quantum.finance.pricing.CreditRiskAnalyzer(num_assets, base_default_prob, sensitivity, lgd, confidence_level, degree_of_simulation=4, even_sample=True)
Bases:
object
Simulator for credit risk analysis (CRA) speeded up by quantum algorithms
- Parameters:
num_assets (int) – number of assets.
base_default_prob (ndarray) – basic default probabilities of assets.
sensitivity (ndarray) – sensitivities of assets.
lgd (ndarray) – losses given default (LGD) of assets.
confidence_level (float) – level of confidence of computed result.
degree_of_simulation (int | None) – degree of simulation of CRA, determining the number of samples of the latent variable. Defaults to be
4
.even_sample (bool | None) – whether sample the latent variable by evenly-spaced probability. Defaults to be
True
.
Note
CRA is simulated under the model given by [Tarca & Silvio](https://arxiv.org/abs/1412.1183). That is, the latent random variable for the market is assumed to follow a standard normal distribution.
- estimate_var()
Estimate VaR using the QAE algorithm.
- Returns:
the estimated Value at Risk of these credit assets
- Return type:
float