Metadata-Version: 2.4
Name: optipricepro-cpp
Version: 1.0.0
Summary: OptiPricePro C++ - Monte Carlo option pricing on a native C++ engine
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.31

# OptiPricePro C++

Monte Carlo option pricing on a native C++ engine, reached over HTTPS.

This package is a thin client. Nothing is computed on your machine and no
pricing library is installed — you need no compiler, no Eigen and no Boost.
It can sit alongside the Pandas and JAX packages in the same environment
without their keys or endpoints interfering.

## Installation

    conda create -n optipricepro-cpp python=3.11 -y
    conda activate optipricepro-cpp

    python -m pip install optipricepro_cpp-1.0.0-py3-none-any.whl

## Your licence key

    set OPTIPRICEPRO_CPP_API_KEY=sk_live_YOUR_KEY          Windows, this window
    setx OPTIPRICEPRO_CPP_API_KEY "sk_live_YOUR_KEY"       Windows, permanently
    export OPTIPRICEPRO_CPP_API_KEY=sk_live_YOUR_KEY       macOS / Linux

Or set it in code:

```python
import optipricepro_cpp as opp
opp.configure(api_key="sk_live_YOUR_KEY")
```

Verify before anything else:

    optipricepro-cpp-check

## Pricing

```python
import optipricepro_cpp as opp

r = opp.price(
    product="PathIndependentOption",
    payoff="Call",
    S0=100, K=99, r=0.05, sigma=0.2, y=0.02, T=1,
    N_Paths=100000, M=20,
)

print(r["value"], "+/-", r["error"])
```

`product` and `payoff` are required; everything else takes the engine default.

### American and Bermudan

```python
opp.price(product="PathIndependentOption", payoff="Put",
          exercise="American", regression_degree=6,
          S0=100, K=99, T=1, N_Paths=50000, M=25)

opp.price(product="PathIndependentOption", payoff="Put",
          exercise="Bermudan", num_exercise_points=4, regression_degree=6,
          S0=100, K=99, T=1, N_Paths=50000, M=25)
```

### Barriers and lookbacks

Wrappers compose in five orders. Name the order and the pieces:

```python
opp.price(product="PathIndependentOption", payoff="Call",
          wrapper_order="barrier on underlying",
          barrier_type="DownAndOutBarrier", DownBarrier=80,
          S0=100, K=99, T=1, N_Paths=50000, M=25)

opp.price(product="PathArithmeticAsianOption", payoff="Put",
          wrapper_order="lookback on barrier on underlying",
          barrier_type="DownAndOutBarrier", DownBarrier=80,
          lookback_type="LookbackFixedStrike",
          S0=100, K=99, T=1, N_Paths=50000, M=25)
```

The five orders are `underlying only`, `barrier on underlying`,
`lookback on underlying`, `lookback on barrier on underlying` and
`barrier on lookback on underlying`.

Naming a barrier without a barrier order — or an order without its pieces — is
rejected rather than silently ignored.

### Greeks

```python
r = opp.price(product="PathIndependentOption", payoff="Call",
              S0=100, K=99, r=0.05, sigma=0.2, y=0.02, T=1,
              N_Paths=40000, M=12, greeks=True, hessian=True)

print(r["greeks"])     # delta, vega, rho, theta, delta_decay, delta_sentiment
print(r["gradient"])   # d/dS0, d/dSentiment0, d/dr, d/dsigma, d/dy, d/dT
print(r["hessian"])    # 6x6, only when hessian=True
```

Greeks use central differences, so a request with `greeks=True` costs roughly
**thirteen** simulations rather than one. Size accordingly.

### Control variates

```python
r = opp.price(product="PathArithmeticAsianOption", payoff="Call",
              S0=100, K=99, r=0.05, sigma=0.2, y=0.02, T=1,
              N_Paths=100000, M=250,
              control_variate=True,
              cv_product="PathGeometricAsianOption",
              cv_analytical_formula="Geometric_Asian_Option_price_call")

print(r["value"], r["control_variate"])   # beta, rho, error_without_cv
```

Typically a 30–40x variance reduction on that pair.

**One caveat, and the engine warns you about it.** The closed-form geometric
Asian assumes a *continuously* monitored average while the simulation averages
over `M` discrete steps. The control variate carries that gap into the answer
as a bias which more paths will not reduce — only a larger `M` will. Check
`r["warnings"]`, and either raise `M` or pass `cv_analytical` with a
discrete-average value.

## What the result contains

| Key | Meaning |
| --- | --- |
| `value`, `error` | the price and its Monte Carlo standard error |
| `legs` | comparison legs from the same paths — unwrapped, barrier-only, European |
| `greeks`, `gradient`, `hessian_diag`, `hessian` | when `greeks=True` |
| `control_variate` | beta, rho, error with and without the control |
| `warnings` | anything the engine wants you to know about the result |
| `resolved` | every setting as the engine actually resolved it |
| `elapsed_seconds` | engine time, excluding the network |

Read `resolved` when a number surprises you: it shows exactly which models were
used, so a defaulted field is visible rather than assumed.

## Asking what is accepted

Rather than guessing at spellings:

```python
opp.catalog()["barrier_type"]     # all 17
opp.catalog()["vol_model"]        # constantVolatility, HestonVolatility, Bates
opp.catalog()["product"]
```

or from the shell:

    optipricepro-cpp-catalog

A misspelled selector is rejected with the full list of accepted values — the
service never quietly substitutes a default, because a plausible price computed
from the wrong model is worse than an error.

## Limits

| | |
| --- | --- |
| `N_Paths` x `M` | 5,000,000 |
| `N_Paths` | 2,000,000 |
| `M` | 5,000 |
| Request timeout | 1800 seconds |

Memory grows with the *product* of paths and steps, which is why the binding
limit is on `N_Paths x M`. Exceeding it returns a message naming the largest
`N_Paths` available at your chosen `M`.

## Reproducibility

The engine seeds from the operating system's entropy source, so two identical
requests return two prices differing within Monte Carlo error. This is a
deliberate property of the C++ implementation, which is independent of the
Pandas and JAX engines. No seed is exposed.

## Configuration reference

| Variable | Purpose |
| --- | --- |
| `OPTIPRICEPRO_CPP_API_KEY` | Your licence key |
| `OPTIPRICEPRO_CPP_API_URL` | Override the endpoint (rarely needed) |
| `OPTIPRICEPRO_CPP_PRICE_PATH` | Override the pricing path |

## Command line

    optipricepro-cpp-check              verify connection and licence
    optipricepro-cpp-catalog            list every accepted selector
    optipricepro-cpp request.json       price from a JSON file
    echo {...} | optipricepro-cpp       price from stdin

## Licence and support

Your key is issued for this product and metered independently of any other
OptiPricePro licence you hold. Keep it confidential.

Contact British Asteroid Belt Trading Company with your company name, Python
version and the complete error message if you need assistance.
