Package org.jquantlib.time

Examples of org.jquantlib.time.Date


    public double getDirtyPrice() {
        return settlementValue()/notional(settlementDate())*100.0;
    }

    public Date settlementDate() {
        return settlementDate(new Date());
    }
View Full Code Here


        return settlementDate(new Date());
    }

    //FIXME: intended to return a copy!!!!!!!!!!!!!!!!!!! review!
    public Date settlementDate(final Date date) {
        final Date d = (date.isNull()) ? new Settings().evaluationDate() : date;

        // usually, the settlement is at T+n...
        final Date settlement = calendar_.advance(d, settlementDays_, TimeUnit.Days);
        // ...but the bond won't be traded until the issue date (if given.)


        if (issueDate_.isNull())
            return settlement;
View Full Code Here

     * no date is given.
     *
     * @return The accrued amount. double
     */
    public double accruedAmount() {
        return accruedAmount(new Date());
    }
View Full Code Here

    public double accruedAmount() {
        return accruedAmount(new Date());
    }

    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;

        /*@Rate*/double result = 0.0;

        // QL starts at the next cashflow and only continues to the one after to
        // check that it isn't the same date. Also stop at the penultimate flow. The last flow
        // is not a Coupon
        final int startIndex = cashflows_.indexOf(cf);
        for (final CashFlow flow : Iterables.unmodifiableIterable(cashflows_.listIterator(startIndex))) {
            if (flow.date().ne(paymentDate)) {
                break;
            }
            //TODO: code review: should the last element be excluded?
            final Coupon cp = (Coupon)flow;
            if (cp != null) {
                if (firstCouponFound) {
                    assert(nominal       == cp.nominal() &&
                            accrualPeriod == cp.accrualPeriod() &&
                            //FIXME: implement equals for dayCounters!
                            dc.getClass()            == cp.dayCounter().getClass()):
                                "cannot aggregate accrued amount of two " +
                                "different coupons on "+ paymentDate.toString();
                } else {
                    firstCouponFound = true;
                    nominal = cp.nominal();
                    accrualPeriod = cp.accrualPeriod();
                    dc = cp.dayCounter();
View Full Code Here

    }

    public/* @Real */double cleanPrice(/* @Rate */final double yield,
            final DayCounter dc, final Compounding comp, final Frequency freq) {

        return cleanPrice(yield, dc, comp, freq, new Date());
    }
View Full Code Here

     * @param settlementDate
     * @return
     */
    public/* @Real */double dirtyPrice(/* @Rate */final double yield,
            final DayCounter dc, final Compounding comp, final Frequency freq) {
        return dirtyPrice(yield, dc, comp, freq, new Date());
    }
View Full Code Here

     * @param freq
     * @return
     */
    public/* @Real */double yield(/* @Real */final double cleanPrice,
            final DayCounter dc, final Compounding comp, final Frequency freq) {
        return yield(cleanPrice, dc, comp, freq, new Date(), 1.0e-8, 100);
    }
View Full Code Here

     * @param freq
     * @return
     */
    public/* @Real */double cleanPriceFromZSpread( /* @Spread */final double zSpread,
            final DayCounter dc, final Compounding comp, final Frequency freq) {
        return cleanPriceFromZSpread(zSpread, dc, comp, freq, new Date());
    }
View Full Code Here

     * @param freq
     * @return
     */
    public/* @Real */double dirtyPriceFromZSpread(/* @Spread */final double zSpread,
            final DayCounter dc, final Compounding comp, final Frequency freq) {
        return dirtyPriceFromZSpread(zSpread, dc, comp, freq, new Date());
    }
View Full Code Here

     * given.
     *
     * @return
     */
    public  /* @Rate */double nextCoupon(){
        return nextCoupon(new Date());
    }
View Full Code Here

TOP

Related Classes of org.jquantlib.time.Date

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.