필터 지우기
필터 지우기

odd handling of tensors by blsprice

조회 수: 2 (최근 30일)
Harry
Harry 2020년 7월 11일
답변: Harry 2020년 7월 12일
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.

채택된 답변

Harry
Harry 2020년 7월 12일
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]);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Price and Analyze Financial Instruments에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by