Class AssetSwap
- Namespace
- NanoQL.Instruments
- Assembly
- NanoQL.dll
A bond's asset swap: the bond's coupons and final payment against a floating leg, at par (the bond bought at par, an upfront paying its premium) or at market (the floating notional scaled by the bond's dirty price); D. O'Kane, "Introduction to Asset Swaps", Lehman Brothers European Fixed Income Research, January 2000.
public sealed class AssetSwap : Swap
- Inheritance
-
AssetSwap
- Inherited Members
Remarks
The bond's clean price is its (forward) price at the floating schedule's start, the upfront date. On an overnight index the floating schedule must be given, and the floating coupons are overnight-indexed. QuantLib warns that the fair prices are wrong with indexed coupons.
A non-par repayment is per 100 of the bond's notional at the upfront date, as the fair repayment reads it, and paid
as that share of the notional, where QuantLib's pays the number given as an amount (assetswap.cpp:125-134);
with none given the swap repays the bond's redemption, and its repayment is that redemption per 100 of notional,
where QuantLib's stores 100 whatever the redemption (:130). On a bond of 100 redeemed at 100 the two agree.
The swap is priced by DiscountingSwapEngine's asset swap overload, its fair values
derived from the swap's results; QuantLib's AssetSwap::arguments, which no QuantLib engine reads, aren't
ported.
Constructors
AssetSwap(bool, Bond, double, IborIndex, double, EvaluationContext, Schedule?, DayCounter?, bool, double, double?, Date?)
Initializes a new instance of the AssetSwap class.
public AssetSwap(bool payBondCoupon, Bond bond, double bondCleanPrice, IborIndex iborIndex, double spread, EvaluationContext context, Schedule? floatSchedule = null, DayCounter? floatingDayCount = null, bool parSwap = true, double gearing = 1, double? nonParRepayment = null, Date? dealMaturity = null)
Parameters
payBondCouponboolWhether the bond's coupons are paid (the floating leg received).
bondBondThe bond.
bondCleanPricedoubleThe bond's clean price at the upfront date, per 100 of notional.
iborIndexIborIndexThe floating leg's index, an Ibor or an overnight one.
spreaddoubleThe floating leg's spread.
contextEvaluationContextThe evaluation context, from which the bond's settlement date starts a default floating schedule, and whose at-par switch the floating coupons' default pricer reads.
floatScheduleScheduleThe floating schedule, or null for one from the bond's settlement date to its maturity on the index's tenor, calendar and convention; required on an overnight index.
floatingDayCountDayCounterThe floating coupons' day counter, or null for the index's.
parSwapboolWhether the swap is at par, or at market.
gearingdoubleThe floating leg's gearing.
nonParRepaymentdouble?The final repayment per 100 of notional, or null for the bond's redemption.
dealMaturityDate?The deal's maturity, or null for the floating schedule's end.
Exceptions
- ArgumentNullException
bond,iborIndexorcontextis null.- ArgumentException
The deal maturity is after the schedule's end or not after its start, each with QuantLib's text.
- NanoQLException
An overnight index without a floating schedule, or a bond without cash flows, each with QuantLib's text.
Properties
Bond
Gets the bond.
public Bond Bond { get; }
Property Value
BondLeg
Gets the bond leg: its coupons up to the deal's maturity, any accrued coupon, and the final payment.
public ImmutableArray<CashFlow> BondLeg { get; }
Property Value
CleanPrice
Gets the bond's clean price at the upfront date.
public double CleanPrice { get; }
Property Value
FloatingLeg
Gets the floating leg, with the upfront and the back payment of a par swap, or the final notional exchange of a market one.
public ImmutableArray<CashFlow> FloatingLeg { get; }
Property Value
NonParRepayment
Gets the final repayment per 100 of notional: the one given, or the bond's redemption's.
public double NonParRepayment { get; }
Property Value
ParSwap
Gets whether the swap is at par, or at market.
public bool ParSwap { get; }
Property Value
PayBondCoupon
Gets whether the bond's coupons are paid.
public bool PayBondCoupon { get; }
Property Value
Spread
Gets the floating leg's spread.
public double Spread { get; }
Property Value
UpfrontDate
Gets the upfront date, the floating schedule's start.
public Date UpfrontDate { get; }
Property Value
Methods
FairCleanPrice(AssetSwapResults)
The bond's clean price that gives the swap a zero NPV.
public static double FairCleanPrice(AssetSwapResults results)
Parameters
resultsAssetSwapResultsThe swap's results.
Returns
- double
The fair clean price.
Exceptions
- ArgumentNullException
resultsis null.- NanoQLException
The results hold none, a seasoned deal's, QuantLib's "fair clean price not available for seasoned deal".
FairNonParRepayment(AssetSwapResults)
The final repayment that gives the swap a zero NPV.
public static double FairNonParRepayment(AssetSwapResults results)
Parameters
resultsAssetSwapResultsThe swap's results.
Returns
- double
The fair repayment.
Exceptions
- ArgumentNullException
resultsis null.- NanoQLException
The results hold none, an expired leg's, QuantLib's "fair non par repayment not available for expired leg".
FairSpread(AssetSwapResults)
The spread that gives the swap a zero NPV.
public static double FairSpread(AssetSwapResults results)
Parameters
resultsAssetSwapResultsThe swap's results.
Returns
- double
The fair spread.
Exceptions
- ArgumentNullException
resultsis null.- NanoQLException
The results hold none, QuantLib's "fair spread not available".
FetchResults(InstrumentResults)
Reads an engine's results into the instrument's, applying any derivations the instrument makes.
public override AssetSwapResults FetchResults(InstrumentResults results)
Parameters
resultsInstrumentResultsThe engine's results.
Returns
- AssetSwapResults
The instrument's results.
Remarks
QuantLib's fairSpread, fairCleanPrice and fairNonParRepayment, each derived from
the swap's results unless the results hold it: the fair clean price needs the floating leg's start discount,
unknown for a seasoned deal, and the fair repayment its end discount.
Exceptions
- ArgumentException
The results aren't a swap's, or a per-leg result has the wrong number of legs.
FloatingLegBPS(AssetSwapResults)
The floating leg's BPS.
public static double FloatingLegBPS(AssetSwapResults results)
Parameters
resultsAssetSwapResultsThe swap's results.
Returns
- double
The BPS.
Exceptions
- ArgumentNullException
resultsis null.- NanoQLException
The results hold none, QuantLib's "floating-leg BPS not available".
FloatingLegNPV(AssetSwapResults)
The floating leg's NPV.
public static double FloatingLegNPV(AssetSwapResults results)
Parameters
resultsAssetSwapResultsThe swap's results.
Returns
- double
The NPV.
Exceptions
- ArgumentNullException
resultsis null.- NanoQLException
The results hold none, QuantLib's "floating-leg NPV not available".
SetupExpired()
The results of an expired instrument: a zero value and error estimate, and no valuation date.
public override AssetSwapResults SetupExpired()
Returns
- AssetSwapResults
The expired results.
Remarks
An expired swap has zero leg NPVs, BPS and discounts, so fair values of NaN, the quotients of zeros
QuantLib derives (assetswap.cpp:236-304).