Skip to content
All library documents

Valuing a QuantLib FRA with an Explicit Discount Curve

Article Quant Q&A · Author: user47760

Summary

This question reports an error when valuing a forward rate agreement with QuantLib after changing its value date. The accepted answer identifies the missing input: the ForwardRateAgreement constructor accepts an optional discount curve, and the example leaves that handle empty. The proposed fix is to pass the existing yield-curve handle as the constructor’s final argument.

The explanation is specific to the constructor shown and the reported empty-handle error. It demonstrates that supplying an index curve does not, by itself, populate the FRA’s separate discount-curve parameter. The exchange does not discuss broader valuation choices, curve construction, conventions, or whether using the same curve for index projection and discounting is appropriate in other settings. It addresses the immediate QuantLib setup issue rather than providing a general FRA valuation treatment.

Key ideas

  • The FRA constructor accepts a discount curve as an optional final argument.
  • An empty discount-curve handle can trigger an error when valuation needs that curve.
  • Pass the yield-curve handle explicitly to provide the discount curve.
  • The example uses the same curve handle for the index and discounting, but does not discuss when that modeling choice is appropriate.

Tags

Full text
# FX Forward rate agreement valuation in quantlib


# FX Forward rate agreement valuation in quantlib












I am trying to value an FRA in quantlib Python using the below code:

```
import QuantLib as ql

calendar = ql.UnitedStates()

todaysDate = ql.Date(7, ql.May, 2017)
#
ql.Settings.instance().evaluationDate = todaysDate

spotDates = [ql.Date(7, 5, 2017)+ql.Period(i*6, ql.Months) for i in range(0, 10)]

spotRates = [4.3291/100]*len(spotDates)

interpolation = ql.Linear()

compounding = ql.Compounded

compoundingFrequency = ql.Annual

spotCurve = ql.ZeroCurve(spotDates, spotRates, ql.Actual360(), calendar,interpolation, compounding, compoundingFrequency)

spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)

indexCurve1 = ql.Euribor6M(spotCurveHandle)

indexCurve1.addFixing(ql.Date(7, 5, 2017) -3,0.9,True)

forward_rates=[spotCurve.zeroRate(x,ql.Actual360(),compounding,compoundingFrequency).rate()for x in spotDates]

fra = ql.ForwardRateAgreement(ql.Date(7, 5, 2017),ql.Date(15,12,2020),ql.Position.Long,0.01,10e6,ql.Euribor6M(spotCurveHandle))
```

However if I change the valuation date in the function

```
fra = ql.ForwardRateAgreement(ql.Date(7, 5, 2018),ql.Date(15,12,2020),ql.Position.Long,0.01,10e6,ql.Euribor6M(spotCurveHandle))
```

It gives me an error:RuntimeError: empty Handle cannot be dereferenced

Can anyone please help me with this error? I would sincerely appreciate.

Thanks in advance!

## Answer by David Duarte (score 6, accepted)

https://quant.stackexchange.com/a/55184

You are not giving the constructor a discountCurve. The constructor is:

```
ql.ForwardRateAgreement(valueDate, maturityDate, position, strikeForward, notional, iborIndex, discountCurve=ql.YieldTermStructureHandle())
```

So you should add a the spotCurveHandle as the last parameter:

```
fra = ql.ForwardRateAgreement(ql.Date(7, 5, 2018), ql.Date(15,12,2020), ql.Position.Long, 0.01, 10e6,ql.Euribor6M(spotCurveHandle), spotCurveHandle)
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.