📄 tst_bond_options.cc
字号:
#include <iostream>using namespace std;void test_bondopt_black_scholes(){ cout << "Testing Black Scholes Bond options " << endl; double B=100; double X=100; double r=0.05; double sigma=0.1; double time=1; cout << " call " << bond_option_price_call_zero_black_scholes( B,X,r,sigma,time) ; cout << " put " << bond_option_price_put_zero_black_scholes( B,X,r,sigma,time); cout << endl; vector<double> coupon_times; coupon_times.push_back(0.5); vector<double> coupons; coupons.push_back(1); cout << " price adjusting for coupon " << endl; cout << " call " << bond_option_price_call_coupon_bond_black_scholes( B,X,r,sigma,time,coupon_times,coupons); cout << " put " << bond_option_price_put_coupon_bond_black_scholes( B,X,r,sigma,time,coupon_times,coupons); cout << endl; cout << "Done testing bond options Black Scholes" << endl;};void test_rend_bart_zero_coupon_call() { cout << " Zero Coupon Call " << endl; double X=1000; // exercise price double S=0.15; double M=0.05; // term structure paramters double interest=0.10; // current short interest rate int no_steps=100; double option_maturity=4; double bond_maturity=5; double maturity_payment=1000; X=900; cout << " option on zero coupon bond " << endl; double c = bond_option_price_call_zero_american_rendleman_bartter( X, option_maturity, S, M, interest, bond_maturity, maturity_payment, no_steps); cout << " c = " << c << endl; };/*void test_rend_bart_coupon_call() { double S=0.15; double M=0.05; // term structure paramters double interest=0.10; // current short interest rate int no_steps=5; no_steps = 5; int no_coupons_z=0; double option_maturity=4; double bond_maturity=5; double maturity_payment=1000; double X=1000; no_steps = 5; int no_coupons=5; double bond_coupon_dates[5]={1,2,3,4,5}; double bond_coupons[5]={80,80,80,80,80}; cout << " option on coupon bond, example in Hull " << endl; double c = calc_rendleman_bartter_american_coupon_bond_call(X, option_maturity, S,M,interest,bond_maturity, maturity_payment, no_coupons, bond_coupon_dates, bond_coupons, no_steps); cout << "c = " << c << endl;};*/void test_bond_options(){ test_bondopt_black_scholes(); test_rend_bart_zero_coupon_call();};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -