필터 지우기
필터 지우기

Anyone tried function handle of blsprice?

조회 수: 4 (최근 30일)
Zoe Zhang
Zoe Zhang 2011년 11월 3일
For those who are familiar with blsprice,please kindly ignore the next paragraph.
blsprice is in the financial toolbox to price Call/Put Options using Black-Scholes model. The syntax is: [Call, Put] = blsprice(Price, Strike, Rate, Time, Volatility, Yield) e.g.[Call, Put] = blsprice(100, 95, 0.1, 0.25, 0.5) returns call and put prices of $13.70 and $6.35, respectively.
I would like to create a function handle (like funh = @(x)blsprice(x,Strike, Rate, Time, Volatility, Yield) which enables me to control whether it is call or put, cos the result x would be depending on that. Does anyone knows how to do it? Thanks so much!
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2011년 11월 3일
I don't understand the question. x is your input argument. Why did you say "the result x would be depending on that"?
The function returns two outputs. You can always ignore the one that you don't need. Use ~ in R2009b or later might help. [~, Put] = blsprice(100, 95, 0.1, 0.25, 0.5)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 3일
If you are trying to create a function handle that is able to select the second output of a function, then unfortunately there is no way to do that in MATLAB other than to use an auxiliary real function along the line of
function output = selectoutput(funct,x,number)
[t1,t2] = funct(x);
if number == 2
result = t2;
else
result = t1;
end
end
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 11월 3일
I should not have used "function" as a variable name -- opps!
quad(@(x) selectoutput(funct,x,2),lb,ub)
Zoe Zhang
Zoe Zhang 2011년 11월 3일
Works well~ Thanks you :-)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Nikolay
Nikolay 2012년 4월 26일
Hi fellas
could you help me with this. If I have the value of the call (c) can I use some kind of solver to find what the S0 and SIG are? I need them for the merton model
[c, p] = blsprice(S0, K, R, T, SIG, Q)
  댓글 수: 2
Zoe Zhang
Zoe Zhang 2012년 4월 26일
if u r trying to find sig, you don't really need solver. Check out doc blsimpv; if you need to search for S0, check out fzero, fminsearch etc.
Nikolay
Nikolay 2012년 4월 30일
thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by