odd handling of tensors by blsprice

2 visualizzazioni (ultimi 30 giorni)
Harry
Harry il 11 Lug 2020
Risposto: Harry il 12 Lug 2020
Hi
I am trying to investigate the shape of the scalar field of the Black Scholes option pricing formula.
In matalb to vary all 5 of the parameters rather than inputing a vector for each parameter, you have to do it by inputting a tesseract.
In the folowing code each tesseract is 12*12*12*12*12
Tess = ones(12,12,12,12,12);
StockPTess = Tess.*[1:12];
StockPTess = permute(StockPTess,[2,1,3,4,5]);
StrikePTess= Tess.*[1:12];
RateTess = Tess.*[0.05:0.05:0.6];
RateTess = permute(RateTess,[1,3,2,4,5]);
TimeTess = Tess.*[1:12];
TimeTess = permute(TimeTess,[1,3,4,2,5]);
VolTess = Tess.*[0.2:0.2:2.4];
VolTess = permute(VolTess,[1,3,4,5,2]);
Price = blsprice(StockPTess,StrikePTess,RateTess,TimeTess,VolTess);````
Instead of outputing a 12*12*12*12*12 matrix, this exports a 12*20736 matrix, from the help page i can see no indication of which entries in the matrix correspond to which element of the tesseract that I expected to get out.

Risposta accettata

Harry
Harry il 12 Lug 2020
After testing this function I found that with the above set up:
columns 1-12 vary with strike price and the strike prices repeat from 13-24 etc
columns 1-12 all correspond to the same intrest rate as do 13-24 - this
pattern repeats until 144; and the cycle begins again at 145
columns 1-144 all correspond to the same duration of option; and so on
columns 1-1728 all correspond to the same volatility
this means that we can reshape the matrix to get the tesseract:
PriceTess =reshape(Price,[12,12,12,12,12]);

Più risposte (0)

Categorie

Scopri di più su Price and Analyze Financial Instruments in Help Center e File Exchange

Prodotti


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by