The fair rate calculated in the above example is the rate to be used for fixed rate leg to yield 0 NPV. You would need to reconstruct the swap with the float leg as is but a fixed leg with fair rate from above. That should yield a 0 NPV for the swap.
Try casting, something like
c = as_coupon(cf)
if not c.__nonzero__():
print "principal redemption"
You can likewise attempt casting the cf to as_fixed_rate_coupon(cf) or to as_floating_rate_coupon(cf), and if they work, then access other useful info. Also, redemptions is another available inspector.
Related question: how can i see the ...
I think you are missing the eval date, and then there are some subleties in how Excel/QL setup discount factors etc.:
import QuantLib as ql
now, you forgot this step:
ql.Settings.instance().evaluationDate = ql.Date(15,5,2021)
coupon = 0.00375
yld = 0.01
start = ql.Date(15,5,2021)
maturity = ql.Date(30,11,2025)
schedule = ql.Schedule(start,
Gamma is computed differently;
price is quoted by the exchange in a way QuantLib does not compute
BBG's DES page computes Gamma as 1% chg in underlying - there is also no flexibility with the DES page and frequently this is not the best calc they offer.
However you can load any listed option in their OTC pricers to get listed ...