Generated banner for Matlab Price Instrument
Generated logo for Matlab Price Instrument

Matlab Price Instrument

MathWorksOfficialCreated by MathWorks

  • Skill
  • Tool integration
  • Science and research
  • BSD-2-Clause
  • No issues found

From the author

Price financial instruments in MATLAB using the Financial Instruments Toolbox. Route to the appropriate numerical method reference based on the user's request: Monte Carlo simulation (AssetMonteCarlo, IRMonteCarlo, RoughVolMonteCarlo), FFT / Numerical Integration (Vanilla European options), or Interest-Rate Trees (option-embedded bonds with IRTree). Use when the user asks to price financial instruments or compute Greeks using any of these methods. Use one of the following models depending on the pricing method and instrument: Black-Scholes, Bachelier, Heston, Bates, Merton, Hull-White, Black-Karasinski, Black-Derman-Toy, Cox-Ingersoll-Ross, Linear Gaussian 2 Factor (G2PP), Brace-Gatarek-Musiela (BGM), SABR-BGM, RoughBergomi, RoughHeston.
— the description by MathWorks

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

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/matlab/matlab-price-instrument/download
  2. Unzip 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:

MethodReferenceWhen to Use
Monte Carlo (MC)references/monte-carlo.mdSimulation-based pricing: path-dependent options, exotic options, Interest Rate (IR) derivatives via MC, rough volatility
FFT / FRFT / Numerical Integrationreferences/ni-fft.mdFast pricing: European vanilla options under Heston/Bates/Merton via characteristic functions
Interest Rate Treesreferences/embedded-bond-tree.mdCallable/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:

  1. User mentions a specific pricer:

    • AssetMonteCarlo, RoughVolMonteCarlo, IRMonteCarlo -> references/monte-carlo.md

    • FFT, NumericalIntegration -> references/ni-fft.md

    • IRTree -> references/embedded-bond-tree.md

  2. User mentions a specific numerical method and associated concepts:

    • Monte Carlo, simulation, NumTrials, SimulationDates -> references/monte-carlo.md

    • FFT, FRFT, characteristic function, CharacteristicFcnStep, LogStrikeStep -> references/ni-fft.md

    • Interest-rate tree, TreeDates, exercise probability -> references/embedded-bond-tree.md

  3. User mentions instrument type without a method:

    • Path-dependent options or other exotic options (Asian, Barrier, Lookback, Cliquet, Touch, Spread, Binary) -> references/monte-carlo.md

    • European vanilla options under stochastic vol/jump models -> references/ni-fft.md

    • Callable/puttable fixed-rate bonds -> references/embedded-bond-tree.md

    • IR derivatives (caps, floors, swaptions, swaps) -> references/monte-carlo.md

  4. User mentions model name without a method:

    • Heston, Bates, Merton + European vanilla -> references/ni-fft.md

    • Heston, Bates, Merton + exotic/path-dependent -> references/monte-carlo.md

    • Hull-White, Black-Karasinski, BDT, CIR + callable/puttable bond -> references/embedded-bond-tree.md

    • Hull-White, BK, Linear Gaussian 2 Factor (G2PP), Brace-Gatarek-Musiela (BGM), SABR-BGM + caps/floors/swaptions -> references/monte-carlo.md

    • Rough volatility (RoughBergomi, RoughHeston) -> references/monte-carlo.md

  5. 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.md

    • If 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/ratecurve objects (modern OO API) over legacy functions

  • Never 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 arguments

  • Parameter names are case-insensitive but write them in MixedCase for clarity

  • Always use datetime for dates (not datenum)

  • Do not use price as a variable name — it shadows the price function; prefer p, or capitalized Price

  • Request 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.

MistakeCorrect
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 datenumAlways 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

references/monte-carlo/asset-monte-carlo.md

Asset Monte Carlo Pricing

Price equity and FX options using Monte Carlo simulation with finpricer("AssetMonteCarlo", ...).

Model-to-Pricer Mapping

The model you pass to the pricer determines the underlying SDE engine:

finmodelVol DynamicsInternal Pricer
finmodel("BlackScholes", "Volatility", sigma)Constant vol (GBM)GBMMonteCarlo
finmodel("Heston", "V0", v0, "ThetaV", theta, "Kappa", kappa, "SigmaV", sigmaV, "RhoSV", rho)Stochastic volHestonMonteCarlo
finmodel("Bates", "V0", v0, "ThetaV", theta, "Kappa", kappa, "SigmaV", sigmaV, "RhoSV", rho, "MeanJ", mu, "JumpVol", sigmaJ, "JumpFreq", lambda)Stochastic vol + jumpsBatesMonteCarlo
finmodel("Merton", "Volatility", sigma, "MeanJ", mu, "JumpVol", sigmaJ, "JumpFreq", lambda)Constant vol + jumpsMertonMonteCarlo
finmodel("Bachelier", "Volatility", sigma)Normal modelBachelierMonteCarlo

For rough volatility models, use finpricer("RoughVolMonteCarlo", ...) instead:

finmodelInternal Pricer
finmodel("RoughBergomi", "Alpha", alpha, "Eta", eta, "Xi", xi, "RhoSV", rho)RoughBergomiMonteCarlo
finmodel("RoughHeston", "V0", v0, "ThetaV", theta, "Kappa", kappa, "SigmaV", sigmaV, "RhoSV", rho, "Alpha", alpha)RoughHestonMonteCarlo

RoughVolMonteCarlo works best with evenly spaced SimulationDates. The documentation recommends uniform spacing for accuracy; non-uniform dates may work but can reduce simulation quality.

Supported Instruments

InstrumentKey ParametersNotes
VanillaExerciseDate, Strike, OptionType, ExerciseStyleEuropean, American (daily SimDates), Bermudan (SimDates must include all exercise dates). Bermudan Strike can be a vector (one per exercise date).
AsianExerciseDate, Strike, OptionType, AverageType, AverageStartDate, AveragePriceAverageType: "arithmetic" or "geometric". Strike=NaN for floating strike. AveragePrice is the running average to date for seasoned options (set AverageStartDate to when averaging began).
BarrierExerciseDate, Strike, BarrierType, BarrierValue, RebateBarrierType: "di", "do", "ui", "uo". Use ExerciseStyle="american" for continuous monitoring.
DoubleBarrierExerciseDate, Strike, BarrierType, BarrierValue, RebateBarrierType: "dki", "dko". BarrierValue is [UpperBarrier LowerBarrier]. Rebate can be scalar or [UpperRebate LowerRebate].
LookbackExerciseDate, Strike, OptionType, AssetMinMaxStrike=NaN for floating strike. AssetMinMax for seasoned options.
PartialLookbackExerciseDate, Strike, OptionType, MonitorDate, StrikeScaler, AssetMinMaxStrike=NaN for floating strike. MonitorDate is end of monitoring window (monitoring starts at settle). StrikeScaler multiplies the extremum (default 1). AssetMinMax for seasoned options (pre-existing min/max).
BinaryExerciseDate, Strike, OptionType, PayoffValueDigital option. PayoffValue is the fixed cash payout (default 1).
TouchExerciseDate, BarrierType, BarrierValue, PayoffValue, PayoffTypeBarrierType: "ot" (one-touch) or "nt" (no-touch). BarrierValue is the trigger level. PayoffValue is the fixed payout amount. PayoffType: "hit" (pay at barrier touch) or "expiry" (pay at maturity).
DoubleTouchExerciseDate, BarrierType, BarrierValue, PayoffValue, PayoffTypeBarrierType: "dot" (double one-touch), "dnt" (double no-touch), "unt-lot" (upper no-touch, lower one-touch), "uot-lnt" (upper one-touch, lower no-touch). BarrierValue is [UpperBarrier LowerBarrier]. PayoffValue is the fixed payout. PayoffType: "hit" or "expiry".
CliquetResetDates, OptionType, LocalCap, LocalFloor, GlobalCap, GlobalFloor, ReturnType, InitialStrikeReturnType: "absolute" (default) or "relative". Caps/floors default to Inf/0. ResetDates defines reset schedule (first date is start, last is expiry).
SpreadExerciseDate, Strike, OptionTypeBlackScholes model only. Requires multi-asset pricer setup (see below).
Model-Instrument Restrictions

Not all instruments work with all models:

ModelSupported InstrumentsNotes
BlackScholesAll instruments including SpreadOnly model supporting full instrument set with multi-asset
MertonAll single-asset instruments (no Spread)Supports Cliquet. Error: 'fininst:finpricer:InvalidInst' for Spread
Heston, BatesAll single-asset instruments (no Spread)Supports Cliquet. Also supports "vegalt" sensitivity. Error: 'fininst:finpricer:SingleAsset' for multi-asset
BachelierBinary, Vanilla, Spread onlySupports multi-asset for Spread. No Cliquet.

Pricer Parameters

Required
pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, ...        % ratecurve object
    "Model", mdl, ...               % finmodel object
    "SpotPrice", S0, ...            % positive scalar (or vector for multi-asset)
    "SimulationDates", simDates);   % datetime vector — MUST include all exercise dates
Optional
ParameterTypeDefaultNotes
NumTrialspositive integer1000Use 1e4+ for production
RandomNumbersstruct or numeric array[]Struct with field Z (and N, SizeJ for jump models). Or pass the raw array directly.
DividendType"continuous" or "cash""continuous"
DividendValuescalar or timetable0Scalar for continuous yield. timetable(dates, amounts) for cash dividends.
MonteCarloMethod"standard", "quasi", "randomized-quasi""standard"Ignored if RandomNumbers is supplied.
BrownianMotionMethod"standard", "brownian-bridge", "principal-components""standard"Ignored if RandomNumbers is supplied.

SimulationDates Rules

This is the most common source of errors:

  • Must include all exercise dates. For European options, include at least the expiry date. For American options, use daily dates from settle to expiry. For Bermudan, include all exercise dates.

  • Must be after ratecurve.Settle. Dates on or before settle cause an error.

  • Path-dependent options (Asian, Barrier, Lookback) need enough intermediate dates to capture the path accurately. Daily or near-daily dates are typical.

  • Dates are automatically sorted. You can pass them in any order.

% European: just needs expiry
simDates = ExerciseDate;

% American: daily dates
simDates = rc.Settle+days(1):days(1):ExerciseDate;

% Asian with monitoring: regular intervals
simDates = rc.Settle+days(1):days(5):ExerciseDate;
% Make sure ExerciseDate is included
if simDates(end) ~= ExerciseDate
    simDates = [simDates, ExerciseDate];
end

Random Number Reuse

To compare pricing runs with identical paths (e.g., different strikes, different instruments):

% First run: capture random numbers from output
[p1, pr1] = price(pricer, inst1, "all");
savedRN = pr1.PricerData.RandomNumbers;

% Second run: feed them back
pricer.RandomNumbers = savedRN;
[p2, pr2] = price(pricer, inst2, "all");

You can also pass just the Z matrix directly:

pricer.RandomNumbers = pr1.PricerData.RandomNumbers.Z;

The output pr.PricerData also contains:

  • Paths: simulated asset paths (NumDates x NumAssets x NumTrials)

  • SimulationTimes.Dates: datetime vector of simulation dates

  • SimulationTimes.Times: year fraction vector

Dividend Configuration

Continuous dividend yield
pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, "Model", mdl, "SpotPrice", 100, ...
    "SimulationDates", simDates, ...
    "DividendValue", 0.03);  % 3% continuous yield
% DividendType defaults to "continuous"
Discrete cash dividends
divDates = [datetime(2025,3,15); datetime(2025,9,15)];
divAmounts = [2; 2];
divSchedule = timetable(divDates, divAmounts);

pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, "Model", mdl, "SpotPrice", 100, ...
    "SimulationDates", simDates, ...
    "DividendType", "cash", ...
    "DividendValue", divSchedule);

Multi-Asset / Spread Pricing

Spread options require two correlated assets:

% Model with 2 volatilities and correlation
mdl = finmodel("BlackScholes", ...
    "Volatility", [0.20; 0.10], ...
    "Correlation", [1 0.5; 0.5 1]);

% Pricer with 2 spot prices
pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, ...
    "Model", mdl, ...
    "SpotPrice", [110, 90], ...
    "SimulationDates", ExerciseDate, ...
    "DividendType", ["continuous"; "continuous"], ...
    "DividendValue", [0; 0]);

% Spread instrument
spreadOpt = fininstrument("Spread", ...
    "ExerciseDate", ExerciseDate, ...
    "Strike", 15);

[p, pr] = price(pricer, spreadOpt, "all");

Key rules for multi-asset:

  • Volatility on the model must be a vector matching the number of assets

  • Correlation must be an NxN positive definite matrix

  • SpotPrice must be a vector matching the number of assets

  • DividendType and DividendValue must also have one entry per asset

  • Non-Spread instruments (Vanilla, Asian, etc.) require exactly 1 asset

Complete Examples

European Call with Greeks
Settle = datetime(2024,1,1);
ExerciseDate = datetime(2025,1,1);
Rates = 0.05;

rc = ratecurve('zero', Settle, ExerciseDate, Rates);
mdl = finmodel("BlackScholes", "Volatility", 0.3);
call = fininstrument("Vanilla", "ExerciseDate", ExerciseDate, "Strike", 100);

pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, ...
    "Model", mdl, ...
    "SpotPrice", 100, ...
    "SimulationDates", ExerciseDate, ...
    "NumTrials", 1e4);

[p, pr] = price(pricer, call, ["delta", "vega", "gamma"]);
fprintf("Price: %.4f, Delta: %.4f, Vega: %.4f\n", p, pr.Results.Delta, pr.Results.Vega);
Asian Call with Path Reuse
Settle = datetime(2024,1,1);
ExerciseDate = datetime(2025,1,1);

rc = ratecurve('zero', Settle, ExerciseDate, 0.05);
mdl = finmodel("BlackScholes", "Volatility", 0.3);

simDates = [Settle+days(5):days(5):ExerciseDate-days(5), ExerciseDate];

asianCall = fininstrument("Asian", ...
    "ExerciseDate", ExerciseDate, ...
    "Strike", 100, ...
    "OptionType", "call");

pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, ...
    "Model", mdl, ...
    "SpotPrice", 100, ...
    "SimulationDates", simDates, ...
    "NumTrials", 1e4);

[p1, pr1] = price(pricer, asianCall, "all");

% Reuse paths for different strike
asianCall2 = fininstrument("Asian", ...
    "ExerciseDate", ExerciseDate, ...
    "Strike", 110, ...
    "OptionType", "call");

pricer.RandomNumbers = pr1.PricerData.RandomNumbers;
p2 = price(pricer, asianCall2);
Heston Stochastic Vol
Settle = datetime(2024,1,1);
ExerciseDate = datetime(2025,1,1);

rc = ratecurve('zero', Settle, ExerciseDate, 0.05);

mdl = finmodel("Heston", ...
    "V0", 0.04, ...
    "ThetaV", 0.04, ...
    "Kappa", 2, ...
    "SigmaV", 0.3, ...
    "RhoSV", -0.7);

call = fininstrument("Vanilla", "ExerciseDate", ExerciseDate, "Strike", 100);

pricer = finpricer("AssetMonteCarlo", ...
    "DiscountCurve", rc, ...
    "Model", mdl, ...
    "SpotPrice", 100, ...
    "SimulationDates", ExerciseDate, ...
    "NumTrials", 1e4);

[p, pr] = price(pricer, call, "all");

Common Mistakes

MistakeWhy It FailsCorrect
SimulationDates missing ExerciseDateRuntime error: 'fininst:finpricer:ExerciseDateNotSim'Always include ExerciseDate in SimulationDates
"NumSimulations"Not a valid parameter"NumTrials"
"Paths" as inputNot a valid parameter (it's an output in pr.PricerData.Paths)Use "RandomNumbers" to control simulation input
"AntitheticVariates"Not a valid parameter; antithetic variates are not supportedUse "MonteCarloMethod", "quasi" or "BrownianMotionMethod", "brownian-bridge" for variance reduction
finpricer("RoughVolMonteCarlo", "Model", finmodel("BlackScholes",...))Wrong pricer for BlackScholesUse finpricer("AssetMonteCarlo", ...) for BlackScholes/Heston/Bates/Merton
finpricer("AssetMonteCarlo", "Model", finmodel("RoughBergomi",...))Wrong pricer for rough volUse finpricer("RoughVolMonteCarlo", ...) for RoughBergomi/RoughHeston
Single SpotPrice for Spread instrumentError: 'fininst:finpricer:SpreadNeedTwoAssets'Provide vector of SpotPrices and correlation matrix
Pricing Vanilla/Asian with multi-asset pricerError: 'fininst:finpricer:OptionNeedOneAsset'Use single SpotPrice for non-Spread instruments
Spread with Heston/Merton/Bates modelOnly BlackScholes and Bachelier support multi-asset. Error: 'fininst:finpricer:SingleAsset'Use finmodel("BlackScholes", ...) for Spread pricing
Non-uniform SimulationDates with RoughVolMonteCarloAccuracy degrades with irregular spacingPrefer uniform spacing: Settle+days(1):days(1):ExerciseDate

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