Beispiel #1
0
    void BMASwapRateHelper::initializeDates() {
        // if the evaluation date is not a business day
        // then move to the next business day
        JointCalendar jc(calendar_,
                         iborIndex_->fixingCalendar());
        Date referenceDate = jc.adjust(evaluationDate_);
        earliestDate_ =
            calendar_.advance(referenceDate, settlementDays_ * Days, Following);

        Date maturity = earliestDate_ + tenor_;

        // dummy BMA index with curve/swap arguments
        shared_ptr<BMAIndex> clonedIndex(new BMAIndex(termStructureHandle_));

        Schedule bmaSchedule =
            MakeSchedule().from(earliestDate_).to(maturity)
                          .withTenor(bmaPeriod_)
                          .withCalendar(bmaIndex_->fixingCalendar())
                          .withConvention(bmaConvention_)
                          .backwards();

        Schedule liborSchedule =
            MakeSchedule().from(earliestDate_).to(maturity)
                          .withTenor(iborIndex_->tenor())
                          .withCalendar(iborIndex_->fixingCalendar())
                          .withConvention(iborIndex_->businessDayConvention())
                          .endOfMonth(iborIndex_->endOfMonth())
                          .backwards();

        swap_ = shared_ptr<BMASwap>(new BMASwap(BMASwap::Payer, 100.0,
                                                liborSchedule,
                                                0.75, // arbitrary
                                                0.0,
                                                iborIndex_,
                                                iborIndex_->dayCounter(),
                                                bmaSchedule,
                                                clonedIndex,
                                                bmaDayCount_));
        swap_->setPricingEngine(shared_ptr<PricingEngine>(new
            DiscountingSwapEngine(iborIndex_->forwardingTermStructure())));

        Date d = calendar_.adjust(swap_->maturityDate(), Following);
        Weekday w = d.weekday();
        Date nextWednesday = (w >= 4) ?
            d + (11 - w) * Days :
            d + (4 - w) * Days;
        latestDate_ = clonedIndex->valueDate(
                         clonedIndex->fixingCalendar().adjust(nextWednesday));
    }
    void CdsHelper::initializeDates() {
        protectionStart_ = evaluationDate_ + settlementDays_;
        Date startDate, endDate;
        if(startDate_ == Date()) {
            startDate = calendar_.adjust(protectionStart_,
                                         paymentConvention_);
            if (rule_ == DateGeneration::CDS || rule_ == DateGeneration::CDS2015) { // for standard CDS ..
                // .. the start date is not adjusted
                startDate = protectionStart_;
            }
            // .. and (in any case) the end date rolls by 3 month as
            //  soon as the trade date falls on an IMM date,
            // or the March or September IMM date in case of the CDS2015 rule.
            endDate = protectionStart_ + tenor_;

        } else {
            if(!schedule_.empty()) return; //no need to update schedule
            startDate = calendar_.adjust(startDate_, paymentConvention_);
            endDate = startDate_ + settlementDays_ + tenor_;
        }
        schedule_ =
            MakeSchedule().from(startDate)
                          .to(endDate)
                          .withFrequency(frequency_)
                          .withCalendar(calendar_)
                          .withConvention(paymentConvention_)
                          .withTerminationDateConvention(Unadjusted)
                          .withRule(rule_);
        earliestDate_ = schedule_.dates().front();
        latestDate_   = calendar_.adjust(schedule_.dates().back(),
                                         paymentConvention_);
        if (model_ == CreditDefaultSwap::ISDA)
            ++latestDate_;
    }
Beispiel #3
0
void Organizer::Qualify()
{
	list<Team> teams;
	int iterations = result.size()/2;
	int first, second;
	for (int i = 0; i < iterations; i++)
	{
		first = result.top();
		result.pop();
		second = result.top();
		result.pop();
		if (first > second)
		{
			teams.push_back(matches.top());
			matches.pop();
			loser.push_back(matches.top());
			matches.pop();

		}
		else
		{
			loser.push_back(matches.top());
			matches.pop();
			teams.push_back(matches.top());
			matches.pop();

		}
	}
	if (teams.size() == 1)
	{
		cout << "winner is " <<teams.begin()->GetName()<<endl;
		return;
	}
	MakeSchedule(teams);
}
Beispiel #4
0
 Schedule BMAIndex::fixingSchedule(const Date& start, const Date& end) {
     return MakeSchedule().from(previousWednesday(start))
                          .to(nextWednesday(end))
                          .withFrequency(Weekly)
                          .withCalendar(fixingCalendar())
                          .withConvention(Following)
                          .forwards();
 }
    OvernightIndexedCoupon::OvernightIndexedCoupon(
                    const Date& paymentDate,
                    Real nominal,
                    const Date& startDate,
                    const Date& endDate,
                    const shared_ptr<OvernightIndex>& overnightIndex,
                    Real gearing,
                    Spread spread,
                    const Date& refPeriodStart,
                    const Date& refPeriodEnd,
                    const DayCounter& dayCounter)
    : FloatingRateCoupon(paymentDate, nominal, startDate, endDate,
                         overnightIndex->fixingDays(), overnightIndex,
                         gearing, spread,
                         refPeriodStart, refPeriodEnd,
                         dayCounter, false) {

        // value dates
        Schedule sch = MakeSchedule()
                    .from(startDate)
                    .to(endDate)
                    .withTenor(1*Days)
                    .withCalendar(overnightIndex->fixingCalendar())
                    .withConvention(overnightIndex->businessDayConvention())
                    .backwards();
        valueDates_ = sch.dates();
        QL_ENSURE(valueDates_.size()>=2, "degenerate schedule");

        // fixing dates
        n_ = valueDates_.size()-1;
        if (overnightIndex->fixingDays()==0) {
            fixingDates_ = vector<Date>(valueDates_.begin(),
                                             valueDates_.end()-1);
        } else {
            fixingDates_.resize(n_);
            for (Size i=0; i<n_; ++i)
                fixingDates_[i] = overnightIndex->fixingDate(valueDates_[i]);
        }

        // accrual (compounding) periods
        dt_.resize(n_);
        const DayCounter& dc = overnightIndex->dayCounter();
        for (Size i=0; i<n_; ++i)
            dt_[i] = dc.yearFraction(valueDates_[i], valueDates_[i+1]);

        setPricer(shared_ptr<FloatingRateCouponPricer>(new
                                            OvernightIndexedCouponPricer));
    }
    void CdsHelper::initializeDates() {
        Date protectionStart_ = evaluationDate_ + settlementDays_;
        Date startDate = calendar_.adjust(protectionStart_,
                                          paymentConvention_);
        Date endDate = evaluationDate_ + tenor_;

        schedule_ =
            MakeSchedule().from(startDate)
                          .to(endDate)
                          .withFrequency(frequency_)
                          .withCalendar(calendar_)
                          .withConvention(paymentConvention_)
                          .withTerminationDateConvention(Unadjusted)
                          .withRule(rule_);
        earliestDate_ = schedule_.dates().front();
        latestDate_   = calendar_.adjust(schedule_.dates().back(),
                                         paymentConvention_);
    }