void PriceDisplayBoardWindowBoxList::mousePressEvent(QMouseEvent * event)
{
	if (event->button() == Qt::RightButton)
	{
		QMenu * popupMenu = new QMenu(this);
		QString menuStyle = "QMenu { font-size:18px; color:white; background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #333333);}" ;
		popupMenu->setStyleSheet(menuStyle);

		popupMenu->addAction(tr("&Add"),this,SLOT(Add()),QKeySequence(Qt::CTRL + Qt::Key_A));
		popupMenu->addSeparator();

		QAction* highestLowest = new QAction(tr("&HighestLowest"), this);
		connect(highestLowest,SIGNAL(triggered()), this, SLOT(HighestLowest()));
		QAction* preClose = new QAction(tr("&PreClose"), this);
		connect(preClose,SIGNAL(triggered()), this, SLOT(PreClose()));
		QAction* interestRate = new QAction(tr("&InterestRate"), this);
		connect(interestRate,SIGNAL(triggered()), this, SLOT(InterestRate()));

		QActionGroup* infoGroup = new QActionGroup(this);
		infoGroup->addAction(highestLowest);
		infoGroup->addAction(preClose);
		infoGroup->addAction(interestRate);

		QMenu* marketInfo = popupMenu->addMenu(tr("&MarketInformations"));
		marketInfo->addAction(highestLowest);
		marketInfo->addAction(preClose);
		marketInfo->addAction(interestRate);

		popupMenu->exec(event->globalPos());
	}
}
Esempio n. 2
0
 FixedRateLeg& FixedRateLeg::withCouponRates(Rate rate,
                                             const DayCounter& dc,
                                             Compounding comp,
                                             Frequency freq) {
     couponRates_.resize(1);
     couponRates_[0] = InterestRate(rate, dc, comp, freq);
     return *this;
 }
Esempio n. 3
0
 FixedRateLeg& FixedRateLeg::withCouponRates(const vector<Rate>& rates,
                                             const DayCounter& dc,
                                             Compounding comp,
                                             Frequency freq) {
     couponRates_.resize(rates.size());
     for (Size i=0; i<rates.size(); ++i)
         couponRates_[i] = InterestRate(rates[i], dc, comp, freq);
     return *this;
 }
 void ForwardRateAgreement::performCalculations() const {
     Date fixingDate = calendar_.advance(valueDate_,
         -static_cast<Integer>(settlementDays_), Days);
     forwardRate_ = InterestRate(index_->fixing(fixingDate),
                                 index_->dayCounter(),
                                 Simple, Once);
     underlyingSpotValue_ = spotValue();
     underlyingIncome_    = 0.0;
     Forward::performCalculations();
 }
Esempio n. 5
0
 FixedRateCoupon::FixedRateCoupon(const Date& paymentDate,
                                  Real nominal,
                                  Rate rate,
                                  const DayCounter& dayCounter,
                                  const Date& accrualStartDate,
                                  const Date& accrualEndDate,
                                  const Date& refPeriodStart,
                                  const Date& refPeriodEnd,
                                  const Date& exCouponDate)
 : Coupon(paymentDate, nominal, accrualStartDate, accrualEndDate,
          refPeriodStart, refPeriodEnd, exCouponDate),
   rate_(InterestRate(rate, dayCounter, Simple, Annual)) {}
    FixedCoupon::FixedCoupon(Real nominal,
                           const Date& startDate,
                           const Date& endDate,
                           Natural fixingDays,
                           Real fixedRate,
						   const DayCounter& dayCounter)
    : MonteCoupon(nominal,startDate, endDate,fixingDays,dayCounter) ,
		rate_(InterestRate(fixedRate, dayCounter, Simple, Annual))
				  
    {
		
        registerWith(Settings::instance().evaluationDate());
		
    }
    ForwardRateAgreement::ForwardRateAgreement(
                           const Date& valueDate,
                           const Date& maturityDate,
                           Position::Type type,
                           Rate strikeForwardRate,
                           Real notionalAmount,
                           const boost::shared_ptr<IborIndex>& index,
                           const Handle<YieldTermStructure>& discountCurve)
    : Forward(index->dayCounter(), index->fixingCalendar(),
              index->businessDayConvention(),
              index->fixingDays(), boost::shared_ptr<Payoff>(),
              valueDate, maturityDate, discountCurve),
      fraType_(type), notionalAmount_(notionalAmount), index_(index) {

        QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive");

        // do I adjust this ?
        // valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_);
        Date fixingDate = calendar_.advance(valueDate_,
            -static_cast<Integer>(settlementDays_), Days);
        forwardRate_ = InterestRate(index->fixing(fixingDate),
                                    index->dayCounter(),
                                    Simple, Once);
        strikeForwardRate_ = InterestRate(strikeForwardRate,
                                          index->dayCounter(),
                                          Simple, Once);
        Real strike = notionalAmount_ *
                      strikeForwardRate_.compoundFactor(valueDate_,
                                                        maturityDate_);
        payoff_ = boost::shared_ptr<Payoff>(new ForwardTypePayoff(fraType_,
                                                                  strike));
        // incomeDiscountCurve_ is irrelevant to an FRA
        incomeDiscountCurve_ = discountCurve_;
        // income is irrelevant to FRA - set it to zero
        underlyingIncome_ = 0.0;
        registerWith(index_);
    }
Esempio n. 8
0
    InterestRate InterestRate::impliedRate(Real compound,
                                           const DayCounter& resultDC,
                                           Compounding comp,
                                           Frequency freq,
                                           Time t) {

        QL_REQUIRE(compound>0.0, "positive compound factor required");

        Rate r;
        if (compound==1.0) {
            QL_REQUIRE(t>=0.0, "non negative time (" << t << ") required");
            r = 0.0;
        } else {
            QL_REQUIRE(t>0.0, "positive time (" << t << ") required");
            switch (comp) {
              case Simple:
                r = (compound - 1.0)/t;
                break;
              case Compounded:
                r = (std::pow(compound, 1.0/(Real(freq)*t))-1.0)*Real(freq);
                break;
              case Continuous:
                r = std::log(compound)/t;
                break;
              case SimpleThenCompounded:
                if (t<=1.0/Real(freq))
                    r = (compound - 1.0)/t;
                else
                    r = (std::pow(compound, 1.0/(Real(freq)*t))-1.0)*Real(freq);
                break;
              default:
                QL_FAIL("unknown compounding convention ("
                        << Integer(comp) << ")");
            }
        }
        return InterestRate(r, resultDC, comp, freq);
    }
Esempio n. 9
0
    void BlackStyleSwaptionEngine<Spec>::calculate() const {
        static const Spread basisPoint = 1.0e-4;

        Date exerciseDate = arguments_.exercise->date(0);

        // the part of the swap preceding exerciseDate should be truncated
        // to avoid taking into account unwanted cashflows
        VanillaSwap swap = *arguments_.swap;

        Rate strike = swap.fixedRate();

        // using the discounting curve
        // swap.iborIndex() might be using a different forwarding curve
        swap.setPricingEngine(boost::shared_ptr<PricingEngine>(new
            DiscountingSwapEngine(discountCurve_, false)));
        Rate atmForward = swap.fairRate();

        // Volatilities are quoted for zero-spreaded swaps.
        // Therefore, any spread on the floating leg must be removed
        // with a corresponding correction on the fixed leg.
        if (swap.spread()!=0.0) {
            Spread correction = swap.spread() *
                std::fabs(swap.floatingLegBPS()/swap.fixedLegBPS());
            strike -= correction;
            atmForward -= correction;
            results_.additionalResults["spreadCorrection"] = correction;
        } else {
            results_.additionalResults["spreadCorrection"] = 0.0;
        }
        results_.additionalResults["strike"] = strike;
        results_.additionalResults["atmForward"] = atmForward;

        // using the discounting curve
        swap.setPricingEngine(boost::shared_ptr<PricingEngine>(
                           new DiscountingSwapEngine(discountCurve_, false)));
        Real annuity;
        switch(arguments_.settlementType) {
          case Settlement::Physical: {
              annuity = std::fabs(swap.fixedLegBPS())/basisPoint;
              break;
          }
          case Settlement::Cash: {
              const Leg& fixedLeg = swap.fixedLeg();
              boost::shared_ptr<FixedRateCoupon> firstCoupon =
                  boost::dynamic_pointer_cast<FixedRateCoupon>(fixedLeg[0]);
              DayCounter dayCount = firstCoupon->dayCounter();
              Real fixedLegCashBPS =
                  CashFlows::bps(fixedLeg,
                                 InterestRate(atmForward, dayCount, Compounded, Annual),
                                 false, discountCurve_->referenceDate()) ;
              annuity = std::fabs(fixedLegCashBPS/basisPoint);
              break;
          }
          default:
            QL_FAIL("unknown settlement type");
        }
        results_.additionalResults["annuity"] = annuity;

        // the swap length calculation might be improved using the value date
        // of the exercise date
        Time swapLength =  vol_->swapLength(exerciseDate,
                                                   arguments_.floatingPayDates.back());
        results_.additionalResults["swapLength"] = swapLength;

        Real variance = vol_->blackVariance(exerciseDate,
                                                   swapLength,
                                                   strike);

        // once the deprecated methods allowing to override the displacement
        // are gone, we can avoid this and directly read the displacement
        // from the volatility structure
        Real displacement = displacement_ == Null<Real>()
                                ? vol_->shift(exerciseDate, swapLength)
                                : displacement_;

        Real stdDev = std::sqrt(variance);
        results_.additionalResults["stdDev"] = stdDev;
        Option::Type w = (arguments_.type==VanillaSwap::Payer) ?
                                                Option::Call : Option::Put;
        results_.value = Spec().value(w, strike, atmForward, stdDev, annuity,
                                                                displacement);

        Time exerciseTime = vol_->timeFromReference(exerciseDate);
        results_.additionalResults["vega"] = Spec().vega(
            strike, atmForward, stdDev, exerciseTime, annuity, displacement);
    }