options-pricer 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. options_pricer-0.1.0/LICENSE +21 -0
  2. options_pricer-0.1.0/PKG-INFO +432 -0
  3. options_pricer-0.1.0/README.md +412 -0
  4. options_pricer-0.1.0/pyproject.toml +59 -0
  5. options_pricer-0.1.0/setup.cfg +4 -0
  6. options_pricer-0.1.0/src/options_pricer/__init__.py +26 -0
  7. options_pricer-0.1.0/src/options_pricer/__main__.py +227 -0
  8. options_pricer-0.1.0/src/options_pricer/american.py +104 -0
  9. options_pricer-0.1.0/src/options_pricer/black_scholes.py +132 -0
  10. options_pricer-0.1.0/src/options_pricer/implied_vol.py +62 -0
  11. options_pricer-0.1.0/src/options_pricer/monte_carlo.py +86 -0
  12. options_pricer-0.1.0/src/options_pricer/path_dependent.py +196 -0
  13. options_pricer-0.1.0/src/options_pricer/py.typed +0 -0
  14. options_pricer-0.1.0/src/options_pricer/real_data.py +104 -0
  15. options_pricer-0.1.0/src/options_pricer/surface.py +375 -0
  16. options_pricer-0.1.0/src/options_pricer.egg-info/PKG-INFO +432 -0
  17. options_pricer-0.1.0/src/options_pricer.egg-info/SOURCES.txt +29 -0
  18. options_pricer-0.1.0/src/options_pricer.egg-info/dependency_links.txt +1 -0
  19. options_pricer-0.1.0/src/options_pricer.egg-info/entry_points.txt +2 -0
  20. options_pricer-0.1.0/src/options_pricer.egg-info/requires.txt +10 -0
  21. options_pricer-0.1.0/src/options_pricer.egg-info/top_level.txt +1 -0
  22. options_pricer-0.1.0/tests/test_american.py +63 -0
  23. options_pricer-0.1.0/tests/test_barrier_greeks.py +127 -0
  24. options_pricer-0.1.0/tests/test_black_scholes.py +97 -0
  25. options_pricer-0.1.0/tests/test_cli.py +204 -0
  26. options_pricer-0.1.0/tests/test_implied_vol.py +50 -0
  27. options_pricer-0.1.0/tests/test_monte_carlo.py +62 -0
  28. options_pricer-0.1.0/tests/test_path_dependent.py +158 -0
  29. options_pricer-0.1.0/tests/test_properties.py +56 -0
  30. options_pricer-0.1.0/tests/test_real_data.py +69 -0
  31. options_pricer-0.1.0/tests/test_surface.py +173 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Iker Abad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,432 @@
1
+ Metadata-Version: 2.4
2
+ Name: options-pricer
3
+ Version: 0.1.0
4
+ Summary: European option pricing: Black-Scholes, Monte Carlo and SVI volatility calibration
5
+ Author: Iker Abad
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy>=2.0
11
+ Requires-Dist: scipy>=1.14
12
+ Requires-Dist: matplotlib>=3.9
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8; extra == "dev"
15
+ Requires-Dist: pytest-cov>=5; extra == "dev"
16
+ Requires-Dist: ruff>=0.6; extra == "dev"
17
+ Requires-Dist: mypy>=1.10; extra == "dev"
18
+ Requires-Dist: hypothesis>=6.100; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # options-pricer
22
+
23
+ [![ci](https://github.com/IkerAbad/options-pricer/actions/workflows/ci.yml/badge.svg)](https://github.com/IkerAbad/options-pricer/actions/workflows/ci.yml)
24
+ [![license](https://img.shields.io/badge/license-MIT-333?style=flat-square)](LICENSE)
25
+
26
+ API reference: **https://ikerabad.github.io/options-pricer/**
27
+
28
+ European, American and path-dependent option pricing in Python: closed-form
29
+ Black-Scholes, Monte Carlo with antithetic variates, implied volatility by root
30
+ finding, SVI calibration across a term structure, a binomial tree for early
31
+ exercise and path simulation for Asians and barriers. Every number in this
32
+ README comes from a command you can run.
33
+
34
+ ![Monte Carlo convergence](docs/monte_carlo_convergence.png)
35
+
36
+ ![Volatility smile](docs/volatility_smile.png)
37
+
38
+ ![Volatility surface](docs/volatility_surface.png)
39
+
40
+ ![Early exercise](docs/early_exercise.png)
41
+
42
+ ![Real volatility smile](docs/real_smile.png)
43
+
44
+ ![Barrier curve](docs/barrier_curve.png)
45
+
46
+ ![ETH volatility smile](docs/real_smile_eth.png)
47
+
48
+ ![BTC implied volatility slices](docs/real_surface.png)
49
+
50
+ ## Results
51
+
52
+ Reference case: spot 100, strike 100, rate 5%, volatility 20%, expiry 1 year.
53
+
54
+ | Quantity | Value |
55
+ | --- | --- |
56
+ | Black-Scholes call | 10.450584 |
57
+ | Delta | 0.636831 |
58
+ | Gamma | 0.018762 |
59
+ | Vega | 37.524035 |
60
+ | Theta | -6.414028 |
61
+ | Rho | 53.232482 |
62
+ | Vanna | -0.281430 |
63
+ | Volga | 9.850059 |
64
+ | Charm | -0.065667 |
65
+ | Monte Carlo, 1,000,000 paths | 10.456536 |
66
+ | Standard error | 0.014737 |
67
+ | 95% interval | [10.427652, 10.485419] |
68
+
69
+ The analytic price falls inside the Monte Carlo interval. The standard error
70
+ falls with the square root of the number of paths, which is what the first plot
71
+ shows.
72
+
73
+ SVI calibration on a synthetic smile with 0.1 % relative price noise:
74
+
75
+ | Parameter | True | Fitted |
76
+ | --- | --- | --- |
77
+ | a | 0.02 | 0.022490 |
78
+ | b | 0.15 | 0.144749 |
79
+ | rho | -0.4 | -0.423434 |
80
+ | m | -0.05 | -0.051059 |
81
+ | sigma | 0.15 | 0.138244 |
82
+
83
+ RMSE in implied volatility: 0.021 vol points.
84
+
85
+ Four expiries, calibrated from short to long and chained through the previous
86
+ slice. The quotes come from a synthetic term structure with 0.1 % price noise.
87
+
88
+ | Expiry | a | b | rho | m | sigma | RMSE |
89
+ | --- | --- | --- | --- | --- | --- | --- |
90
+ | 0.25 | 0.0072 | 0.0867 | -0.326 | -0.020 | 0.136 | 0.001431 |
91
+ | 0.50 | 0.0145 | 0.0985 | -0.347 | -0.042 | 0.151 | 0.000682 |
92
+ | 1.00 | 0.0251 | 0.1205 | -0.368 | -0.071 | 0.184 | 0.000832 |
93
+ | 2.00 | 0.0651 | 0.0954 | -0.346 | -0.075 | 0.153 | 0.000278 |
94
+
95
+ `a` grows with maturity, which is the shape you expect when short-dated
96
+ volatility is higher than long-dated volatility.
97
+
98
+ ## American options
99
+
100
+ Prices from a Cox-Ross-Rubinstein tree with 1,000 steps, same reference case:
101
+
102
+ | Option | American | European | Premium |
103
+ | --- | --- | --- | --- |
104
+ | Put | 6.089595 | 5.571527 | 0.518069 |
105
+ | Call, no dividend | 10.448584 | 10.448584 | 0.000000 |
106
+ | Call, 8% dividend yield | 6.541188 | 6.141112 | 0.400076 |
107
+
108
+ The put carries a real premium because waiting has a cost: the strike is
109
+ discounted and the downside is protected today. The call without dividends has
110
+ no premium, which is the standard no-arbitrage result. Adding a dividend yield
111
+ changes that, and the tree finds the value of the early exercise right.
112
+
113
+ ## Real market data
114
+
115
+ `data/binance_btc_options_2026-11-22.csv` is a snapshot of the Binance BTC
116
+ options chain, captured on 2026-11-22 at 20:22 UTC with the index at 60,637.68
117
+ USDT. It holds 446 quotes across three expiries, calls and puts, filtered to
118
+ positive bid and ask, mid above 1 USDT, a relative spread below 50 % and
119
+ moneyness between 0.5 and 2.
120
+
121
+ The forward for each expiry comes from put-call parity on the pair closest to
122
+ the index, with a zero rate. SVI is fitted directly to the market implied
123
+ volatilities, which avoids the quote conversion that an inverse contract would
124
+ need.
125
+
126
+ | Expiry | Days | Forward | Quotes | RMSE |
127
+ | --- | --- | --- | --- | --- |
128
+ | 2026-12-25 | 32.5 | 60,875.00 | 75 | 1.57 vol points |
129
+ | 2027-01-29 | 67.5 | 61,127.50 | 85 | 0.42 vol points |
130
+ | 2027-03-26 | 123.5 | 61,627.50 | 78 | 0.58 vol points |
131
+
132
+ The short expiry is the hard one. A five-parameter SVI cannot follow the full
133
+ curvature of a 33-day crypto smile, and the fit leaves 1.57 vol points of RMSE.
134
+ That is visible in the last figure and it is reported, not hidden.
135
+
136
+ The snapshot is downloaded by `scripts/fetch_binance.py` and versioned so the
137
+ repository works without network access. `scripts/real_smile.py` rebuilds the
138
+ figure from the CSV.
139
+
140
+ The same pipeline runs on ETH, with 200 quotes and RMSE between 0.45 and 1.37
141
+ vol points. The two extra figures show the ETH smile and the three BTC slices in
142
+ three dimensions.
143
+
144
+ Calibration time on one real slice, ten repetitions:
145
+
146
+ | Constraint | Median | Minimum | Maximum |
147
+ | --- | --- | --- | --- |
148
+ | Soft penalty | 14.80 ms | 14.72 ms | 14.92 ms |
149
+ | Hard SLSQP | 16.44 ms | 16.33 ms | 16.80 ms |
150
+
151
+ ## Path-dependent options
152
+
153
+ Asian and barrier options are priced by Monte Carlo over full price paths. The
154
+ table uses 200,000 paths and 100 steps.
155
+
156
+ | Option | Price | Standard error |
157
+ | --- | --- | --- |
158
+ | Asian call, arithmetic average | 5.797045 | 0.017937 |
159
+ | Up-and-out call, barrier 120 | 1.424428 | 0.007951 |
160
+ | Up-and-out call, barrier 150 | 7.854730 | 0.024648 |
161
+ | Up-and-out call, barrier 200 | 10.363996 | 0.032452 |
162
+ | European call | 10.450584 | analytic |
163
+
164
+ The Asian is much cheaper than the European because averaging removes variance.
165
+ The barrier converges to the European price as the level moves away, which is
166
+ what the last figure shows.
167
+
168
+ Barriers are monitored at the simulation steps, not continuously. That
169
+ overprices knock-outs slightly, because a path can cross and come back between
170
+ two steps. The code does not pretend otherwise.
171
+
172
+ Delta, vega and theta for the barrier at 200 come from bump and reprice with
173
+ common random numbers: 0.623412, 33.576223 and -5.987842. Gamma is not reported
174
+ because the second difference is the same order as the Monte Carlo noise at
175
+ these path counts.
176
+
177
+ ## No arbitrage
178
+
179
+ Two conditions are checked on every calibrated slice.
180
+
181
+ **Butterfly.** Gatheral's function
182
+
183
+ ```
184
+ g(k) = (1 - k w' / (2 w))^2 - (w'^2 / 4) (1 / w + 1 / 4) + w'' / 2
185
+ ```
186
+
187
+ must be non-negative at every log moneyness. A negative value means the implied
188
+ density is negative somewhere, which no arbitrage-free distribution can produce.
189
+
190
+ **Calendar.** Total variance must not decrease with maturity at a fixed log
191
+ moneyness: `w(k, T2) >= w(k, T1)` for `T2 > T1`.
192
+
193
+ On the real snapshot the three slices are butterfly-free: zero per cent of the
194
+ grid points violate `g >= 0`. Calendar is tighter. Fitting each expiry
195
+ independently leaves a gap of -0.0156 between the first two expiries, so the
196
+ short slice carries more total variance than the long one somewhere in the
197
+ wings. The long slice is then refitted with the calendar constraint imposed by
198
+ SLSQP instead of a penalty. The gap becomes +9.99e-15, zero to machine
199
+ precision, and the price is a worse fit: the RMSE of the middle expiry goes from
200
+ 0.0021 to 0.0042, and the last one from 0.0035 to 0.0058.
201
+
202
+ The hard constraint is opt-in through `hard_calendar=True`. SLSQP can fail to
203
+ converge on a difficult slice, so the default remains the soft penalty.
204
+
205
+ That is a soft constraint, not a theorem. A hard guarantee needs an optimizer
206
+ with explicit non-linear constraints, and it is not implemented.
207
+
208
+ ## What it does
209
+
210
+ - Black-Scholes prices and first and second order Greeks for European calls and
211
+ puts.
212
+ - Monte Carlo under the exact lognormal terminal distribution, not an Euler
213
+ discretisation, with antithetic variates, standard error and a 95 % interval.
214
+ - Implied volatility by Brent root finding, with an explicit rejection of prices
215
+ outside the no-arbitrage range.
216
+ - SVI total-variance calibration by bounded least squares with a soft L1 loss.
217
+ - One slice per expiry, chained in time and regularised towards the previous
218
+ slice, plus a 3D surface by interpolation in log time.
219
+ - American and European prices on the same binomial tree, with the early
220
+ exercise premium measured directly.
221
+ - Asian and barrier options by Monte Carlo over simulated paths.
222
+ - Barrier delta, vega and theta by bump and reprice with common random numbers.
223
+ - SVI calibration on a versioned real snapshot of the Binance BTC options
224
+ chain, not only on synthetic data.
225
+ - Butterfly and calendar diagnostics, plus a soft calendar penalty between
226
+ consecutive expiries.
227
+ - Six figures that regenerate from a script.
228
+
229
+ ## Install
230
+
231
+ ```
232
+ python -m venv .venv
233
+ .venv\Scripts\activate
234
+ pip install -e ".[dev]"
235
+ pytest
236
+ ```
237
+
238
+ ## Use
239
+
240
+ ```
241
+ python -m options_pricer price --spot 100 --strike 100 --rate 0.05 --vol 0.2 --expiry 1
242
+ python -m options_pricer mc --spot 100 --strike 100 --rate 0.05 --vol 0.2 --expiry 1 --paths 1000000
243
+ python -m options_pricer iv --spot 100 --strike 100 --rate 0.05 --expiry 1 --price 10.45
244
+ python -m options_pricer american --spot 100 --strike 100 --rate 0.05 --vol 0.2 --expiry 1 --type put
245
+ python -m options_pricer asian --spot 100 --strike 100 --rate 0.05 --vol 0.2 --expiry 1 --type call
246
+ python -m options_pricer barrier --spot 100 --strike 100 --rate 0.05 --vol 0.2 --expiry 1 --barrier 120 --kind up-and-out
247
+ python -m options_pricer surface
248
+ python -m options_pricer surface --all
249
+ python scripts/make_figures.py
250
+ ```
251
+
252
+ As a library:
253
+
254
+ ```python
255
+ from options_pricer import binomial, call_price, greeks, implied_volatility, price_european
256
+ from options_pricer.surface import (
257
+ SviParams,
258
+ calibrate,
259
+ calibrate_surface,
260
+ example_term_structure,
261
+ synthetic_surface,
262
+ )
263
+
264
+ value = call_price(100, 100, 0.05, 0.20, 1.0)
265
+ vol = implied_volatility(value, 100, 100, 0.05, 1.0, "call")
266
+ result = price_european("call", 100, 100, 0.05, 0.20, 1.0, paths=1_000_000)
267
+ american = binomial("put", 100, 100, 0.05, 0.20, 1.0, steps=1_000)
268
+
269
+ structure = example_term_structure()
270
+ expiries = list(structure)
271
+ quotes = synthetic_surface(
272
+ 100, 0.03, expiries, [90, 95, 100, 105, 110], [structure[t] for t in expiries]
273
+ )
274
+ rows = calibrate_surface(100, 0.03, expiries, [90, 95, 100, 105, 110], quotes)
275
+ ```
276
+
277
+ ## Conventions
278
+
279
+ - Prices and strikes are in currency units.
280
+ - Rates, volatilities and expiries are annualised. Expiry is in years.
281
+ - Rates are continuously compounded.
282
+ - Vega is the derivative with respect to volatility in units (0.20, not 20).
283
+ - Theta is the derivative with respect to time, per year.
284
+ - No dividends in the closed form. The binomial tree takes a continuous
285
+ dividend yield.
286
+ - The SVI form is the raw parametrisation,
287
+ `w(k) = a + b * (rho * (k - m) + sqrt((k - m)^2 + sigma^2))`, with
288
+ `k = ln(K / F)` and `w = vol^2 * T`.
289
+
290
+ ## Validation
291
+
292
+ 81 tests cover:
293
+
294
+ - Reference prices 10.4506 and 5.5735 with tolerance 1e-3.
295
+ - Put-call parity to 1e-10.
296
+ - Greeks at the reference point and their signs.
297
+ - Vanna, volga and charm matching central finite differences of delta and vega,
298
+ and agreeing between calls and puts.
299
+ - Monte Carlo interval containing the analytic price.
300
+ - Exact put-call parity per path using the sample mean terminal price.
301
+ - Error shrinking as the square root of the number of paths.
302
+ - Implied volatility recovering the input to 1e-6.
303
+ - Rejection of prices below intrinsic value and above the attainable range.
304
+ - SVI calibration recovering a noiseless surface to 1e-4 RMSE and surviving
305
+ quoted noise.
306
+ - One stable fit per expiry across a term structure, with a downward slope in
307
+ at-the-money volatility.
308
+ - American calls without dividends matching European calls.
309
+ - A positive early exercise premium for American puts and for calls with a
310
+ dividend yield.
311
+ - Binomial European prices converging to Black-Scholes.
312
+ - Deep in-the-money American puts close to intrinsic value.
313
+ - Loading the versioned real snapshot, calibrating its three slices below three
314
+ vol points and recovering the forward from put-call parity.
315
+ - Butterfly positivity on a regular slice, detection of a pathological one, and
316
+ calendar gaps with the expected sign in both directions.
317
+ - Asian and barrier prices: a one-step Asian matching the European price, an
318
+ Asian below the European, a far barrier matching the European, knock-in plus
319
+ knock-out adding up to the European, and reproducibility from a seed.
320
+ - Property tests with Hypothesis: put-call parity, monotonicity in spot and
321
+ strike, and Greek bounds over random valid inputs.
322
+
323
+ CI runs the suite and rebuilds the figures on Ubuntu and Windows, Python 3.12
324
+ and 3.13.
325
+
326
+ ## Development
327
+
328
+ ```
329
+ pip install -e ".[dev]"
330
+ ruff check .
331
+ ruff format --check .
332
+ mypy src/options_pricer
333
+ pytest --cov=options_pricer --cov-report=term-missing
334
+ ```
335
+
336
+ Line coverage is 98 %. CI runs lint, format, types, tests and coverage on Ubuntu
337
+ and Windows with Python 3.12 and 3.13.
338
+
339
+ ## Limitations
340
+
341
+ - The American price comes from a binomial tree, not from the free boundary. The
342
+ tree costs O(steps^2) and carries a discretisation error of a few cents at
343
+ 1,000 steps. The premium is the difference between two trees, so that error
344
+ partially cancels.
345
+ - Exotic payoffs beyond Asians and barriers: no lookbacks, no cliquets, no
346
+ Bermudan schedules.
347
+ - Barrier monitoring is discrete at the simulation steps. Continuous monitoring
348
+ needs a Brownian bridge correction or a much finer time grid.
349
+ - No Greeks for path-dependent options.
350
+ - Black-Scholes assumes constant volatility and lognormal returns. The smile in
351
+ the second figure exists because that assumption is false.
352
+ - The surface is an interpolation of the five SVI parameters in log time between
353
+ calibrated expiries. It is not a continuous arbitrage-free model and it does
354
+ not enforce calendar or butterfly constraints.
355
+ - SVI with five parameters is not uniquely identified by a handful of quotes.
356
+ The chain and the ridge term stabilise it, and the fitted parameters are not
357
+ meant to be read as ground truth.
358
+ - The hard calendar constraint uses SLSQP, which can fail to converge on a
359
+ difficult slice. The fitted parameters are a local optimum, not a global one.
360
+ - The real data is a single snapshot of Binance BTC options. There is no time
361
+ series, no second underlying and no execution costs.
362
+
363
+ ## Español
364
+
365
+ Valoración de opciones europeas y americanas en Python: Black-Scholes cerrado,
366
+ Monte Carlo con variates antitéticas, volatilidad implícita por búsqueda de raíz,
367
+ calibración SVI encadenada a lo largo de la estructura temporal y árbol binomial
368
+ para el ejercicio anticipado.
369
+
370
+ Caso de referencia, con spot y strike 100, tipo 5 %, volatilidad 20 % y un año:
371
+ la call europea vale 10,450584. Con un millón de trayectorias, Monte Carlo da
372
+ 10,456536 con un error estándar de 0,014737 y un intervalo al 95 % de 10,427652
373
+ a 10,485419.
374
+
375
+ En el árbol binomial con 1.000 pasos, la put americana vale 6,089595 frente a
376
+ 5,571527 de la europea, con una prima de 0,518069. La call sin dividendos no
377
+ tiene prima, que es el resultado estándar de no arbitraje. Con un rendimiento por
378
+ dividendo del 8 %, la prima de la call sube a 0,400076.
379
+
380
+ La calibración SVI se hace por vencimientos encadenados, de corto a largo, con
381
+ una regularización suave hacia la slice anterior. Con cuatro vencimientos entre
382
+ 0,25 y 2 años y un 0,1 % de ruido en precio, el RMSE queda por debajo de 0,0015
383
+ en todas las slices. La superficie de la tercera figura es una interpolación de
384
+ los cinco parámetros en tiempo logarítmico, no un modelo continuo libre de
385
+ arbitraje.
386
+
387
+ El repositorio incluye además un snapshot real de opciones de BTC de Binance,
388
+ capturado el 22/11/2026 con el índice en 60.637,68 USDT. Son 446 cotizaciones en
389
+ tres vencimientos. El forward de cada vencimiento sale de la paridad put-call con
390
+ tipo cero, y el SVI se ajusta directamente a las volatilidades implícitas del
391
+ mercado. El RMSE va de 0,21 puntos de volatilidad en el vencimiento a 67 días a
392
+ 1,57 puntos en el de 33 días. El vencimiento corto es el difícil: un SVI de cinco
393
+ parámetros no sigue toda la curvatura de una sonrisa de cripto a un mes.
394
+
395
+ El ajuste se comprueba contra dos condiciones de no arbitraje. La de mariposa,
396
+ con la función de Gatheral, no se viola en ningún punto de las tres slices. La de
397
+ calendario sí: calibrando cada vencimiento por separado, la varianza total cae al
398
+ alargar el plazo en 0,0156. Al reajustar la slice larga con la restricción
399
+ impuesta por SLSQP, la violación desaparece, el gap queda en 9,99e-15, a cambio
400
+ de empeorar el RMSE del vencimiento intermedio de 0,0021 a 0,0042 y el del último
401
+ de 0,0035 a 0,0058. La restricción dura es opcional porque SLSQP puede no
402
+ converger en una slice difícil.
403
+
404
+ También hay opciones dependientes de la trayectoria. La asiática aritmética de
405
+ referencia vale 5,797045 con un error estándar de 0,017937, muy por debajo de la
406
+ europea porque promediar reduce la varianza. La up-and-out con barrera en 120
407
+ vale 1,424428, con barrera en 150 vale 7,854730 y con barrera en 200 se acerca a
408
+ la europea, 10,363996. La barrera se vigila en los pasos de simulación, no de
409
+ forma continua, y eso sobrevalora ligeramente las knock-out. Está escrito.
410
+
411
+ Las griegas de la barrera en 200 salen de recalcular el precio con perturbaciones
412
+ y números aleatorios comunes: delta 0,623412, vega 33,576223 y theta -5,987842.
413
+ No se publica gamma porque la segunda diferencia queda al nivel del ruido de
414
+ Monte Carlo con este número de caminos.
415
+
416
+ Los 81 tests cubren los precios de referencia, la paridad put-call, las griegas
417
+ de primer y segundo orden, la convergencia del error como 1/√N, la recuperación
418
+ de la volatilidad implícita, la calibración de una sonrisa, la estabilidad de la
419
+ estructura temporal, las propiedades del ejercicio anticipado, la calibración del
420
+ snapshot real, los diagnósticos de mariposa y calendario, y las relaciones entre
421
+ asiáticas, barreras y europeas. Vanna, volga y charm se comprueban contra
422
+ diferencias finitas centrales de delta y vega. La cobertura de línea es del 98 %,
423
+ y el CI ejecuta ruff, mypy, los tests y la cobertura en Ubuntu y Windows.
424
+
425
+ El mismo proceso se aplica a ETH, con 200 cotizaciones y un RMSE de entre 0,45 y
426
+ 1,37 puntos de volatilidad. El benchmark de calibración de una slice real da
427
+ 14,80 ms de mediana con la penalización suave y 16,44 ms con la restricción dura
428
+ de SLSQP.
429
+
430
+ ## License
431
+
432
+ MIT. See [LICENSE](LICENSE).