#include <optionpair.h>
Inheritance diagram for option_pair:

Definition at line 102 of file optionpair.h.
Public Member Functions | |
| virtual const char * | get_class_name () |
| void | set_null () |
| virtual void | init_calc_derived_attributes () const |
| void | init (const option_pair &rhs) |
| option_pair & | operator= (const option_pair &rhs) |
| option_pair (const option_pair &rhs) | |
| void | init (double S, double K, double Tau, double Alpha=0, double R=0.05, double Sigma=0.2) |
| option_pair (double S=0, double K=0, double Tau=0, double Alpha=0, double R=0.05, double Sigma=0.2) | |
| void | deinit () |
| virtual | ~option_pair () |
| double | get_S () const |
| double | get_K () const |
| double | get_tau () const |
| double | get_alpha () const |
| double | get_r () const |
| double | get_sigma () const |
| double | get_C () const |
| double | get_P () const |
| double | get_dC_dS () const |
| double | get_dP_dS () const |
| double | get_d2C_dS2 () const |
| double | get_d2P_dS2 () const |
| double | get_dC_dtau () const |
| double | get_dP_dtau () const |
| double | get_dC_dsigma () const |
| double | get_dP_dsigma () const |
| bool | get_calc_call () const |
| bool | get_calc_put () const |
| double | get_input_call_price () const |
| double | get_input_put_price () const |
| double | get_C_implied_sigma () const |
| double | get_P_implied_sigma () const |
| void | put_S (double S) |
| void | put_K (double K) |
| void | put_tau (double Tau) |
| void | put_alpha (double Alpha) |
| void | put_r (double R) |
| void | put_sigma (double Sigma) |
| void | init_simple_attributes (const option_pair &rhs) |
| virtual double | call_intrinsic_value () const=0 |
| virtual double | put_intrinsic_value () const=0 |
| virtual double | call_implied_sigma (double call_price, bool show_iterations=false) |
| This is a wrapper for the secant algortihm. This function returns the implied volatility of a call. If there is an error, _C_implied_sigma is set to a NA = not a number, and an exception is thrown. | |
| virtual double | put_implied_sigma (double call_price, bool show_iterations=false) |
| This is a wrapper for the secant algortihm. This function returns the implied volatility of a put. If there is an error, _P_implied_sigma is set to a NA = not a number, and an exception is thrown. | |
| double | C_sigma (double sigma) |
| this function serves as a function pointer for calls to Bisection | |
| double | P_sigma (double sigma) |
| this function serves as a function pointer for calls to Bisection | |
| void | set_call_immediate_exercise () const |
| void | set_put_immediate_exercise () const |
Static Public Member Functions | |
| static const char * | get_error_msg () |
| static int | get_erno () |
| static int | check_attributes (double S, double K, double Tau, double Alpha, double R, double Sigma) |
| static bool | is_NA (const double &tst) |
Static Public Attributes | |
| static const double | NA |
Static Protected Member Functions | |
| static int | strictly_check_attributes (double S, double K, double Tau, double Alpha, double R, double Sigma) |
Protected Attributes | |
| double | _S |
| double | _K |
| double | _tau |
| double | _alpha |
| double | _r |
| double | _sigma |
| double | _C |
| double | _P |
| double | _dC_dS |
| double | _dP_dS |
| double | _d2C_dS2 |
| double | _d2P_dS2 |
| double | _dC_dtau |
| double | _dP_dtau |
| double | _dC_dsigma |
| double | _dP_dsigma |
| bool | _calc_call |
| bool | _calc_put |
| double | _input_call_price |
| double | _input_put_price |
| double | _C_implied_sigma |
| double | _P_implied_sigma |
Static Protected Attributes | |
| static const char * | _error_msg |
| static int | _erno |
Friends | |
| OPTIONPAIRFNC ostream &STDCALL | operator<< (ostream &os, const option_pair &rhs) |
| double option_pair::call_implied_sigma | ( | double | call_price, | |
| bool | show_iterations = false | |||
| ) | [virtual] |
This is a wrapper for the secant algortihm. This function returns the implied volatility of a call. If there is an error, _C_implied_sigma is set to a NA = not a number, and an exception is thrown.
assumes: These key attributes have been defined:
Reimplemented in binomial_option.
Definition at line 134 of file optionpair.cpp.
References _alpha, _C_implied_sigma, _error_msg, _input_call_price, _K, _r, _S, _sigma, _tau, C_sigma(), Bisection_Secant< functor, real >::do_iteration(), Bisection< functor, real >::get_converged(), Bisection< functor, real >::get_x_mid(), NA, stradle_value(), and strictly_check_attributes().
Referenced by binomial_option::call_implied_sigma(), and main().
00137 { 00138 int erno; 00139 00140 erno = strictly_check_attributes( 00141 _S, 00142 _K, 00143 _tau, 00144 _alpha, 00145 _r, 00146 _sigma); 00147 00148 if (erno) { 00149 _C_implied_sigma = NA; 00150 throw std::domain_error( _error_msg); 00151 } 00152 00153 if (call_price < call_intrinsic_value()) { 00154 _C_implied_sigma = NA; 00155 throw std::domain_error( "call_price < call_intrinsic_value in option_pair::call_implied_sigma"); 00156 } 00157 00158 _input_call_price = call_price; 00159 00160 double sigma0, sigma1, price_sigma0, price_sigma1; 00161 00162 sigma0 = .01; 00163 sigma1 = .50; 00164 00165 stradle_value( 00166 sigma0, 00167 sigma1, 00168 price_sigma0, 00169 price_sigma1, 00170 call_price, 00171 *this, 00172 &option_pair::C_sigma, 00173 true, 00174 true, 00175 1, 00176 1e-5, 00177 1e5); 00178 00179 Bisection_Secant< option_pair, double > 00180 solution( 00181 sigma0, 00182 sigma1, 00183 price_sigma0, 00184 price_sigma1, 00185 call_price, 00186 .0001, 00187 .0001, 00188 100, 00189 *this, 00190 &option_pair::C_sigma); 00191 00192 solution.do_iteration( show_iterations); 00193 00194 if (!solution.get_converged()) { 00195 _C_implied_sigma = NA; 00196 throw std::domain_error( "sigma did not converge in option_pair::call_implied_sigma"); 00197 } 00198 00199 return solution.get_x_mid(); 00200 }
| double option_pair::put_implied_sigma | ( | double | put_price, | |
| bool | show_iterations = false | |||
| ) | [virtual] |
This is a wrapper for the secant algortihm. This function returns the implied volatility of a put. If there is an error, _P_implied_sigma is set to a NA = not a number, and an exception is thrown.
assumes: These key attributes have been defined:
Reimplemented in binomial_option.
Definition at line 218 of file optionpair.cpp.
References _alpha, _error_msg, _input_put_price, _K, _P_implied_sigma, _r, _S, _sigma, _tau, Bisection_Secant< functor, real >::do_iteration(), Bisection< functor, real >::get_converged(), Bisection< functor, real >::get_x_mid(), NA, P_sigma(), stradle_value(), and strictly_check_attributes().
Referenced by binomial_option::put_implied_sigma().
00221 { 00222 int erno; 00223 00224 erno = strictly_check_attributes( 00225 _S, 00226 _K, 00227 _tau, 00228 _alpha, 00229 _r, 00230 _sigma); 00231 00232 if (erno) { 00233 _P_implied_sigma = NA; 00234 throw std::domain_error( _error_msg); 00235 } 00236 00237 if (put_price < put_intrinsic_value()) { 00238 _P_implied_sigma = NA; 00239 throw std::domain_error( "put_price < put_intrinsic_value in option_pair::put_implied_sigma"); 00240 } 00241 00242 _input_put_price = put_price; 00243 00244 double sigma0, sigma1, price_sigma0, price_sigma1; 00245 00246 sigma0 = .01; 00247 sigma1 = .50; 00248 00249 stradle_value( 00250 sigma0, 00251 sigma1, 00252 price_sigma0, 00253 price_sigma1, 00254 put_price, 00255 *this, 00256 &option_pair::P_sigma, 00257 true, 00258 true, 00259 1, 00260 1e-5, 00261 1e5); 00262 00263 Bisection_Secant< option_pair, double > 00264 solution( 00265 sigma0, 00266 sigma1, 00267 price_sigma0, 00268 price_sigma1, 00269 put_price, 00270 .0001, 00271 .0001, 00272 100, 00273 *this, 00274 &option_pair::P_sigma); 00275 00276 solution.do_iteration( show_iterations); 00277 00278 if (!solution.get_converged()) { 00279 _P_implied_sigma = NA; 00280 throw std::domain_error( "sigma did not converge in option_pair::put_implied_sigma"); 00281 } 00282 00283 return solution.get_x_mid(); 00284 }
1.5.1