first time matlab user, trying to use fmincon for a simple question
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to use fmincon to get the best result for an input variable. I think I am close. Student here!
my input variables are
S0 = 1433.32; K = 1430; r = 0.0011; T = 30/365; sigma = .15;
y = ??
the y is my variable I need to change, so that the result of this function will be 24.5.
x0 = 24.9;
x = fmincon(blackScholesCallPrice,x0,[],[])
function [cprice] = blackScholesCallPrice( K, T, S0, r, y, sigma )
numerator = log(S0./K) + (r-y+0.5*sigma.^2).*T;
denominator = sigma.*sqrt(T);
d1 = numerator./denominator;
d2 = d1 - denominator;
cprice = S0 *exp(-y*T).* normcdf(d1) - exp(-r.*T).*K.*normcdf(d2);
end
0 commentaires
Réponses (1)
Walter Roberson
le 3 Déc 2021
S0 = 1433.32; K = 1430; r = 0.0011; T = 30/365; sigma = .15;
x0 = 24.9;
x = fmincon(@(y)blackScholesCallPrice(K,T,S0,r,y,sigma), x0, [], [])
syms Y
X = blackScholesCallPrice( K, T, S0, r, Y, sigma )
dX = diff(X,Y)
bestX = vpasolve(dX == 0)
fplot(dX, [0 1])
limit(dX, Y, 0)
vpa(ans)
limit(dX, Y, inf)
vpa(ans)
function [cprice] = blackScholesCallPrice( K, T, S0, r, y, sigma )
numerator = log(S0./K) + (r-y+0.5*sigma.^2).*T;
denominator = sigma.*sqrt(T);
d1 = numerator./denominator;
d2 = d1 - denominator;
cprice = S0 *exp(-y*T).* normcdf(d1) - exp(-r.*T).*K.*normcdf(d2);
end
So the minimum of the function is at Y = infinity
1 commentaire
Matt J
le 3 Déc 2021
Brian O'Connell's reply moved here:
HI, Thanks.
I am way out of my depth here. The lecturer said the cprice should be the midpoint of 24.1 - 24.9, which is why I put x0 = 24.5.
I think y is supped to equal 0.3. he just wants us to familiarise ourselves with using fmincon. Apparently its better than excel solver, which is where I got the result 0.3 for Y.
regards
brian
Voir également
Catégories
En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!