std::string periodStr(QuantLib::Period period)
			{
				std::string str;

				if ( period.units() == Days )
				{
					str = "D";
				}
				else if( period.units() == Weeks )
				{
					str = "W";
				}
				else if( period.units() == Months )
				{
					str = "M";
				}
				else if( period.units() == Years )
				{
					str = "Y";
				}
				else
				{
					//Error
				}

				return str;
			
			}
Esempio n. 2
0
 Euribor365::Euribor365(const shared_ptr<ValueObject>& properties,
                        const std::string& p_inp,
                        const QuantLib::Handle<QuantLib::YieldTermStructure>& h,
                        bool permanent)
 : IborIndex(properties, permanent)
 {
     std::string p = boost::algorithm::to_upper_copy(p_inp);
     if (p=="SW")
         libraryObject_ = boost::shared_ptr<QuantLib::IborIndex>(new
         QuantLib::Euribor365(1*QuantLib::Weeks, h));
     else {
         QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
         pp.normalize();
         libraryObject_ = boost::shared_ptr<QuantLib::IborIndex>(new
             QuantLib::Euribor365(pp, h));
     }
 }
Esempio n. 3
0
void cppToLibrary(const std::string &in, QuantLib::Period &ret) {
    ret = QuantLib::PeriodParser::parse(in);
    ret.normalize();
}
Esempio n. 4
0
 Libor::Libor(const shared_ptr<ValueObject>& properties,
              const QuantLib::Currency& currency,
              const std::string& p,
              const QuantLib::Handle<QuantLib::YieldTermStructure>& h,
              bool permanent) : IborIndex(properties, permanent)
 {
     switch (currency.numericCode()) {
       case 978: // EUR
         if (to_upper_copy(p)=="ON")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorEURLibor(0, h));
         else if (to_upper_copy(p)=="1D")
             QL_FAIL("1D is ambigous: please specify ON, TN, or SN");
         else if (to_upper_copy(p)=="TN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorEURLibor(1, h));
         else if (to_upper_copy(p)=="SN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorEURLibor(2, h));
         else if (to_upper_copy(p)=="SW")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::EURLibor(1*QuantLib::Weeks, h));
         else {
             QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
             pp.normalize();
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::EURLibor(pp, h));
         }
         break;
       case 840: // USD
         if (to_upper_copy(p)=="ON")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorUSDLibor(0, h));
         else if (to_upper_copy(p)=="1D")
             QL_FAIL("1D is ambigous: please specify ON, TN, or SN");
         else if (to_upper_copy(p)=="TN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorUSDLibor(1, h));
         else if (to_upper_copy(p)=="SN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorUSDLibor(2, h));
         else if (to_upper_copy(p)=="SW")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::USDLibor(1*QuantLib::Weeks, h));
         else {
             QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
             pp.normalize();
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::USDLibor(pp, h));
         }
         break;
       case 826: // GBP
         if (to_upper_copy(p)=="ON")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorGBPLibor(0, h));
         else if (to_upper_copy(p)=="1D")
             QL_FAIL("1D is ambigous: please specify ON, TN, or SN");
         else if (to_upper_copy(p)=="TN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorGBPLibor(1, h));
         else if (to_upper_copy(p)=="SN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorGBPLibor(2, h));
         else if (to_upper_copy(p)=="SW")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::GBPLibor(1*QuantLib::Weeks, h));
         else {
             QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
             pp.normalize();
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::GBPLibor(pp, h));
         }
         break;
       case 756: // CHF
         if (to_upper_copy(p)=="ON")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorCHFLibor(0, h));
         else if (to_upper_copy(p)=="1D")
             QL_FAIL("1D is ambigous: please specify ON, TN, or SN");
         else if (to_upper_copy(p)=="TN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorCHFLibor(1, h));
         else if (to_upper_copy(p)=="SN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorCHFLibor(2, h));
         else if (to_upper_copy(p)=="SW")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::CHFLibor(1*QuantLib::Weeks, h));
         else {
             QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
             pp.normalize();
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::CHFLibor(pp, h));
         }
         break;
       case 392: // JPY
         if (to_upper_copy(p)=="ON")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorJPYLibor(0, h));
         else if (to_upper_copy(p)=="1D")
             QL_FAIL("1D is ambigous: please specify ON, TN, or SN");
         else if (to_upper_copy(p)=="TN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorJPYLibor(1, h));
         else if (to_upper_copy(p)=="SN")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::DailyTenorJPYLibor(2, h));
         else if (to_upper_copy(p)=="SW")
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::JPYLibor(1*QuantLib::Weeks, h));
         else {
             QuantLib::Period pp = QuantLib::PeriodParser::parse(p);
             pp.normalize();
             libraryObject_ = shared_ptr<QuantLib::IborIndex>(new
                 QuantLib::JPYLibor(pp, h));
         }
         break;
       default:
           QL_FAIL("Unhandled currency " << currency);
     }
 }