MATLAB Examples

Demonstrates optimizing a storage facility and valuing a storage contract using intrinsic valuation. The optimization involves finding the optimal positions in a set of forward natural

Hedge the interest-rate risk of a portfolio using bond futures.

Compute the unilateral credit value (valuation) adjustment (CVA) for a bank holding a portfolio of vanilla interest rate swaps with several counterparties. CVA is the expected loss on an

An approach to modeling wrong-way risk for Counterparty Credit Risk using a Gaussian copula.

Price first-to-default (FTD) swaps under the homogeneous loss assumption.

Price a single-name CDS option using cdsoptprice . The function cdsoptprice is based on the Black's model as described in O'Kane (2008). The optional knockout argument for cdsoptprice

Simulate electricity prices using a mean-reverting model with seasonality and a jump component. The model is calibrated under the real-world probability using historical electricity

Different hedging strategies to minimize exposure in the Energy market using Crack Spread Options.

Price a swing option using a Monte Carlo simulation and the Longstaff-Schwartz method. A risk-neutral simulation of the underlying natural gas price is conducted using a mean-reverting

Price and calculate sensitivities for European and American spread options using various techniques. First, the price and sensitivities for a European spread option is calculated using

Consider an American call option with an exercise price of $120. The option expires on Jan 1, 2018. The stock has a volatility of 14% per annum, and the annualized continuously compounded

Price a European Asian option using four methods in the Financial Instruments Toolbox™. This example demonstrates two closed form approximations (Levy and Kemna-Vorst), a lattice model

Analyze inflation indexed instruments using Financial Toolbox™ and Financial Instruments Toolbox™.

Bootstrap an interest-rate curve, often referred to as a swap curve, using the IRDataCurve object. The static bootstrap method takes as inputs a cell array of market instruments (which can

Construct a Diebold Li model of the US yield curve for each month from 1990 to 2010. This example also demonstrates how to forecast future yield curves by fitting an autoregressive model to the

Use objects to model the term structure of interest rates (also referred to as the yield curve). This can be contrasted with modeling the term structure with vectors of dates and data and

Price Bermudan swaptions using interest-rate models in Financial Instruments Toolbox™. Specifically, a Hull-White one factor model, a Linear Gaussian two-factor model, and a LIBOR

This file replicates cross-currency forward pricing using covered interest parity (CIP). It generates and plots CIP-implied forward exchange rates and calculates forward contract

Use ZeroRates for a zero curve that is hard-coded. You can also create a zero curve by bootstrapping the zero curve from market data (for example, deposits, futures/forwards, and swaps)

Price a swaption using the SABR model. First, a swaption volatility surface is constructed from market volatilities. This is done by calibrating the SABR model parameters separately for

Model prepayment in MATLAB® using functionality from the Financial Instruments Toolbox™. Specifically, a variation of the Richard and Roll prepayment model is implemented using a two

Use an underlying mortgage-backed security (MBS) pool for a 30-year fixed-rate mortgage of 6% to define a PAC bond, and then define a sequential CMO from the PAC bond. Analyze the CMO by

Illustrates how MATLAB® can be used to create a portfolio of interest-rate derivatives securities, and price it using the Black-Karasinski interest-rate model. The example also shows

Illustrates how the Financial Toolbox™ and Financial Instruments Toolbox™ are used to price a level mortgage backed security using the BDT model.

Illustrates how the Financial Instruments Toolbox™ is used to price European vanilla call options using different equity models.

Illustrates how the Financial Instruments Toolbox™ is used to create a Black-Derman-Toy (BDT) tree and price a portfolio of instruments using the BDT model.

Price swaptions with negative strikes by using the Shifted SABR model. The market Shifted Black volatilities are used to calibrate the Shifted SABR model parameters. The calibrated

Use hwcalbyfloor to calibrate market data with the Normal (Bachelier) model to price floorlets. Use the Normal (Bachelier) model to perform calibrations when working with negative

Use hwcalbycap to calibrate market data with the Normal (Bachelier) model to price caplets. Use the Normal (Bachelier) model to perform calibrations when working with negative interest

Compute risk neutral standardized moments of an asset's return distribution from volatility smile interpolation. Part of the IMOMBOX.

Compute risk-neutral prices of a contract paying an asset's return or powers thereof from traded options. Part of the IMOMBOX.

Compute risk-neutral prices of a contract paying an asset's return or powers thereof from volatility smile interpolation. Part of the IMOMBOX.

Compute risk neutral standardized moments of an asset's return distribution from traded options. Part of the IMOMBOX.

Copyright 2017 - 2017 The MathWorks, Inc.

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a location from the following list:

See all countries