Package org.jquantlib.cashflow

Examples of org.jquantlib.cashflow.CashFlow


    public Date maturityDate() {
        return CashFlows.getInstance().maturityDate(floatingLeg_);
    }

    public Date lastFixingDate() {
        final CashFlow lastCoupon = floatingLeg_.get(floatingLeg_.size() - 1); // no linkedlist :-(
        final FloatingRateCoupon lastFloatingCoupon = (FloatingRateCoupon) lastCoupon;
        return lastFloatingCoupon.fixingDate();
    }
View Full Code Here


            notionals_.add(faceAmount);

            notionalSchedule_.add(maturityDate);
            notionals_.add(0.0);

            final CashFlow last = cashflows.last();
            redemptions_.add(last);

            // sort cashflows, except last one
            cashflows.remove(last);
            Collections.sort(cashflows, new EarlierThanCashFlowComparator());
View Full Code Here

    public double accruedAmount(Date settlement) {
        if (settlement==new Date()){
            settlement = settlementDate();
        }
        final CashFlow cf = CashFlows.getInstance().nextCashFlow(cashflows_, settlement);

        if (cf==null)
            return 0.0;

        final Date paymentDate = cf.date();
        boolean firstCouponFound = false;
        /*@Real*/double nominal = Constants.NULL_REAL;
        /*@Time*/double accrualPeriod = Constants.NULL_REAL;
        DayCounter dc = null;

View Full Code Here

        redemptions_.clear();
        for (int i=1; i<notionalSchedule_.size(); ++i) {
            final /*@Real*/ double R = (i < redemptions.length) ? redemptions[i] :
                !(redemptions.length == 0) ? redemptions[redemptions.length-1] : 100.0;
                final /*@Real*/ double amount = (R/100.0)*(notionals_.get(i-1)-notionals_.get(i));
                final CashFlow  redemption = new SimpleCashFlow(amount, notionalSchedule_.get(i));
                cashflows_.add(redemption);
                redemptions_.add(redemption);
        }
        // stable_sort now moves the redemptions to the right places
        // while ensuring that they follow coupons with the same date.
View Full Code Here

        notionals_.add( notional);

        notionalSchedule_.add(date);
        notionals_.add(0.0);

        final CashFlow redemptionCashflow =  new SimpleCashFlow(notional*redemption/100.0, date);
        cashflows_.add(redemptionCashflow);
        redemptions_.add(redemptionCashflow);
    }
View Full Code Here

                // first not-expired coupon
                if (i > 0) {
                    lastDate = cashflows.get(i - 1).date();
                } else {
                    // Coupon coupon = (Coupon )cashflows.get(i);
                    final CashFlow coupon = cashflows.get(i);
                    if (coupon instanceof Coupon && coupon != null) {
                        // if (coupon)
                        lastDate = ((Coupon) coupon).accrualStartDate();
                    } else {
                        lastDate = couponDate.sub(new Period(1, TimeUnit.Years));
View Full Code Here

        QL.require(payoff!=null, "non-striked payoff given"); // TODO: message

        final Date settlementDate = process.riskFreeRate().currentLink().referenceDate();
        double riskless = 0.0;
        for (int i=0; i<a.cashFlow.size(); i++) {
            final CashFlow cashflow = a.cashFlow.get(i);
            if (cashflow.date().gt(settlementDate)) {
                riskless += cashflow.amount() * process.riskFreeRate().currentLink().discount(cashflow.date());
            }
        }

        final double spot = process.stateVariable().currentLink().value() - riskless;
        QL.require(spot > 0.0, "negative or null underlying after subtracting dividends"); // TODO: message

        final /*@DiscountFactor*/ double dividendDiscount = process.dividendYield().currentLink().discount(a.exercise.lastDate());
        final /*@DiscountFactor*/ double riskFreeDiscount = process.riskFreeRate().currentLink().discount(a.exercise.lastDate());
        final double forwardPrice = spot * dividendDiscount / riskFreeDiscount;

        final double variance = process.blackVolatility().currentLink().blackVariance(a.exercise.lastDate(), payoff.strike());
        final BlackCalculator black = new BlackCalculator(payoff, forwardPrice, Math.sqrt(variance), riskFreeDiscount);

        r.value = black.value();
        greeks.delta = black.delta(spot);
        greeks.gamma = black.gamma(spot);

        final DayCounter rfdc  = process.riskFreeRate().currentLink().dayCounter();
        final DayCounter voldc = process.blackVolatility().currentLink().dayCounter();
        /*@Time*/ double t = voldc.yearFraction(process.blackVolatility().currentLink().referenceDate(), a.exercise.lastDate());
        greeks.vega = black.vega(t);

        double delta_theta = 0.0, delta_rho = 0.0;
        for (int i = 0; i < a.cashFlow.size(); i++) {
            final CashFlow cashflow = a.cashFlow.get(i);
            final Date d = cashflow.date();
            if (d.gt(settlementDate)) {
                delta_theta -= cashflow.amount()
                * process.riskFreeRate().currentLink().zeroRate(d, rfdc, Compounding.Continuous, Frequency.Annual).rate()
                * process.riskFreeRate().currentLink().discount(d);
                delta_rho += cashflow.amount() * process.time(d) * process.riskFreeRate().currentLink().discount(t);
            }
        }
        t = process.time(a.exercise.lastDate());
        try {
            greeks.theta = black.theta(spot, t) + delta_theta * black.delta(spot);
 
View Full Code Here

    public Date maturityDate() {
        return CashFlows.getInstance().maturityDate(floatingLeg_);
    }

    public Date lastFixingDate() {
        final CashFlow lastCoupon = floatingLeg_.get(floatingLeg_.size() - 1); // no linkedlist :-(
        final FloatingRateCoupon lastFloatingCoupon = (FloatingRateCoupon) lastCoupon;
        return lastFloatingCoupon.fixingDate();
    }
View Full Code Here

            notionals_.add(faceAmount);

            notionalSchedule_.add(maturityDate.clone());
            notionals_.add(0.0);

            final CashFlow last = cashflows.last();
            redemptions_.add(last);

            // sort cashflows, except last one
            cashflows.remove(last);
            Collections.sort(cashflows, new EarlierThanCashFlowComparator());
View Full Code Here

    public double accruedAmount(Date settlement) {
        if (settlement.isNull()){
            settlement = settlementDate();
        }
        final CashFlow cf = CashFlows.getInstance().nextCashFlow(cashflows_, settlement);

        if (cf==null)
            return 0.0;

        final Date paymentDate = cf.date();
        boolean firstCouponFound = false;
        /*@Real*/double nominal = Constants.NULL_REAL;
        /*@Time*/double accrualPeriod = Constants.NULL_REAL;
        DayCounter dc = null;

View Full Code Here

TOP

Related Classes of org.jquantlib.cashflow.CashFlow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.