C++:实现量化使用OIS折扣设置期限结构,然后定价一个简单的5年互换测试实例

C++:实现量化使用OIS折扣设置期限结构,然后定价一个简单的5年互换测试实例

#include 
#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC)
#  include 
#endif
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include #include 
#include using namespace QuantLib;int main(int, char* []) {try {std::cout << std::endl;/****************************  GLOBAL SETTINGS  ****************************/Calendar calendar = TARGET();Date todaysDate(11, December, 2012);Settings::instance().evaluationDate() = todaysDate;todaysDate = Settings::instance().evaluationDate();Integer fixingDays = 2;Date settlementDate = calendar.advance(todaysDate, fixingDays, Days);// must be a business daysettlementDate = calendar.adjust(settlementDate);std::cout << "Today: " << todaysDate.weekday()<< ", " << todaysDate << std::endl;std::cout << "Settlement date: " << settlementDate.weekday()<< ", " << settlementDate << std::endl;/***********************   EONIA CURVE    ***********************/DayCounter termStructureDayCounter = Actual365Fixed();std::vector<ext::shared_ptr<RateHelper> > eoniaInstruments;ext::shared_ptr<Eonia> eonia(new Eonia);// a SimpleQuote instance stores a value which can be manually changed;// other Quote subclasses could read the value from a database// or some kind of data feed.// RateHelpers are built from the quotes, together with// other info depending on the instrument.  Quotes are passed in// relinkable handles which could be relinked to some other// data source later.// depositsstd::map<Natural, ext::shared_ptr<Quote>> depoQuotes = {// settlement days, quote{0, ext::make_shared<SimpleQuote>(0.0004)},{1, ext::make_shared<SimpleQuote>(0.0004)},{2, ext::make_shared<SimpleQuote>(0.0004)}};DayCounter depositDayCounter = Actual360();for (const auto& q : depoQuotes) {auto settlementDays = q.first;auto quote = q.second;auto helper = ext::make_shared<DepositRateHelper>(Handle<Quote>(quote),1 * Days, settlementDays,calendar, Following,false, depositDayCounter);eoniaInstruments.push_back(helper);}// short-term OISstd::map<Period, ext::shared_ptr<Quote>> shortOisQuotes = {{1 * Weeks, ext::make_shared<SimpleQuote>(0.00070)},{2 * Weeks, ext::make_shared<SimpleQuote>(0.00069)},{3 * Weeks, ext::make_shared<SimpleQuote>(0.00078)},{1 * Months, ext::make_shared<SimpleQuote>(0.00074)}};for (const auto& q : shortOisQuotes) {auto tenor = q.first;auto quote = q.second;auto helper = ext::make_shared<OISRateHelper>(2, tenor, Handle<Quote>(quote), eonia);eoniaInstruments.push_back(helper);}// Dated OISstd::map<std::pair<Date, Date>, ext::shared_ptr<Quote>> datedOisQuotes = {{{Date(16, January, 2013), Date(13, February, 2013)}, ext::make_shared<SimpleQuote>( 0.000460)},{{Date(13, February, 2013), Date(13, March, 2013)}, ext::make_shared<SimpleQuote>( 0.000160)},{{Date(13, March, 2013), Date(10, April, 2013)}, ext::make_shared&


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部