hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.Instrument.Bond

Synopsis

Types

Bond hierarchy

type GenBond b = GenInstrument (AnyOf CBond' b) Source #

type Bond = GenBond CBond Source #

An Instrument; see the hierarchy under GenInstrument.

type GenFixedRateBond fb = GenBond (AnyOf CFixedRateBond' fb) Source #

type FixedRateBond = GenFixedRateBond CFixedRateBond Source #

A Bond; see the hierarchy under GenInstrument.

type BTP = GenFixedRateBond CBTP Source #

A FixedRateBond; see the hierarchy under GenInstrument.

type CPIBond = GenBond CCPIBond Source #

A Bond; see the hierarchy under GenInstrument.

type CallableBond = GenBond CCallableBond Source #

A Bond; see the hierarchy under GenInstrument.

type ConvertibleBond = GenBond CConvertibleBond Source #

A Bond; see the hierarchy under GenInstrument.

Configuration

data CPIInterpolationType Source #

Constructors

CPIFlat 
CPILinear 

Instances

Instances details
Bounded CPIInterpolationType Source # 
Instance details

Defined in QuantLib.Internal.Common

Enum CPIInterpolationType Source #

How an overnight leg observes its index fixings. Shared by every overnight-leg producer: the swap constructors, the OIS rate helpers, and the cross-currency swaps. lookbackDays is Nothing for upstream's Null default, meaning the index's own fixing days.

Declared here rather than in a topical module because its producers span QuantLib.Instrument.Swap and QuantLib.TermStructure.Yield, whose build order cannot accommodate one importing the other.

Instance details

Defined in QuantLib.Internal.Common

Read CPIInterpolationType Source # 
Instance details

Defined in QuantLib.Internal.Common

Show CPIInterpolationType Source # 
Instance details

Defined in QuantLib.Internal.Common

Eq CPIInterpolationType Source # 
Instance details

Defined in QuantLib.Internal.Common

data Discounting y Source #

Where discount factors come from.

data BpsDiscounting y Source #

Discounting restricted to the cases bps supports: upstream has no Z-spreaded bps.

Constructors

Hierarchy conversion

Bonds and baskets

bond Source #

Arguments

:: Word 
-> Calendar 
-> Maybe Day

issueDate

-> GenLeg l

coupons

-> IO Bond 

constructor for amortizing or non-amortizing bonds. Redemptions and maturity are calculated from the coupon data, if available. Therefore, redemptions must not be included in the passed cash flows.

fixedRateBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Schedule

schedule

-> NonEmpty Double

coupons

-> DayCounter

accrualDayCounter

-> BusinessDayConvention

paymentConvention

-> Double

redemption

-> Maybe Day

issueDate

-> Calendar

paymentCalendar

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> DayCounter

firstPeriodDayCounter

-> IO FixedRateBond 

generic compounding and frequency InterestRate coupons

btp Source #

Arguments

:: Day

maturityDate

-> Double

fixedRate

-> Maybe Day

startDate

-> Maybe Day

issueDate

-> IO BTP 

Italian BTP (Buono Poliennali del Tesoro): a FixedRateBond with the Italian Treasury's own hardcoded conventions baked in -- semiannual, Actual/Actual (ISMA), ModifiedFollowing, TARGET payment calendar, par (100) redemption. accruedAmount (generic, via GenBond) additionally rounds to 5 decimal places on a BTP, through the C++ override -- no separate binding needed. yield upstream is a thin wrapper fixing yield's day counter/compounding/frequency arguments to Actual/Actual (ISMA)/Compounded/Annual and is not bound; call the generic yield with those same arguments instead.

btpWithRedemption Source #

Arguments

:: Day

maturityDate

-> Double

fixedRate

-> Double

redemption

-> Maybe Day

startDate

-> Maybe Day

issueDate

-> IO BTP 

As btp, but with an explicit (non-par) redemption amount -- needed only for one remaining legacy BTP (as of upstream's own documentation) that redeems below par.

zeroCouponBond Source #

Arguments

:: Word

settlementDays

-> Calendar 
-> Double

faceAmount

-> Day

maturityDate

-> BusinessDayConvention 
-> Double

redemption

-> Maybe Day

issueDate

-> IO Bond 

zero-coupon bond

floatingRateBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Schedule

schedule

-> GenIborIndex ibor 
-> DayCounter

accrualDayCounter

-> BusinessDayConvention 
-> Word

fixingDays

-> [Double]

gearings

-> [Double]

spreads

-> [Double]

caps

-> [Double]

floors

-> Bool

inArrears

-> Double

redemption

-> Maybe Day

issueDate

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> BusinessDayConvention

fixingConvention

-> IO Bond 

floating-rate bond (possibly capped and/or floored)

cmsRateBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Schedule

schedule

-> GenSwapIndex sidx 
-> DayCounter

paymentDayCounter

-> BusinessDayConvention

paymentConvention

-> Word

fixingDays

-> [Double]

gearings

-> [Double]

spreads

-> [Double]

caps

-> [Double]

floors

-> Bool

inArrears

-> Double

redemption

-> Maybe Day

issueDate

-> IO Bond 

CMS-rate bond

cpiBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Double

baseCPI

-> (Word, TimeUnit)

observationLag

-> ZeroInflationIndex 
-> CPIInterpolationType

observationInterpolation

-> Schedule 
-> NonEmpty Double

coupons

-> DayCounter

accrualDayCounter

-> BusinessDayConvention

paymentConvention

-> Maybe Day

issueDate

-> Calendar

paymentCalendar

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> IO CPIBond 

An inflation-linked bond whose redemption and coupons scale with a ZeroInflationIndex fixing relative to baseCPI.

amortizingFixedRateBond Source #

Arguments

:: Word

settlementDays

-> NonEmpty Double

notionals

-> Schedule

schedule

-> NonEmpty Double

coupons

-> DayCounter

accrualDayCounter

-> BusinessDayConvention

paymentConvention

-> Maybe Day

issueDate

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> [Double]

redemptions

-> Int

paymentLag

-> IO Bond 

amortizing fixed-rate bond: like fixedRateBond but with a per-period notional schedule instead of a single face amount (see sinkingSchedule/sinkingNotionals for building one).

amortizingCmsRateBond Source #

Arguments

:: Word

settlementDays

-> NonEmpty Double

notionals

-> Schedule

schedule

-> GenSwapIndex sidx 
-> DayCounter

paymentDayCounter

-> BusinessDayConvention

paymentConvention

-> Word

fixingDays

-> [Double]

gearings

-> [Double]

spreads

-> [Double]

caps

-> [Double]

floors

-> Bool

inArrears

-> Maybe Day

issueDate

-> [Double]

redemptions

-> IO Bond 

amortizing CMS-rate bond (possibly capped and/or floored) with a per-period notional schedule instead of a single face amount, and a per-period redemption schedule instead of a single redemption value.

amortizingFloatingRateBond :: Word -> NonEmpty Double -> Schedule -> GenIborIndex ibor -> DayCounter -> AmortizingFloatingRateBondOpts -> IO Bond Source #

amortizing floating-rate bond (possibly capped and/or floored) with a per-period notional schedule instead of a single face amount; see AmortizingFloatingRateBondOpts for the trailing optional parameters (default via defaultAmortizingFloatingRateBondOpts, override with record-update syntax).

sinkingSchedule Source #

Arguments

:: Day

startDate

-> (Int, TimeUnit)

bondLength

-> Frequency 
-> Calendar

paymentCalendar

-> IO Schedule 

returns a schedule for French amortization

sinkingNotionals Source #

Arguments

:: (Int, TimeUnit)

bondLength

-> Frequency 
-> Double

couponRate

-> Double

initialNotional

-> IO [Double] 

returns a sequence of notionals for French amortization

rendistatoBasket :: NonEmpty (BTP, Double, GenQuote q) -> IO RendistatoBasket Source #

A weighted collection of BTPs with their outstanding amounts and live clean-price quotes, used by rendistatoCalculator. size/btps/cleanPriceQuotes/outstandings/weights/outstanding are all constructor echoes and are not bound.

rendistatoCalculator Source #

Arguments

:: RendistatoBasket

basket

-> (Int, TimeUnit)

euriborTenor

-> Maybe (GenYieldTermStructure y1)

euriborForwardCurve

-> GenYieldTermStructure y2

discountCurve

-> IO RendistatoCalculator 

QuantLib's own BTP-vs-EUR-swap-curve relative-value tool (ql/instruments/bonds/btp.hpp's RendistatoCalculator): aggregates a RendistatoBasket into a weighted BTP yield/duration, prices a fixed ladder of 1..15Y EUR swaps against a discount curve, and reports the swap whose duration is closest to (without exceeding) the basket's own duration as the "equivalent swap". euriborForwardCurve forwards the internally constructed Euribor index used for those comparison swaps' floating leg -- matching upstream's own Euribor default when Nothing, but the calculator immediately prices those swaps (fairRate), which needs a real forwarding curve to project floating cashflows, so a Nothing here throws rather than degrading gracefully; pass the same curve as discountCurve unless a genuinely different forward curve is wanted. discountCurve is required, with no upstream default.

Callable and convertible bonds

callableFixedRateBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Schedule 
-> NonEmpty Double

coupons

-> DayCounter 
-> BusinessDayConvention 
-> Double

redemption

-> Maybe Day

issueDate

-> [Callability] 
-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> IO CallableBond 

fixed-rate bond with an embedded call/put schedule

callableZeroCouponBond Source #

Arguments

:: Word

settlementDays

-> Double

faceAmount

-> Calendar 
-> Day

maturityDate

-> DayCounter 
-> BusinessDayConvention 
-> Double

redemption

-> Maybe Day

issueDate

-> [Callability] 
-> IO CallableBond 

zero-coupon bond with an embedded call/put schedule

convertibleFixedCouponBond Source #

Arguments

:: Exercise 
-> Double

conversionRatio

-> [Callability] 
-> Day

issueDate

-> Word

settlementDays

-> NonEmpty Double

coupons

-> DayCounter 
-> Schedule 
-> Double

redemption

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> IO ConvertibleBond 

convertible bond with a fixed-rate coupon leg

convertibleFloatingRateBond Source #

Arguments

:: Exercise 
-> Double

conversionRatio

-> [Callability] 
-> Day

issueDate

-> Word

settlementDays

-> GenIborIndex ibor 
-> Word

fixingDays

-> [Double]

spreads

-> DayCounter 
-> Schedule 
-> Double

redemption

-> (Int, TimeUnit)

exCouponPeriod

-> Calendar

exCouponCalendar

-> BusinessDayConvention

exCouponConvention

-> Bool

exCouponEndOfMonth

-> IO ConvertibleBond 

convertible bond with a floating-rate coupon leg

convertibleZeroCouponBond Source #

Arguments

:: Exercise 
-> Double

conversionRatio

-> [Callability] 
-> Day

issueDate

-> Word

settlementDays

-> DayCounter 
-> Schedule 
-> Double 
-> IO ConvertibleBond 

convertible zero-coupon bond

Inspectors

Bond state

maturityDate :: GenBond b -> IO (Maybe Day) Source #

Returns the maturity date of the bond

yield Source #

Arguments

:: GenBond b 
-> DayCounter 
-> Compounding 
-> Frequency 
-> Double

accuracy

-> Word

maxEvaluations

-> (Double, BondPriceType)

guess, priceType

-> IO Double 

theoretical bond yield

accruedAmount :: GenBond b -> Day -> IO Double Source #

accrued amount at a given date

dirtyPriceFromYield :: GenBond b -> Double -> DayCounter -> Compounding -> Frequency -> Day -> IO Double Source #

dirty price given a yield and settlement date

nextCashFlowDate :: GenBond b -> Day -> IO (Maybe Day) Source #

date of the next cash flow after the given (or default settlement) date

nextCouponRate :: GenBond b -> Day -> IO Double Source #

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.

notional :: GenBond b -> Day -> IO Double Source #

bond notional outstanding at the given date

previousCashFlowDate :: GenBond b -> Day -> IO (Maybe Day) Source #

date of the cash flow immediately before the given (or default settlement) date

previousCouponRate :: GenBond b -> Day -> IO Double Source #

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.

settlementValueFromCleanPrice :: GenBond b -> Double -> IO Double Source #

settlement value as a function of the clean price The default bond settlement date is used for calculation.

settlementValue :: GenBond b -> IO Double Source #

theoretical settlement value The default bond settlement date is used for calculation.

yieldFromPrice Source #

Arguments

:: GenBond b 
-> (Double, BondPriceType) 
-> DayCounter 
-> Compounding 
-> Frequency 
-> Day 
-> Double

accuracy

-> Word

maxEvaluations

-> IO Double 

yield given a (clean) price and settlement date

isTradable :: GenBond b -> Day -> IO Bool Source #

whether the bond can be traded (i.e. still has a positive notional) at the given date

notionals :: GenBond b -> IO [Double] Source #

notionals for each period of the bond's amortization schedule

cashFlows :: GenBond b -> IO Leg Source #

returns all the cashflows, including the redemptions.

redemptions :: GenBond b -> IO Leg Source #

returns just the redemption flows (not interest payments)

settlementDate :: GenBond b -> Day -> IO Day Source #

settlement date computed from the given date (or today's date if none is given)

startDate :: GenBond b -> IO Day Source #

date the bond starts accruing

Bond analytics

accrualDays :: GenBond b -> Day -> IO Int Source #

number of days in the current accrual period up to the given (or default settlement) date

accrualEndDate :: GenBond b -> Day -> IO (Maybe Day) Source #

end date of the accrual period containing the given (or default settlement) date

accrualPeriod :: GenBond b -> Day -> IO Double Source #

length in time of the accrual period containing the given (or default settlement) date

accrualStartDate :: GenBond b -> Day -> IO (Maybe Day) Source #

start date of the accrual period containing the given (or default settlement) date

accruedDays :: GenBond b -> Day -> IO Int Source #

number of days accrued up to the given (or default settlement) date

accruedPeriod :: GenBond b -> Day -> IO Double Source #

length in time accrued up to the given (or default settlement) date

atmRate :: GenBond b -> GenYieldTermStructure y -> Day -> (Double, BondPriceType) -> IO Double Source #

the bond's yield to maturity given a market price and discount curve

basisPointValue :: GenBond b -> InterestRate -> Day -> IO Double Source #

basis-point value given an InterestRate yield

bps :: GenBond b -> BpsDiscounting y -> Day -> IO Double Source #

Basis-point sensitivity under the given discounting, at a settlement date.

cleanPrice :: GenBond b -> Discounting y -> Day -> IO Double Source #

Clean price under the given discounting, at a settlement date.

convexity Source #

Arguments

:: GenBond b 
-> InterestRate

yield

-> Day

settlementDate

-> IO Double 

convexity given an InterestRate yield

duration Source #

Arguments

:: GenBond b 
-> InterestRate

yield

-> DurationType 
-> Day 
-> IO Double 

duration given an InterestRate yield and duration type

nextCashFlowAmount :: GenBond b -> Day -> IO Double Source #

amount of the cash flow immediately after the given (or default settlement) date

previousCashFlowAmount :: GenBond b -> Day -> IO Double Source #

amount of the cash flow immediately before the given (or default settlement) date

referencePeriodEnd :: GenBond b -> Day -> IO (Maybe Day) Source #

end date of the reference period containing the given (or default settlement) date

referencePeriodStart :: GenBond b -> Day -> IO (Maybe Day) Source #

start date of the reference period containing the given (or default settlement) date

yieldFromPriceWithGuess Source #

Arguments

:: GenBond b 
-> (Double, BondPriceType) 
-> DayCounter 
-> Compounding 
-> Frequency 
-> Day

settlementDate

-> Double 
-> Word

maxIterations

-> Double

guess

-> IO Double 

yield given a (clean) price and settlement date, solved to the given accuracy

yieldValueBasisPoint Source #

Arguments

:: GenBond b 
-> InterestRate

yield

-> Day 
-> IO Double 

yield value of a basis point given an InterestRate yield

zSpread Source #

Arguments

:: GenBond b 
-> (Double, BondPriceType) 
-> GenYieldTermStructure y 
-> Compounding 
-> Frequency 
-> Day

settlementDate

-> Double

accuracy

-> Word

maxIterations

-> Double

guess

-> IO Double 

Z-spread over a discount curve implied by a (clean) price, solved to the given accuracy

Current prices

currentCleanPrice :: GenBond b -> IO Double Source #

theoretical clean price for the current evaluation date and term structure

currentDirtyPrice :: GenBond b -> IO Double Source #

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.

Rendistato basket analytics

rendistatoYield :: RendistatoCalculator -> IO Double Source #

the basket's outstanding-weighted BTP yield: sum (weights * yields) -- a near-tautology over rendistatoYields, kept because it is upstream's own published aggregate.

rendistatoDuration :: RendistatoCalculator -> IO Double Source #

the basket's outstanding-weighted BTP (modified) duration.

rendistatoYields :: RendistatoCalculator -> IO [Double] Source #

per-bond yields, in basket order.

rendistatoDurations :: RendistatoCalculator -> IO [Double] Source #

per-bond (modified) durations, in basket order.

rendistatoSwapLengths :: RendistatoCalculator -> IO [Double] Source #

the fixed 1..15Y comparison-swap ladder's lengths, in years -- pairs positionally with rendistatoSwapRates/rendistatoSwapYields/rendistatoSwapDurations.

rendistatoSwapRates :: RendistatoCalculator -> IO [Double] Source #

each ladder swap's fair (par) rate.

rendistatoSwapYields :: RendistatoCalculator -> IO [Double] Source #

each ladder swap's fixed leg, repriced as a par bond and re-expressed as a BTP-convention yield.

rendistatoSwapDurations :: RendistatoCalculator -> IO [Double] Source #

each ladder swap's fixed leg (modified) duration, on the same par-bond proxy.

rendistatoEquivalentSwap :: RendistatoCalculator -> IO VanillaSwap Source #

the ladder swap whose duration is closest to (without exceeding) the basket's own duration.

rendistatoEquivalentSwapRate :: RendistatoCalculator -> IO Double Source #

the equivalent swap's fair rate.

rendistatoEquivalentSwapYield :: RendistatoCalculator -> IO Double Source #

the equivalent swap's par-bond-proxy yield.

rendistatoEquivalentSwapDuration :: RendistatoCalculator -> IO Double Source #

the equivalent swap's par-bond-proxy duration.

rendistatoEquivalentSwapLength :: RendistatoCalculator -> IO Double Source #

the equivalent swap's length, in years.

rendistatoEquivalentSwapSpread :: RendistatoCalculator -> IO Double Source #

rendistatoYield - rendistatoEquivalentSwapRate: the basket's spread over its equivalent swap.

rendistatoEquivalentSwapLengthQuote :: RendistatoCalculator -> IO Quote Source #

A live Quote tracking rendistatoEquivalentSwapLength -- re-evaluates on every access rather than snapshotting it, so it can be wired into curve bootstrapping like any other quote.