%% Use FFT Pricer and Heston Model to Price Vanilla Instrument
% This example shows the workflow to price a Vanilla instrument when you use a Heston model and an FFT pricing method.
%% Create Vanilla Instrument Object
% Use fininstrument to create a Vanilla instrument object.

VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2022,9,15),'Strike',105,'ExerciseStyle',"european",'Name',"vanilla_option")

%
%% Create Heston Model Object
% Use finmodel to create a Heston model object.

HestonModel = finmodel("Heston",'V0',0.032,'ThetaV',0.1,'Kappa',0.003,'SigmaV',0.2,'RhoSV',0.9)

%% Create ratecurve Object
% Create a flat ratecurve object using ratecurve.

Settle = datetime(2018,9,15);
Maturity = datetime(2023,9,15);
Rate = 0.035;
myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)

%% Create FFT Pricer Object
% Use finpricer to create an FFT pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("fft",'DiscountCurve',myRC,'Model',HestonModel,'SpotPrice',100,'CharacteristicFcnStep', 0.2,'NumFFT',2^13)

%% Price Vanilla Instrument
% Use price to compute the price and sensitivities for the Vanilla instrument.

[Price, outPR] = price(outPricer,VanillaOpt,["all"])
outPR.Results

%
% Copyright 2019 The MathWorks, Inc.