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/embedded-bond-tree.md

Price Option-Embedded Fixed Bonds with Interest-Rate Trees

Price callable and puttable fixed-rate bonds using interest-rate tree models in MATLAB Financial Instruments Toolbox. Covers model selection, instrument construction, pricing, exercise probability extraction, and exercise policy modification.

When to Use

  • Pricing callable or puttable fixed-rate bonds with embedded options

  • Building interest-rate trees (HW, BK, BDT, CIR) for bond pricing

  • Choosing between rate models for different market conditions

  • Extracting exercise probabilities from tree-based pricing

  • Modifying exercise policies on existing instruments

  • Comparing prices across multiple IR tree models

When NOT to Use

  • Monte Carlo pricing for option-embedded bonds — read references/monte-carlo.md (use IRMonteCarlo pricer)

  • Floating-rate option-embedded bonds — use OptionEmbeddedFloatBond instrument

  • Convertible bonds — use ConvertibleBond instrument

  • Vanilla fixed-bond pricing without embedded options — use FixedBond instrument

  • OAS computation — the oas function works directly after pricing; no special guidance needed

Workflow

The workflow follows four steps: instrument -> model -> pricer -> price.

Step 1: Create the Instrument

Use fininstrument("OptionEmbeddedFixedBond", ...) for bonds with embedded call or put options. Define the exercise schedule as a timetable.

CallDates = [datetime(2026,1,15); datetime(2029,1,15)];
CallPrices = [101; 101];
CallSchedule = timetable(CallDates, CallPrices);

Bond = fininstrument("OptionEmbeddedFixedBond", ...
    CouponRate=0.03, ...
    Maturity=datetime(2029,1,15), ...
    Period=2, ...
    Principal=100, ...
    CallSchedule=CallSchedule, ...
    CallExerciseStyle="American", ...
    Name="CallableBond");

Exercise schedule conventions:

  • European: single date in the schedule

  • Bermudan: list each allowed exercise date explicitly

  • American: either a single date (callable from settlement up to that date) or two rows defining a restricted exercise window (start and end)

Bermudan example (callable at par on years 3, 4, and 5):

CallDates = (datetime(2027,1,15):calyears(1):datetime(2029,1,15))';
CallPrices = repmat(100, numel(CallDates), 1);
CallSchedule = timetable(CallDates, CallPrices);

Bond = fininstrument("OptionEmbeddedFixedBond", ...
    CouponRate=0.035, ...
    Maturity=datetime(2029,1,15), ...
    Period=2, ...
    Principal=100, ...
    CallSchedule=CallSchedule, ...
    CallExerciseStyle="Bermudan", ...
    Name="BermudanCallable");

American puttable example (puttable at par from year 5 through maturity):

% American exercise: exactly 2 rows — window start and end
PutDates = [datetime(2029,1,15); datetime(2034,1,15)];
PutPrices = [100; 100];
PutSchedule = timetable(PutDates, PutPrices);

Bond = fininstrument("OptionEmbeddedFixedBond", ...
    CouponRate=0.0275, ...
    Maturity=datetime(2034,1,15), ...
    Period=1, ...
    Principal=100, ...
    PutSchedule=PutSchedule, ...
    PutExerciseStyle="American", ...
    Name="PuttableBond");
Step 2: Create the Model

Four models support IRTree pricing for option-embedded bonds:

ModelFunctionParametersRatesBest For
Hull-Whitefinmodel("HullWhite", ...)Alpha, SigmaAllows negativeNegative rate environments
Black-Karasinskifinmodel("BlackKarasinski", ...)Alpha, SigmaPositive onlyLow positive rates, mean reversion control
Black-Derman-Toyfinmodel("BlackDermanToy", ...)SigmaPositive onlySimple calibration, shorter maturities
Cox-Ingersoll-Rossfinmodel("CoxIngersollRoss", ...)Alpha, Theta, SigmaNon-negativeSquare-root diffusion, rate-dependent vol
HWModel = finmodel("HullWhite", Alpha=0.05, Sigma=0.01);
BKModel = finmodel("BlackKarasinski", Alpha=0.05, Sigma=0.10);
BDTModel = finmodel("BlackDermanToy", Sigma=0.10);
CIRModel = finmodel("CoxIngersollRoss", Alpha=0.03, Theta=0.04, Sigma=0.05);

Time-varying volatility: BK and HW accept Sigma as a timetable:

VolDates = [datetime(2026,1,15); datetime(2029,1,15); datetime(2032,1,15)];
VolValues = [0.10; 0.15; 0.12];
SigmaTT = timetable(VolDates, VolValues, VariableNames={'Value'});
BKModel = finmodel("BlackKarasinski", Alpha=0.05, Sigma=SigmaTT);
Step 3: Create the IRTree Pricer

Critical difference: CIR uses Maturity + NumPeriods. All others use TreeDates.

% Hull-White, Black-Karasinski, Black-Derman-Toy:
TreeDates = (Settle + calyears(1:5))';
Pricer = finpricer("IRTree", Model=HWModel, DiscountCurve=myRC, TreeDates=TreeDates);

% Cox-Ingersoll-Ross (different interface):
CIRPricer = finpricer("IRTree", Model=CIRModel, DiscountCurve=myRC, ...
    Maturity=datetime(2029,1,15), NumPeriods=10);
Step 4: Price and Extract Results
[P, priceResult] = price(Pricer, Bond);

The second output is a priceresult object containing:

  • priceResult.Results — table with the price

  • priceResult.PricerData.PriceTree — struct with tree data including:

    • ExTree — exercise decision at each node

    • ExProbTree — exercise probability at each node

    • ExProbsByTreeLevel — aggregate exercise probability per time step

    • PTree — bond prices at each node

    • ProbTree — transition probabilities

    • tObs — observation times

Model Selection Guide

Market ConditionRecommended ModelRationale
Negative interest ratesHull-WhiteGaussian process naturally allows negative rates
Low positive ratesBlack-KarasinskiLognormal with explicit mean-reversion control
Simple/short-datedBlack-Derman-ToySingle parameter (Sigma), easy calibration
Rate-dependent volatilityCox-Ingersoll-RossSquare-root diffusion, vol scales with rate level

LinearGaussian2F is NOT supported for IRTree pricing. It will fail at runtime with "Model not supported in IRTree." Use it only with other pricer types.

Key Functions

FunctionPurposeAvailable From
fininstrument("OptionEmbeddedFixedBond", ...)Create callable/puttable bondR2020a
finmodel("CoxIngersollRoss", ...)Create CIR rate modelR2023b
finpricer("IRTree", ...)Create tree-based pricerR2020a
price(pricer, instrument)Compute bond priceR2020a
setCallExercisePolicy(bond, schedule, style)Modify call exercise policyR2020b
setPutExercisePolicy(bond, schedule, style)Modify put exercise policyR2020b
oas(pricer, instrument, marketPrice)Compute option-adjusted spreadR2020a

Patterns

Modify Exercise Policy Without Rebuilding

Use setCallExercisePolicy or setPutExercisePolicy to change an existing instrument's exercise style and schedule without creating a new instrument:

NewSchedule = timetable([datetime(2027,1,15); datetime(2031,1,15)], [100; 100]);
BondAmerican = setCallExercisePolicy(Bond, NewSchedule, "American");

% Same pattern for puts:
PutBondEuropean = setPutExercisePolicy(PutBond, timetable(datetime(2030,1,15), 100), "European");
Extract Exercise Probabilities
[P, priceResult] = price(Pricer, Bond);
pt = priceResult.PricerData.PriceTree;

% Aggregate probability of exercise at each tree level (1 x nLevels double)
disp(pt.ExProbsByTreeLevel);

% Per-node exercise probabilities (cell array, one per tree level)
% Each cell contains probabilities of exercise at each node for that level
disp(pt.ExProbTree{3});

% Exercise indicator: 1 = exercised, 0 = not (cell array of logical arrays)
disp(pt.ExTree{3});

% Probability of reaching each node from root (cell array of doubles)
% Use to weight node-level results for custom analytics
disp(pt.ProbTree{3});
Compute OAS, Duration, and Convexity
MarketPrice = 97.50;
[OAS, OAD, OAC] = oas(Pricer, Bond, MarketPrice);
Compare All Models
Settle = datetime(2024,1,15);
Maturity = datetime(2029,1,15);
TreeDates = (Settle + calyears(1:5))';

models = {
    finmodel("HullWhite", Alpha=0.05, Sigma=0.01)
    finmodel("BlackKarasinski", Alpha=0.05, Sigma=0.10)
    finmodel("BlackDermanToy", Sigma=0.10)
};
modelNames = ["Hull-White", "Black-Karasinski", "Black-Derman-Toy"];

for i = 1:numel(models)
    p = finpricer("IRTree", Model=models{i}, DiscountCurve=myRC, TreeDates=TreeDates);
    prices(i) = price(p, Bond);
end

% CIR uses different interface
CIRModel = finmodel("CoxIngersollRoss", Alpha=0.03, Theta=0.04, Sigma=0.05);
CIRPricer = finpricer("IRTree", Model=CIRModel, DiscountCurve=myRC, ...
    Maturity=Maturity, NumPeriods=10);
prices(4) = price(CIRPricer, Bond);
modelNames(4) = "CoxIngersollRoss";

table(modelNames', prices', VariableNames=["Model", "Price"])

Common Mistakes

MistakeWhy It's WrongCorrect Approach
Using FixedBondOption for callable/puttable bondsFixedBondOption is an option ON a bond (separate contract). OptionEmbeddedFixedBond is a bond WITH embedded options.Use fininstrument("OptionEmbeddedFixedBond", ...)
Using TreeDates with CIR modelCIR pricer requires Maturity and NumPeriodsUse finpricer("IRTree", Model=CIRModel, DiscountCurve=rc, Maturity=mat, NumPeriods=n)
Using LinearGaussian2F with IRTreeNot supported — fails at runtimeUse HW, BK, BDT, or CIR only
Listing every date for American exerciseAmerican uses at most two rows, not a list of datesUse a single date (callable from settlement to that date) or two rows (restricted window start + end)
Rebuilding instrument to change exercise styleUnnecessary — methods exist for thisUse setCallExercisePolicy or setPutExercisePolicy
Using only 3 models (HW, BK, BDT)CIR is also available (since R2023b)Include CoxIngersollRoss in model comparisons

Conventions

  • Always use datetime for dates (not datenum)

  • Always use column vectors for TreeDates (row vectors cause concatenation errors)

  • Always request two outputs from price() when exercise analysis is needed

  • Prefer OptionEmbeddedFixedBond over FixedBondOption + FixedBond combination

  • Use Principal (not Face) for the notional amount parameter


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