Ejemplo n.º 1
0
DayCounter ComponentMust::eff_convert_basis(std::string basis) const
{
	//cette fonction fait la conversion 
	//de la convention de calcul (basis) de type string lue de XML de MUST

	// daycounter;
	if (basis == "A360")
		return Actual360();

	if (basis == "A365")
		return Actual365Fixed();

	if (basis == "Actual")
		return ActualActual();

	if (basis == "Daily Price")
		return OneDayCounter();

	if (basis == "Business 252")
		return Business252();

	if (basis == "JGB")
		return Actual365NoLeap();

	if (basis == "30/360")
		return Thirty360(Thirty360::EurobondBasis);


	return Thirty360();

}
Ejemplo n.º 2
0
 USDLiborCurve(string tenor, Frequency fixedFrequency=Semiannual):
     CurveBase(boost::shared_ptr<IborIndex>(new USDLibor( Tenor(tenor) )),
               2,
               fixedFrequency,
               ModifiedFollowing,
               Thirty360(Thirty360::European),
               ActualActual(ActualActual::ISDA)
              )
 {}
Ejemplo n.º 3
0
 USDLiborCurve():
     CurveBase(boost::shared_ptr<IborIndex>(new USDLibor(Period(3,Months))),
               2,
               Semiannual,
               ModifiedFollowing,
               Thirty360(Thirty360::European),
               ActualActual(ActualActual::ISDA)
              )
 {}
Ejemplo n.º 4
0
 CPILeg::CPILeg(const Schedule& schedule, const boost::shared_ptr<ZeroInflationIndex>& index,
                const Real baseCPI, const Period& observationLag) :
 schedule_(schedule), index_(index),
 baseCPI_(baseCPI), observationLag_(observationLag),
 paymentDayCounter_(Thirty360()),
 paymentAdjustment_(ModifiedFollowing),
 fixingDays_(std::vector<Natural>(1,0)),
 observationInterpolation_(CPI::AsIndex),
 subtractInflationNominal_(true),
 spreads_(std::vector<Real>(1,0))
 {}
Ejemplo n.º 5
0
 UsdLiborSwapIsdaFixPm::UsdLiborSwapIsdaFixPm(
                             const Period& tenor,
                             const Handle<YieldTermStructure>& h)
 : SwapIndex("UsdLiborSwapIsdaFixPm", // familyName
             tenor,
             2, // settlementDays
             USDCurrency(),
             UnitedStates(UnitedStates::GovernmentBond),
             6*Months, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             boost::shared_ptr<IborIndex>(new USDLibor(3*Months, h))) {}
 MakeYoYInflationCapFloor::MakeYoYInflationCapFloor(
                             YoYInflationCapFloor::Type capFloorType,
                             const ext::shared_ptr<YoYInflationIndex>& index,
                             const Size& length, const Calendar& cal,
                             const Period& observationLag)
 : capFloorType_(capFloorType), length_(length),
   calendar_(cal), index_(index), observationLag_(observationLag),
   strike_(Null<Rate>()), firstCapletExcluded_(false),
   asOptionlet_(false), effectiveDate_(Date()),
   dayCounter_(Thirty360()), roll_(ModifiedFollowing), fixingDays_(0),
   nominal_(1000000.0)
  {}
Ejemplo n.º 7
0
 ChfLiborSwapIsdaFix::ChfLiborSwapIsdaFix(const Period& tenor,
                                          const Handle<YieldTermStructure>& h)
 : SwapIndex("ChfLiborSwapIsdaFix", // familyName
             tenor,
             2, // settlementDays
             CHFCurrency(),
             TARGET(),
             1*Years, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             tenor > 1*Years ?
                 boost::shared_ptr<IborIndex>(new CHFLibor(6*Months, h)) :
                 boost::shared_ptr<IborIndex>(new CHFLibor(3*Months, h))) {}
Ejemplo n.º 8
0
 UsdLiborSwapIsdaFixPm::UsdLiborSwapIsdaFixPm(
                             const Period& tenor,
                             const Handle<YieldTermStructure>& forwarding,
                             const Handle<YieldTermStructure>& discounting)
 : SwapIndex("UsdLiborSwapIsdaFixPm", // familyName
             tenor,
             2, // settlementDays
             USDCurrency(),
             TARGET(),
             6*Months, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             boost::shared_ptr<IborIndex>(new USDLibor(3*Months, forwarding)),
             discounting) {}
Ejemplo n.º 9
0
 EurLiborSwapIsdaFixB::EurLiborSwapIsdaFixB(
                             const Period& tenor,
                             const Handle<YieldTermStructure>& forwarding,
                             const Handle<YieldTermStructure>& discounting)
 : SwapIndex("EurLiborSwapIsdaFixB", // familyName
             tenor,
             2, // settlementDays
             EURCurrency(),
             TARGET(),
             1*Years, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             tenor > 1*Years ?
                 shared_ptr<IborIndex>(new EURLibor(6*Months, forwarding)) :
                 shared_ptr<IborIndex>(new EURLibor(3*Months, forwarding)),
             discounting) {}
Ejemplo n.º 10
0
 SwapType(// Fixed Leg
           Frequency fixedLegFrequency = Semiannual,
           DayCounter fixedLegDayCounter = Thirty360(Thirty360::European),
           BusinessDayConvention fixedLegConvention = ModifiedFollowing,
           // floating leg 
           Frequency floatingLegFrequency = Quarterly,
           DayCounter floatingLegDayCounter = Actual360(),
           BusinessDayConvention floatingLegConvention = ModifiedFollowing,
           Calendar calendar = TARGET()
           ) :
 _fixedLegFrequency(fixedLegFrequency),
 _fixedLegDayCounter(fixedLegDayCounter),
 _fixedLegConvention(fixedLegConvention),
 _floatingLegFrequency(floatingLegFrequency),
 _floatingLegDayCounter(floatingLegDayCounter),
 _floatingLegConvention(floatingLegConvention),
 _calendar(calendar) 
 {
     _indexBase = IndexBase<T>(floatingLegFrequency);
 }
Ejemplo n.º 11
0
    MakeVanillaSwap::operator ext::shared_ptr<VanillaSwap>() const {

        Date startDate;
        if (effectiveDate_ != Date())
            startDate = effectiveDate_;
        else {
            Date refDate = Settings::instance().evaluationDate();
            // if the evaluation date is not a business day
            // then move to the next business day
            refDate = floatCalendar_.adjust(refDate);
            Date spotDate = floatCalendar_.advance(refDate,
                                                   settlementDays_*Days);
            startDate = spotDate+forwardStart_;
            if (forwardStart_.length()<0)
                startDate = floatCalendar_.adjust(startDate,
                                                  Preceding);
            else
                startDate = floatCalendar_.adjust(startDate,
                                                  Following);
        }

        Date endDate = terminationDate_;
        if (endDate == Date()) {
            if (floatEndOfMonth_)
                endDate = floatCalendar_.advance(startDate,
                                                 swapTenor_,
                                                 ModifiedFollowing,
                                                 floatEndOfMonth_);
            else
                endDate = startDate + swapTenor_;
        }

        const Currency& curr = iborIndex_->currency();
        Period fixedTenor;
        if (fixedTenor_ != Period())
            fixedTenor = fixedTenor_;
        else {
            if ((curr == EURCurrency()) ||
                (curr == USDCurrency()) ||
                (curr == CHFCurrency()) ||
                (curr == SEKCurrency()) ||
                (curr == GBPCurrency() && swapTenor_ <= 1 * Years))
                fixedTenor = Period(1, Years);
            else if ((curr == GBPCurrency() && swapTenor_ > 1 * Years) ||
                (curr == JPYCurrency()) ||
                (curr == AUDCurrency() && swapTenor_ >= 4 * Years))
                fixedTenor = Period(6, Months);
            else if ((curr == HKDCurrency() ||
                     (curr == AUDCurrency() && swapTenor_ < 4 * Years)))
                fixedTenor = Period(3, Months);
            else
                QL_FAIL("unknown fixed leg default tenor for " << curr);
        }

        Schedule fixedSchedule(startDate, endDate,
                               fixedTenor, fixedCalendar_,
                               fixedConvention_,
                               fixedTerminationDateConvention_,
                               fixedRule_, fixedEndOfMonth_,
                               fixedFirstDate_, fixedNextToLastDate_);

        Schedule floatSchedule(startDate, endDate,
                               floatTenor_, floatCalendar_,
                               floatConvention_,
                               floatTerminationDateConvention_,
                               floatRule_, floatEndOfMonth_,
                               floatFirstDate_, floatNextToLastDate_);

        DayCounter fixedDayCount;
        if (fixedDayCount_ != DayCounter())
            fixedDayCount = fixedDayCount_;
        else {
            if (curr == USDCurrency())
                fixedDayCount = Actual360();
            else if (curr == EURCurrency() || curr == CHFCurrency() ||
                     curr == SEKCurrency())
                fixedDayCount = Thirty360(Thirty360::BondBasis);
            else if (curr == GBPCurrency() || curr == JPYCurrency() ||
                     curr == AUDCurrency() || curr == HKDCurrency())
                fixedDayCount = Actual365Fixed();
            else
                QL_FAIL("unknown fixed leg day counter for " << curr);
        }

        Rate usedFixedRate = fixedRate_;
        if (fixedRate_ == Null<Rate>()) {
            VanillaSwap temp(type_, nominal_,
                             fixedSchedule,
                             0.0, // fixed rate
                             fixedDayCount,
                             floatSchedule, iborIndex_,
                             floatSpread_, floatDayCount_);
            if (engine_ == 0) {
                Handle<YieldTermStructure> disc =
                                        iborIndex_->forwardingTermStructure();
                QL_REQUIRE(!disc.empty(),
                           "null term structure set to this instance of " <<
                           iborIndex_->name());
                bool includeSettlementDateFlows = false;
                ext::shared_ptr<PricingEngine> engine(new
                    DiscountingSwapEngine(disc, includeSettlementDateFlows));
                temp.setPricingEngine(engine);
            } else
                temp.setPricingEngine(engine_);

            usedFixedRate = temp.fairRate();
        }

        ext::shared_ptr<VanillaSwap> swap(new
            VanillaSwap(type_, nominal_,
                        fixedSchedule,
                        usedFixedRate, fixedDayCount,
                        floatSchedule,
                        iborIndex_, floatSpread_, floatDayCount_));

        if (engine_ == 0) {
            Handle<YieldTermStructure> disc =
                                    iborIndex_->forwardingTermStructure();
            bool includeSettlementDateFlows = false;
            ext::shared_ptr<PricingEngine> engine(new
                DiscountingSwapEngine(disc, includeSettlementDateFlows));
            swap->setPricingEngine(engine);
        } else
            swap->setPricingEngine(engine_);

        return swap;
    }