> For the complete documentation index, see [llms.txt](https://docs.algenta.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.algenta.ai/machine-learning/ml-chain-greeks.md).

# Batched chain greeks

SIMD-batched Black-Scholes price and greeks across a whole option chain in one call, matching the scalar pricing functions to 1e-9.

`option_greeks_batch` prices an entire option chain — hundreds to thousands of strikes and expiries — in a single call, vectorizing the Black-Scholes math across hardware SIMD lanes. It replaces per-contract scalar pricing loops where call overhead and scalar transcendentals dominate.

## The modules

| Module                | What it does                                                                                                                             |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `option_greeks_batch` | SIMD-batched Black-Scholes price, delta, gamma, vega and theta for an entire option chain in one call                                    |
| `option_pricing`      | the scalar Black-Scholes, binomial-tree, greeks and implied-volatility functions that `option_greeks_batch` is verified to match to 1e-9 |

## Functions

| Function                                                       | What it does                                                                                                                                                           |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chain_greeks(spots, strikes, times, rates, sigmas, is_calls)` | Batched BS price, delta, gamma, vega and theta for mixed call/put chains (`is_calls` 1.0/0.0). Returns `ChainGreeksResult` with five parallel `List[Float64]` outputs. |

## Semantics and guarantees

* Results match the scalar `option_pricing` functions to 1e-9 on the valid domain (verified across a 144-cell hostile grid of moneyness, expiry and volatility, calls and puts).
* Put greeks derive from parity — `delta_put = delta_call - 1`, `theta_put = theta_call + r·K·e^(-rT)`; gamma and vega are shared. Theta is per year, the same convention as `theta_call`.
* Degenerate lanes (`T <= 0` or `sigma <= 0`) return discounted intrinsic value with zero greeks instead of NaN.
* The SIMD main loop and scalar tail produce identical results at every batch size (verified for n = 1..11 against single-element calls).

## Throughput

Measured on a 2-lane NEON float64 machine (wider AVX lanes scale further), with dead-code elimination defeated by checksum accumulation:

```
1,000-contract chain: batch 28.2 us | scalar loop 88.1 us | 3.1x
= 28 ns per contract for price + all four greeks
```

**Next:** feed the greeks into [statistical model comparison](/machine-learning/ml-model-comparison.md) experiments, or browse the [engine catalog](/engine-runtime/catalog.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.algenta.ai/machine-learning/ml-chain-greeks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
