Matlab Price Instrument
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Science and research
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to pricing financial instruments and calculating sensitivities (Greeks) within MATLAB. It guides users through the Financial Instruments Toolbox, routing requests to the appropriate numerical method—Monte Carlo simulation, FFT/Numerical Integration, or Interest-Rate Trees—based on the specific instrument and model requirements. It emphasizes modern object-oriented practices, such as using finpricer, fininstrument, and finmodel, while discouraging legacy functions to ensure efficient and accurate financial modeling.
What it does
- Routes pricing requests to Monte Carlo, FFT/Numerical Integration, or IR Tree methods.
- Supports a wide range of models including Black-Scholes, Heston, Hull-White, and SABR-BGM.
- Facilitates the calculation of Greeks such as delta, vega, gamma, theta, and rho.
- Provides standardized workflows for constructing instruments, models, and pricers.
- Enforces best practices like using datetime objects and modern object-oriented APIs.
- Enables pricing of complex instruments like exotic options and callable bonds.
When to use it
- When pricing options, bonds, swaps, or derivatives in MATLAB.
- When you need to compute Greeks or sensitivities for financial instruments.
- When choosing between simulation, tree-based, or transform-based pricing methods.
- When working with stochastic volatility or jump-diffusion models.
- When you need to compare pricing results across different numerical methods.
Advantages
- Ensures consistent and modern coding standards using the latest toolbox APIs.
- Reduces errors by routing to the most appropriate numerical method for the instrument.
- Simplifies the implementation of complex financial models and sensitivity analysis.
- Provides clear guidance on object-oriented instrument construction.
- Prevents common pitfalls like using legacy functions or incorrect date formats.
Usage examples
- “How do I price an Asian option using Monte Carlo in MATLAB?”
- The agent will guide you to use the AssetMonteCarlo pricer, detailing the setup of the stochastic model, instrument, and the simulation parameters required for path-dependent options.
- “Price a callable fixed-rate bond using a Hull-White tree.”
- The agent will provide the workflow for creating an OptionEmbeddedFixedBond instrument and a HullWhite model, then using the IRTree pricer to calculate the price.
- “Calculate the delta and vega for a European vanilla call option under Heston.”
- The agent will direct you to the FFT/Numerical Integration reference, showing how to use the price function with the Heston model to return both the price and the requested Greeks.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/matlab/matlab-price-instrument/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-price-instrument.zip -d .agents/skills
Documentation by MathWorks
Price Financial Instruments in MATLAB
Price financial instruments in MATLAB using the Financial Instruments Toolbox. Route to the correct numerical pricing method based on the user's request, then follow the method-specific reference for implementation details.
When to Use
User asks to price options, bonds, swaps, or derivatives in MATLAB
User asks for Greeks/sensitivities (delta, vega, gamma, theta, rho, lambda)
User mentions finpricer, fininstrument, finmodel, or ratecurve
User asks about Monte Carlo, tree / lattice, or FFT (Fast Fourier Transform) / FRFT (Fractional FFT) pricing
User wants to compare pricing methods for the same instrument
When NOT to Use
User is working with a non-MATLAB environment
User wants to build a custom instrument with a novel payoff function
User explicitly asks for a from-scratch implementation without the Financial Instruments Toolbox
Method Routing
Identify the pricing method from the user's request and read the corresponding reference:
| Method | Reference | When to Use |
|---|---|---|
| Monte Carlo (MC) | references/monte-carlo.md | Simulation-based pricing: path-dependent options, exotic options, Interest Rate (IR) derivatives via MC, rough volatility |
| FFT / FRFT / Numerical Integration | references/ni-fft.md | Fast pricing: European vanilla options under Heston/Bates/Merton via characteristic functions |
| Interest Rate Trees | references/embedded-bond-tree.md | Callable/puttable fixed-rate bonds with Hull-White (HW), Black-Karasinski (BK), Black-Derman-Toy (BDT), Cox-Ingersoll-Ross (CIR) tree models |
Routing Rules
Read exactly one reference (and any relevant sub-references) that best matches based on these rules:
User mentions a specific pricer:
AssetMonteCarlo,RoughVolMonteCarlo,IRMonteCarlo->references/monte-carlo.mdFFT,NumericalIntegration->references/ni-fft.mdIRTree->references/embedded-bond-tree.md
User mentions a specific numerical method and associated concepts:
Monte Carlo, simulation, NumTrials, SimulationDates ->
references/monte-carlo.mdFFT, FRFT, characteristic function, CharacteristicFcnStep, LogStrikeStep ->
references/ni-fft.mdInterest-rate tree, TreeDates, exercise probability ->
references/embedded-bond-tree.md
User mentions instrument type without a method:
Path-dependent options or other exotic options (Asian, Barrier, Lookback, Cliquet, Touch, Spread, Binary) ->
references/monte-carlo.mdEuropean vanilla options under stochastic vol/jump models ->
references/ni-fft.mdCallable/puttable fixed-rate bonds ->
references/embedded-bond-tree.mdIR derivatives (caps, floors, swaptions, swaps) ->
references/monte-carlo.md
User mentions model name without a method:
Heston, Bates, Merton + European vanilla ->
references/ni-fft.mdHeston, Bates, Merton + exotic/path-dependent ->
references/monte-carlo.mdHull-White, Black-Karasinski, BDT, CIR + callable/puttable bond ->
references/embedded-bond-tree.mdHull-White, BK, Linear Gaussian 2 Factor (G2PP), Brace-Gatarek-Musiela (BGM), SABR-BGM + caps/floors/swaptions ->
references/monte-carlo.mdRough volatility (RoughBergomi, RoughHeston) ->
references/monte-carlo.md
Ambiguous:
When asked to price European vanilla options without specifying pricing method (e.g., "price European call options with Heston in MATLAB"), default to
references/ni-fft.md(faster, more accurate for European vanilla)If user needs path simulation in addition to price and sensitivities, use
references/monte-carlo.mdIf user requests exercise probabilities at each time step for option embedded bonds, use
references/embedded-bond-tree.md
Shared Conventions
All three methods share these conventions:
Always prefer to use
finpricer/fininstrument/finmodel/ratecurveobjects (modern OO API) over legacy functionsNever use legacy functions unless the user explicitly names them, or the reference suggests them for specific use cases
Use name-value pairs with string keys:
"DiscountCurve", not positional argumentsParameter names are case-insensitive but write them in MixedCase for clarity
Always use
datetimefor dates (notdatenum)Do not use
priceas a variable name — it shadows thepricefunction; preferp, or capitalizedPriceRequest two outputs from
price()when Greeks or tree data are needed:[p, pr] = price(...)
Common Mistakes (Cross-Method)
Best practice: Check MATLAB documentation (doc <functionName>, or help <functionName>, etc.) via the MATLAB MCP server before writing code.
| Mistake | Correct |
|---|---|
finpricer("MonteCarlo", ...) | finpricer("AssetMonteCarlo", ...) or finpricer("IRMonteCarlo", ...) |
finpricer("HWMonteCarlo", ...) | finpricer("IRMonteCarlo", ...) with a HullWhite model |
| Mixing pricer families (e.g., FFT pricer for Asian option) | FFT/NI only works for European vanilla; use AssetMonteCarlo for exotics |
Using datenum | Always use datetime |
| Forgetting second output for Greeks | [p, pr] = price(pricer, inst, "delta") — Greeks are in pr.Results |
discount(rc, dates) | discountfactors(rc, dates) — ratecurve uses discountfactors(), not discount() |
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md6.3 KiB
- manifest.yaml462 B
- references/embedded-bond-tree.md10.2 KiB
- references/monte-carlo.md5.2 KiB
- references/monte-carlo/asset-monte-carlo.md13.0 KiB
- references/monte-carlo/ir-monte-carlo.md17.9 KiB
- references/ni-fft.md20.5 KiB
- references/ni-fft/bates-legacy-api.md2.1 KiB
- references/ni-fft/heston-legacy-api.md1.9 KiB
- references/ni-fft/legacy-api-shared.md4.3 KiB
- references/ni-fft/merton-legacy-api.md2.3 KiB
references/ni-fft/legacy-api-shared.md
Legacy API — Shared Reference
All legacy functions follow the pattern optBy<Model>FFT, optBy<Model>NI, optSensBy<Model>FFT, optSensBy<Model>NI. They are supported (R2018a+) but the OO workflow (R2020a+) is recommended for new code. Use legacy when you need ExpandOutput for surfaces or Strike=[] for grid inspection.
Output Rules
FFT functions return
[..., StrikeOut]— StrikeOut is always the last output (optional)NI functions return price or sensitivity outputs only — no StrikeOut
For optSensBy* functions,
OutSpeccontrols which sensitivities are returned; outputs are positional (1:1 with entries)
% FFT: StrikeOut is always LAST, after all OutSpec entries
[Delta, Gamma, Vega, StrikeOut] = optSensBy<Model>FFT(..., ...
'OutSpec', ["delta", "gamma", "vega"], 'CharacteristicFcnStep', 0.1);
% NI: no StrikeOut
[Delta, Gamma, Vega] = optSensBy<Model>NI(..., ...
'OutSpec', ["delta", "gamma", "vega"]);Name-Value Arguments
FFT-Specific
| Name | Default | Recommendation |
|---|---|---|
NumFFT | 4096 | Keep default; increase CharacteristicFcnStep instead |
CharacteristicFcnStep | 0.01 | Set to 0.1 or higher but not above 0.4 |
LogStrikeStep | 2*pi/NumFFT/CharacteristicFcnStep | Set to 2*pi/NumFFT/CharacteristicFcnStep/10 for FRFT |
DampingFactor | 1.5 | Leave at default |
Quadrature | "simpson" | Leave at default |
NI-Specific
| Name | Default | Notes |
|---|---|---|
AbsTol | 1e-10 | Absolute error tolerance (leave at default) |
RelTol | 1e-6 | Relative error tolerance (leave at default) |
IntegrationRange | [1e-9 Inf] | Adjust if integration warnings appear |
Framework | "heston1993" | Also "lewis2001" |
Shared (all models)
| Name | Default | Notes |
|---|---|---|
Basis | 0 | Day-count basis (numeric: 0,1,2,...,13) |
DividendYield | 0 | Continuously compounded yield |
ExpandOutput | false | Expand to strike-by-maturity matrices |
Model-specific NV args: Heston/Bates have LittleTrap (default true, always keep true) and VolRiskPremium (default 0). Merton does NOT support either — passing them causes an error.
ExpandOutput: Efficient Surface Generation
Setting 'ExpandOutput', true returns outputs as NumStrikes-by-NumMaturities matrices. This is the fastest way to generate surfaces — 2–6× faster than looping over maturities. Not available in the OO workflow.
% Pattern: column vector of strikes, vector of maturities
Strike = (80:5:120)'; % column vector
Maturity = [datetime(2026,9,30); datetime(2026,12,31); ...
datetime(2027,6,30); datetime(2027,12,31)];
% Pricing surface (9-by-4 matrix)
[PriceSurface, StrikeOut] = optBy<Model>FFT(Rate, AssetPrice, Settle, ...
Maturity, OptSpec, Strike, <model params>, ...
'CharacteristicFcnStep', 0.1, 'ExpandOutput', true);
% Sensitivity surfaces (each 9-by-4)
[Delta, Vega, StrikeOut] = optSensBy<Model>FFT(Rate, AssetPrice, Settle, ...
Maturity, OptSpec, Strike, <model params>, ...
'OutSpec', ["delta", "vega"], 'CharacteristicFcnStep', 0.1, ...
'ExpandOutput', true);Strike=[] Grid Inspection (Legacy Only)
Pass empty Strike to compute prices on the entire internal FFT/FRFT grid. StrikeOut then returns all NumFFT grid strikes centered around log(AssetPrice).
[Price, StrikeOut] = optBy<Model>FFT(Rate, AssetPrice, Settle, Maturity, ...
OptSpec, [], <model params>, 'CharacteristicFcnStep', 0.1);
% StrikeOut has NumFFT entries — inspect grid density and coverageNot possible in the OO API (which requires specific strikes on fininstrument).
Legacy-to-OO Mapping
| Legacy | OO Equivalent |
|---|---|
Rate (scalar) | ratecurve("zero", Settle, Maturity, Rate, 'Compounding', -1) |
AssetPrice | 'SpotPrice', AssetPrice on pricer |
OptSpec, Strike, Maturity | fininstrument("Vanilla", 'Strike', K, 'ExerciseDate', T, 'OptionType', OptSpec) |
'DividendYield', q | 'DividendValue', q on pricer |
'OutSpec', ["delta","vega"] | Third arg to price(): ["Delta","Vega"] |
| Positional sensitivity outputs | outPR.Results table with named columns |
StrikeOut (last FFT output) | Not needed — OO prices at exact requested strikes |
Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/computational-finance/matlab-price-instrument · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-price-instrument.zip