import QuantLib as ql
import datetime
today = ql.Date(10,5,2020)
ql.Settings.instance().evaluationDate = today
issueDate = ql.Date(10,5,2020)
maturityDate = ql.Date(9, 7, 2021)
tenor = ql.Period(ql.Monthly)
dayCount = ql.Actual365Fixed()
bussinessConvention = ql.Unadjusted
dateGeneration = ql.DateGeneration.Forward
monthEnd = False
calendar = ql.NullCalendar()
faceValue = 10000000
coupon = 0.07
schedule = ql.Schedule(issueDate, maturityDate,tenor, calendar, ql.Unadjusted, ql.Unadjusted, dateGeneration,False)
fixed_rate_leg = ql.FixedRateLeg(schedule=schedule, dayCount=dayCount,
nominals=[faceValue], couponRates=[coupon]) + (ql.Redemption(faceValue,maturityDate),)
bond = ql.Bond(0, calendar, 100.0,
maturityDate, issueDate, fixed_rate_leg)
print([(a.date(),a.amount() )for a in bond.cashflows()])
[(Date(10,6,2020), 59452.05479451987), (Date(10,7,2020), 57534.24657534145), (Date(10,8,2020), 59452.05479451987), (Date(10,9,2020), 59452.05479451987), (Date(10,10,2020), 57534.24657534145), (Date(10,11,2020), 59452.05479451987), (Date(10,12,2020), 57534.24657534145), (Date(10,1,2021), 59452.05479451987), (Date(10,2,2021), 59452.05479451987), (Date(10,3,2021), 53698.63013698684), (Date(10,4,2021), 59452.05479451987), (Date(10,5,2021), 57534.24657534145), (Date(10,6,2021), 59452.05479451987), (Date(9,7,2021), 55616.43835616526), (Date(9,7,2021), 10000000.0)]
here for example expected cashflow on first cashflow date is.
date = 10/06/2020
amount = 61369.86301369864
above amount calculation explanation:
yr_frac = ql.Actual365Fixed().yearFraction(ql.Date(10,5,2020),ql.Date(11,6,2020))
amount = faceValue*yr_frac*coupon
amount = 61369.86301369864
```
$\begingroup$
$\endgroup$
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
If you check the dates that were generated, you will see 10-06-2020 and not 11-06-2020..
for cf in map(ql.as_fixed_rate_coupon, bond.cashflows()[:1]):
print(cf.accrualStartDate().ISO(), cf.accrualEndDate().ISO(), cf.amount())
2020-05-10 2020-06-10 59452.05479451987
-
$\begingroup$ Yes agreed it was just to get year fraction of 32 days @David as we can see the number of days between two dates is 31, But I want to include the end date also for calculation so it becomes 32. So I am checking if there anything which will give me the cashflow amount for 32 days on 10/06/2020 as above example. $\endgroup$ Commented Sep 15, 2022 at 15:19