Quantlib Floating Rate Instruments

import QuantLib as ql # 1. Set Evaluation Date & Market Curve today = ql.Date(25, 6, 2026) ql.Settings.instance().evaluationDate = today # Create a flat forward yield curve to forecast and discount cash flows rate_handle = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.04, ql.Actual360())) # 2. Define the Floating Rate Index (e.g., USD Libor 6M) # (In production, historical fixings should be added to the index using index.addFixing) ibor_index = ql.USDLibor(ql.Period(6, ql.Months), rate_handle) # 3. Create the Payment Schedule start_date = ql.Date(25, 6, 2026) end_date = ql.Date(25, 6, 2031) tenor = ql.Period(6, ql.Months) calendar = ql.TARGET() convention = ql.Following schedule = ql.Schedule( start_date, end_date, tenor, calendar, convention, convention, ql.DateGeneration.Backward, False ) # 4. Construct the Floating Rate Bond settlement_days = 2 face_amount = 100.0 spreads = [0.005] # 50 bps spread over the floating index floating_bond = ql.FloatingRateBond( settlement_days, face_amount, schedule, ibor_index, ql.Actual360(), convention, spreads=[spreads[0]] )