org.jquantlib.instruments
Class Bond
- java.lang.Object
-
- org.jquantlib.util.LazyObject
-
- org.jquantlib.instruments.Instrument
-
- org.jquantlib.instruments.Bond
-
- All Implemented Interfaces:
- Observable, Observer
- Direct Known Subclasses:
- CmsRateBond, ConvertibleBond, FixedRateBond, FloatingRateBond, ZeroCouponBond
public class Bond extends Instrument
Base bond class Derived classes must fill the uninitialized data members. Warning: Most methods assume that the cash flows are stored sorted by date, the redemption(s) being after any cash flow at the same date. In particular, if there's one single redemption, it must be the last cash flow,
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static interfaceBond.Argumentsbasic bond argumentsstatic classBond.ArgumentsImplstatic interfaceBond.Enginebasic bond price enginestatic classBond.EngineImplThe pricing engine for bondsstatic interfaceBond.Resultsbasic bond resultsstatic classBond.ResultsImplstatic classBond.YieldFinder
-
Constructor Summary
Constructors Constructor and Description Bond(int settlementDays, Calendar calendar, double faceAmount, Date maturityDate, Date issueDate, Leg cashflows)Old constructor for non amortizing bonds.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubleaccruedAmount()Accrued amount at a given date /* The default bond settlement is used if no date is given.doubleaccruedAmount(Date settlement)Calendarcalendar()Legcashflows()doublecleanPrice()Theoretical clean price.doublecleanPrice(double yield, DayCounter dc, Compounding comp, Frequency freq)doublecleanPrice(double yield, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Clean price given a yield and settlement date The default bond settlement is used if no date is given.doublecleanPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq)doublecleanPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Clean price given Z-spread Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given.doubledirtyPrice()Theoretical dirty price.doubledirtyPrice(double yield, DayCounter dc, Compounding comp, Frequency freq)seedirtyPrice()Default null settlement date is used.doubledirtyPrice(double yield, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Dirty price given a yield and settlement date The default bond settlement is used if no date is given.static doubledirtyPriceFromYield(double faceAmount, Leg cashflows, double yield, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlement)doubledirtyPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq)doubledirtyPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq, Date settlement)Dirty price given Z-spread Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given.doublefaceAmount()booleanisExpired()DateissueDate()DatematurityDate()doublenextCoupon()doublenextCoupon(Date settlement)Expected next coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense.doublenotional()Note: new Date() as default argument.doublenotional(Date date)java.util.List<java.lang.Double>notionals()doublepreviousCoupon()doublepreviousCoupon(Date settlement)Previous coupon already paid at a given date /* Expected previous coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense.CashFlowredemption()Legredemptions()DatesettlementDate()DatesettlementDate(Date date)intsettlementDays()doublesettlementValue()Theoretical settlement value.doublesettlementValue(double cleanPrice)Settlement value as a function of the clean price.The default bond settlement date is used for calculation.doubleyield(DayCounter dc, Compounding comp, Frequency freq)doubleyield(DayCounter dc, Compounding comp, Frequency freq, double accuracy, int maxEvaluations)Theoretical bond yield /* The default bond settlement and theoretical price are used for calculation.doubleyield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq)doubleyield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)doubleyield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate, double accuracy)doubleyield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate, double accuracy, int maxEvaluations)Yield given a (clean) price and settlement date The default bond settlement is used if no date is given.-
Methods inherited from class org.jquantlib.instruments.Instrument
errorEstimate, NPV, setPricingEngine
-
Methods inherited from class org.jquantlib.util.LazyObject
addObserver, countObservers, deleteObserver, deleteObservers, freeze, getObservers, notifyObservers, notifyObservers, recalculate, unfreeze, update
-
-
-
-
Constructor Detail
-
Bond
public Bond(int settlementDays, Calendar calendar, double faceAmount, Date maturityDate, Date issueDate, Leg cashflows)Old constructor for non amortizing bonds. /* Warning: The last passed cash flow must be the bond redemption. No other cash flow can have a date later than the redemption date.- Parameters:
settlementDays-calendar-faceAmount-maturityDate-issueDate-cashflows-
-
-
Method Detail
-
settlementDays
public int settlementDays()
-
calendar
public Calendar calendar()
-
faceAmount
public double faceAmount()
-
notionals
public java.util.List<java.lang.Double> notionals()
-
cashflows
public Leg cashflows()
-
redemptions
public Leg redemptions()
-
maturityDate
public Date maturityDate()
-
issueDate
public Date issueDate()
-
notional
public double notional()
Note: new Date() as default argument.
-
notional
public double notional(Date date)
-
redemption
public CashFlow redemption()
-
settlementDate
public Date settlementDate()
-
cleanPrice
public double cleanPrice()
Theoretical clean price. The default bond settlement is used for calculation. Warning: the theoretical price calculated from a flat term structure might differ slightly from the price calculated from the corresponding yield by means of the other overload of this function. If the price from a constant yield is desired, it is advisable to use such other overload.- Returns:
- The clean price of this bond.
-
dirtyPrice
public double dirtyPrice()
Theoretical dirty price. The default bond settlement is used for calculation. Warning: the theoretical price calculated from a flat term structure might differ slightly from the price calculated from the corresponding yield by means of the other overload of this function. If the price from a constant yield is desired, it is advisable to use such other overload.- Returns:
- The dirty price of this bond.
-
settlementValue
public double settlementValue()
Theoretical settlement value. The default bond settlement date is used for calculation.- Returns:
- The theoretical settlement value.
-
settlementValue
public double settlementValue(double cleanPrice)
Settlement value as a function of the clean price.The default bond settlement date is used for calculation.- Parameters:
cleanPrice-- Returns:
- settlementValue
-
yield
public double yield(DayCounter dc, Compounding comp, Frequency freq, double accuracy, int maxEvaluations)
Theoretical bond yield /* The default bond settlement and theoretical price are used for calculation.- Parameters:
dc-comp-freq-
-
yield
public double yield(DayCounter dc, Compounding comp, Frequency freq)
-
cleanPrice
public double cleanPrice(double yield, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Clean price given a yield and settlement date The default bond settlement is used if no date is given.- Parameters:
yield-dc-comp-freq-settlementDate-- Returns:
- clean price
-
cleanPrice
public double cleanPrice(double yield, DayCounter dc, Compounding comp, Frequency freq)
-
dirtyPrice
public double dirtyPrice(double yield, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Dirty price given a yield and settlement date The default bond settlement is used if no date is given.- Parameters:
yield-dc-comp-freq-settlementDate-- Returns:
- dirty price
-
dirtyPrice
public double dirtyPrice(double yield, DayCounter dc, Compounding comp, Frequency freq)seedirtyPrice()Default null settlement date is used.- Parameters:
yield-dc-comp-freq-- Returns:
- dirty price
-
yield
public double yield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate, double accuracy, int maxEvaluations)Yield given a (clean) price and settlement date The default bond settlement is used if no date is given.- Parameters:
cleanPrice-dc-comp-freq-settlementDate-accuracy-maxEvaluations-- Returns:
-
yield
public double yield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq)- Parameters:
cleanPrice-dc-comp-freq-- Returns:
- See Also:
using settlementDate = today, accuracy = 1.0e-8 and maxEvaluation = 100.
-
yield
public double yield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)- Parameters:
cleanPrice-dc-comp-freq-settlementDate-- Returns:
- See Also:
using accuracy = 1.0e-8 and maxEvaluation = 100.
-
yield
public double yield(double cleanPrice, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate, double accuracy)- Parameters:
cleanPrice-dc-comp-freq-settlementDate-accuracy-- Returns:
- See Also:
using maxEvaluation = 100.
-
cleanPriceFromZSpread
public double cleanPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq, Date settlementDate)Clean price given Z-spread Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given. For details on Z-spread refer to: "Credit Spreads Explained", Lehman Brothers European Fixed Income Research - March 2004, D. O'Kane- Parameters:
zSpread-dc-comp-freq-settlementDate-- Returns:
-
cleanPriceFromZSpread
public double cleanPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq)- Parameters:
zSpread-dc-comp-freq-- Returns:
- See Also:
using default(null) settlement date.
-
dirtyPriceFromZSpread
public double dirtyPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq, Date settlement)Dirty price given Z-spread Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given. For details on Z-spread refer to: "Credit Spreads Explained", Lehman Brothers European Fixed Income Research - March 2004, D. O'Kane- Parameters:
zSpread-dc-comp-freq-settlementDate-- Returns:
-
dirtyPriceFromZSpread
public double dirtyPriceFromZSpread(double zSpread, DayCounter dc, Compounding comp, Frequency freq)- Parameters:
zSpread-dc-comp-freq-- Returns:
- See Also:
using today's date as settlement date.
-
accruedAmount
public double accruedAmount()
Accrued amount at a given date /* The default bond settlement is used if no date is given.- Returns:
- The accrued amount. double
-
accruedAmount
public double accruedAmount(Date settlement)
-
isExpired
public boolean isExpired()
- Specified by:
isExpiredin classInstrument- Returns:
trueif the instrument is still tradeable.
-
nextCoupon
public double nextCoupon(Date settlement)
Expected next coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the already-fixed not-yet-paid one. The current bond settlement is used if no date is given.- Returns:
-
nextCoupon
public double nextCoupon()
-
previousCoupon
public double previousCoupon(Date settlement)
Previous coupon already paid at a given date /* Expected previous coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the last paid one. The current bond settlement is used if no date is given.- Returns:
-
previousCoupon
public double previousCoupon()
-
dirtyPriceFromYield
public static double dirtyPriceFromYield(double faceAmount, Leg cashflows, double yield, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlement)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG