I have the following code. However i am having error when executing same. I want the function to calculate the schedule date and ouput same to a new dataframe. It seems the error is in the for loop. I am new to this so just trying to figure out
import QuantLib as ql
import pandas as pd
import numpy as np
import datetime
from dateutil.parser import parse
data = pd.read_excel (r'C:\Users\Avishen\Desktop\Python\BONDDATA.xlsx')
for ISIN,issuedate,maturitydate in data:
issueDate = ql.Date(issuedate, '%d-%m-%Y')
maturityDate = ql.Date(maturitydate, '%d-%m-%Y')
tenor = ql.Period(ql.Semiannual)
day_count = ql.Thirty360
calendar = ql.UnitedStates()
businessConvention = ql.Unadjusted
dateGeneration = ql.DateGeneration.Backward
monthEnd = False
# Dates in Bond Period
df['Test']= df['t'].apply(ISIN)
df['Test']= df['t1'].apply(ql.Schedule (issueDate, maturityDate, tenor, calendar, businessConvention,businessConvention , dateGeneration, monthEnd))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-b6dc0a0bd926> in <module>
8
9
---> 10 for ISIN,issuedate,maturitydate in data:
11 issueDate = ql.Date(issuedate, '%d-%m-%Y')
12 maturityDate = ql.Date(maturitydate, '%d-%m-%Y')
ValueError: too many values to unpack (expected 3)
Desired Output
t t1
Test1 Date(22,10,2019)
Test1 Date(8,2,2020)
Test1 Date(8,8,2020)
Test1 Date(8,2,2021)
Test1 Date(8,8,2021)
Test1 Date(8,2,2022)
Test1 Date(8,8,2022)
Test1 Date(8,2,2023)
Test1 Date(8,8,2023)
Test2 Date(31,7,2020)
Test2 Date(21,9,2020)
Test2 Date(21,3,2021)
Test2 Date(21,9,2021)
Test2 Date(21,3,2022)
Test2 Date(21,9,2022)
Test2 Date(21,3,2023)
Test2 Date(21,9,2023)
Test2 Date(21,3,2024)
Test2 Date(21,9,2024)
Test2 Date(21,3,2025)