Пример #1
0
 Rate BMAIndex::forecastFixing(const Date& fixingDate) const {
     QL_REQUIRE(!termStructure_.empty(),
                "null term structure set to this instance of " << name());
     Date start = fixingCalendar().advance(fixingDate, 1, Days);
     Date end = maturityDate(start);
     return termStructure_->forwardRate(start, end,
                                        dayCounter_,
                                        Simple);
 }
Пример #2
0
Rate IborIndex::forecastFixing(const Date& fixingDate) const {
    Date d1 = valueDate(fixingDate);
    Date d2 = maturityDate(d1);
    Time t = dayCounter_.yearFraction(d1, d2);
    QL_REQUIRE(t>0.0,
               "\n cannot calculate forward rate between " <<
               d1 << " and " << d2 <<
               ":\n non positive time (" << t <<
               ") using " << dayCounter_.name() << " daycounter");
    return forecastFixing(d1, d2, t);
}
Пример #3
0
 Real RiskyFloatingBond::notional(Date date) const {
     if (date > maturityDate())
         return 0.0;
     Real ntl = notionals_.front();
     for (Size i = 0; i < schedule_.size(); i++) {
         if (i < notionals_.size() && schedule_[i] <= date)
             ntl = notionals_[i];
         else
             break;
     }
     return ntl;
 }
Пример #4
0
 Rate IborIndex::forecastFixing(const Date& fixingDate) const {
     QL_REQUIRE(!termStructure_.empty(),
                "null term structure set to this instance of " << name());
     Date fixingValueDate = valueDate(fixingDate);
     Date endValueDate = maturityDate(fixingValueDate);
     DiscountFactor fixingDiscount =
         termStructure_->discount(fixingValueDate);
     DiscountFactor endDiscount =
         termStructure_->discount(endValueDate);
     Time fixingPeriod =
         dayCounter_.yearFraction(fixingValueDate, endValueDate);
     return (fixingDiscount/endDiscount-1.0) / fixingPeriod;
 }
Пример #5
0
 bool RiskyBond::isExpired() const {
     return detail::simple_event(maturityDate()).hasOccurred();
 }
        /* enregistre une jambe à taux flottant */
DLLEXPORT xloper * xlInitiateFloatLegUnitedStates (const char * objectID_,
                                                   const double * effectiveDate_,
                                                   xloper * firstCouponDate_,
                                                   xloper * lastCouponDate_,
                                                   const double * maturityDate_,
                                                   xloper * notional_,
                                                   const char * indexId_,
                                                   xloper * frequency_,
                                                   xloper * daycounter_,
                                                   xloper * spread_,
                                                   xloper * trigger_) {

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall(
        new ObjectHandler::FunctionCall("xlInitiatefloatLegUnitedStates")) ;

     try {


        QL_ENSURE(! functionCall->calledByFunctionWizard(), "") ;


            // vérification des codes erreur
        ObjectHandler::validateRange(trigger_, "trigger") ;

        ObjectHandler::validateRange(firstCouponDate_, "first Coupon Date") ;

        ObjectHandler::validateRange(lastCouponDate_, "last Coupon Date") ;

        ObjectHandler::validateRange(notional_, "notional") ;

        ObjectHandler::validateRange(frequency_, "frequency") ;

        ObjectHandler::validateRange(daycounter_, "daycounter") ;

        ObjectHandler::validateRange(spread_, "spread") ;

            // Création des oper
        ObjectHandler::ConvertOper myOper1(* firstCouponDate_),
                                   myOper2(* lastCouponDate_),
                                   myOper3(* notional_),
                                   myOper4(* frequency_),
                                   myOper5(* daycounter_),
                                   myOper6(* spread_) ;

            // création des dates et contrôles sur les dates intermédiaires
        QuantLib::Date effectiveDate(QuantLib::Date(static_cast<QuantLib::BigInteger>(* effectiveDate_))) ;

        QuantLib::Date maturityDate(QuantLib::Date(static_cast<QuantLib::BigInteger>(* maturityDate_))) ;

        QuantLib::Date firstCouponDate(myOper1.missing() ? 
            QuantLib::Date() : 
            QuantLib::Date(static_cast<QuantLib::BigInteger>(myOper1))) ;

        QuantLib::Date lastCouponDate(myOper2.missing() ? 
            QuantLib::Date() : 
            QuantLib::Date(static_cast<QuantLib::BigInteger>(myOper2))) ;

        QuantLib::Real notional(myOper3.missing() ? 
            100.0 : 
            static_cast<QuantLib::Real>(myOper3)) ;

        QuantLib::Frequency frequency(myOper4.missing() ? 
            QuantLib::Quarterly : 
            ObjectHandler::frequencyFactory()(static_cast<std::string>(myOper4))) ;

        QuantLib::DayCounter daycounter(myOper5.missing() ? 
            QuantLib::Actual360() : 
            ObjectHandler::daycountFactory()(static_cast<std::string>(myOper5))) ;

		QuantLib::Spread spread(myOper6.missing() ? 
            0.0 : 
            static_cast<QuantLib::Spread>(myOper6)) ;


            // on récupère l'index libor
        OH_GET_REFERENCE(iborIndexPtr, 
                         std::string(indexId_), 
                         QuantLibAddin::iborIndexObject,
                         QuantLib::IborIndex)    


            // Construction du value object
        boost::shared_ptr<QuantLibAddin::ValueObjects::floatLegUnitedStatesValueObject> myLegValueObject(
            new QuantLibAddin::ValueObjects::floatLegUnitedStatesValueObject(objectID_,
                                                                   true)) ;

            // instanciation de l'instrument
        boost::shared_ptr<QuantLibAddin::floatLegUnitedStatesObject> myLegObject(
            new QuantLibAddin::floatLegUnitedStatesObject(myLegValueObject,
                                                effectiveDate,
                                                firstCouponDate,
                                                lastCouponDate,
                                                maturityDate,
                                                iborIndexPtr,
                                                2,
                                                frequency,
                                                daycounter,
                                                notional,
                                                spread,
                                                QuantLib::ModifiedFollowing,
                                                QuantLib::ModifiedFollowing, 
                                                true, true)) ;


            // stockage de l'objet
        std::string returnValue =
            ObjectHandler::RepositoryXL::instance().storeObject(objectID_, 
                                                                myLegObject, 
                                                                true) ; // on force la réécriture

        static XLOPER returnOper ;

        ObjectHandler::scalarToOper(returnValue, returnOper) ;

        return & returnOper ;

    } catch (std::exception & e) {

            ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall) ;

            static XLOPER returnOper ;

            ObjectHandler::scalarToOper(e.what(), returnOper) ;

            return & returnOper ;

    }

} ;
        /* enregistre un TIPS */
DLLEXPORT xloper * xlInitiateAussieNote (const char * objectID_,
                                         const double * issueDate_,
                                         xloper * effectiveDate_,
                                         xloper * firstCouponDate_,
                                         xloper * lastCouponDate_,
                                         const double * maturityDate_,
                                         const double * couponRate_,
                                         xloper * trigger_) {

    boost::shared_ptr<ObjectHandler::FunctionCall> functionCall(
        new ObjectHandler::FunctionCall("xlInitiateAussieNote")) ;

    try {


            QL_ENSURE(! functionCall->calledByFunctionWizard(), "") ;

                // trigger pour provoquer le recalcul
            ObjectHandler::validateRange(trigger_, "trigger") ;

            ObjectHandler::validateRange(effectiveDate_, "effective Date") ;

            ObjectHandler::validateRange(firstCouponDate_, "first Coupon Date") ;

            ObjectHandler::validateRange(lastCouponDate_, "last Coupon Date") ;


            ObjectHandler::ConvertOper myOper1(* effectiveDate_) ;

            ObjectHandler::ConvertOper myOper2(* firstCouponDate_) ;

            ObjectHandler::ConvertOper myOper3(* lastCouponDate_) ;


            QuantLib::Date issueDate(static_cast<QuantLib::BigInteger>(* issueDate_)) ;

            QuantLib::Date effectiveDate(myOper1.missing() ? 
                issueDate : 
                static_cast<QuantLib::Date>(myOper1)) ;

            QuantLib::Date firstCouponDate(myOper2.missing() ? 
                QuantLib::Date() : 
                static_cast<QuantLib::Date>(myOper2)) ;

            QuantLib::Date lastCouponDate(myOper3.missing() ? 
                QuantLib::Date() : 
                static_cast<QuantLib::Date>(myOper3)) ;

            QuantLib::Date maturityDate(static_cast<QuantLib::BigInteger>(* maturityDate_)) ;
                                         

                // Construction du value object
            boost::shared_ptr<QuantLibAddin::ValueObjects::australianTreasuryNoteValueObject> myBondValueObject(
				new QuantLibAddin::ValueObjects::australianTreasuryNoteValueObject(objectID_,
                                                                       true)) ;

                // instanciation de l'instrument
            boost::shared_ptr<QuantLibAddin::australianTreasuryNoteObject> myBondObject(
				new QuantLibAddin::australianTreasuryNoteObject(myBondValueObject,
                                                    issueDate,
                                                    effectiveDate,
                                                    firstCouponDate,
                                                    lastCouponDate,
                                                    maturityDate,
                                                    QuantLib::Rate(* couponRate_),
                                                    true)) ;

                // stockage de l'objet
            std::string returnValue =
                ObjectHandler::RepositoryXL::instance().storeObject(objectID_, 
                                                                    myBondObject, 
                                                                    true) ; // on force la réécriture

            static XLOPER returnOper ;
            ObjectHandler::scalarToOper(returnValue, returnOper) ;
            return & returnOper ;

        } catch (std::exception & e) {

                ObjectHandler::RepositoryXL::instance().logError(e.what(), functionCall) ;
                static XLOPER returnOper ;
                ObjectHandler::scalarToOper(e.what(), returnOper) ;
                return & returnOper ;

			}

    } ;
Пример #8
0
    boost::shared_ptr<ObjectHandler::Object> create_fixedLegAustralia(
        const boost::shared_ptr<ObjectHandler::ValueObject> & valueObject) {

            //convert input datatypes to C++ datatypes
        QuantLib::DayCounter legDaycounter =
            ObjectHandler::daycountFactory()(ObjectHandler::convert2<std::string>(valueObject->getProperty("DayCounter"))) ;

        QuantLib::Compounding legCompounding =
            ObjectHandler::convert2<QuantLib::Compounding>(valueObject->getProperty("Compounding")) ;

        QuantLib::Frequency legFrequency =
            ObjectHandler::convert2<QuantLib::Frequency>(valueObject->getProperty("Frequency")) ;

        QuantLib::Date effectiveDate(
            ObjectHandler::convert2<QuantLib::BigInteger>(valueObject->getProperty("effectiveDate"))) ;

        QuantLib::Date firstCouponDate(
            ObjectHandler::convert2<QuantLib::BigInteger>(valueObject->getProperty("firstCouponDate"))) ;

        QuantLib::Date lastCouponDate(
            ObjectHandler::convert2<QuantLib::BigInteger>(valueObject->getProperty("lastCouponDate"))) ;

        QuantLib::Date maturityDate(
            ObjectHandler::convert2<QuantLib::BigInteger>(valueObject->getProperty("maturityDate"))) ;

        QuantLib::BusinessDayConvention paymentConvention =
            ObjectHandler::convert2<QuantLib::BusinessDayConvention >(valueObject->getProperty("paymentConvention")) ;

        QuantLib::BusinessDayConvention terminationPaymentConvention =
            ObjectHandler::convert2<QuantLib::BusinessDayConvention>(valueObject->getProperty("terminationPaymentConvention")) ;

        bool permanent =
            ObjectHandler::convert2<bool>(valueObject->getProperty("permanent")) ;
        
        bool endOfMonth =
            ObjectHandler::convert2<bool>(valueObject->getProperty("endOfMonth")) ;

        double fixedCouponRate =
            ObjectHandler::convert2<double>(valueObject->getProperty("fixedCouponRate")) ;

        double notional =
            ObjectHandler::convert2<double>(valueObject->getProperty("notional")) ;

        boost::shared_ptr<ObjectHandler::Object> object(
            new QuantLibAddin::fixedLegAustraliaObject(
                boost::dynamic_pointer_cast<QuantLibAddin::ValueObjects::fixedLegAustraliaValueObject>(valueObject),
                    effectiveDate,
                    firstCouponDate,
                    lastCouponDate,
                    maturityDate,
                    fixedCouponRate,
                    legFrequency,
                    legDaycounter,
                    legCompounding,
                    notional,
                    paymentConvention,
                    terminationPaymentConvention,
                    endOfMonth,
                    permanent)) ;

        return object ;


    }