Discussion:
[Quantlib-users] Generate Schedule in Python with given dates
TSchulz85
2017-05-10 19:04:07 UTC
Permalink
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias



--
View this message in context: http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
CK TUNG
2017-05-11 02:14:37 UTC
Permalink
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015), Date(2,3,2015), Date(1,4,2015), Date(1,5,2015), Date(1,6,2015), Date(1,7,2015), Date(3,8,2015), Date(1,9,2015), Date(1,10,2015), Date(2,11,2015), Date(1,12,2015), Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar, rolling_convention)
for i, d in enumerate(schedule): print i+1, d
Post by TSchulz85
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
View this message in context: http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Luigi Ballabio
2017-05-12 09:18:27 UTC
Permalink
This will build the schedule, but passing it to other classes such as
FixedRateBond won't work. The Schedule constructor exported to Python
should be extended to support the additional parameters now available in
C++. Until then, schedules built in this way won't be very useful...

Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015),
Date(2,3,2015), Date(1,4,2015),
Date(1,5,2015), Date(1,6,2015),
Date(1,7,2015), Date(3,8,2015),
Date(1,9,2015), Date(1,10,2015),
Date(2,11,2015), Date(1,12,2015),
Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar,
rolling_convention)
print i+1, d
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
CK TUNG
2017-05-12 10:12:00 UTC
Permalink
what I think is QuantLib Python interface file needs to be updated and wrap again. For this case just add this to scheduler.i
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));





Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as FixedRateBond won't work. The Schedule constructor exported to Python should be extended to support the additional parameters now available in C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015), Date(2,3,2015), Date(1,4,2015), Date(1,5,2015), Date(1,6,2015), Date(1,7,2015), Date(3,8,2015), Date(1,9,2015), Date(1,10,2015), Date(2,11,2015), Date(1,12,2015), Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar, rolling_convention)
for i, d in enumerate(schedule): print i+1, d
Post by TSchulz85
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
View this message in context: http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Luigi Ballabio
2017-05-12 10:27:44 UTC
Permalink
Hmm. Unfortunately, I don't think that SWIG supports boost::optional out of
the box. It will require some kind of mapping, which might be the reason
the wrappers are not updated yet.
Post by CK TUNG
what I think is QuantLib Python interface file needs to be updated and
wrap again. For this case just add this to *scheduler.i*
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));
Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as
FixedRateBond won't work. The Schedule constructor exported to Python
should be extended to support the additional parameters now available in
C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015),
Date(2,3,2015), Date(1,4,2015),
Date(1,5,2015), Date(1,6,2015),
Date(1,7,2015), Date(3,8,2015),
Date(1,9,2015), Date(1,10,2015),
Date(2,11,2015), Date(1,12,2015),
Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar,
rolling_convention)
print i+1, d
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
CK TUNG
2017-05-12 10:34:09 UTC
Permalink
In fact I have tried it in Windows SWIG, it works.
Hmm. Unfortunately, I don't think that SWIG supports boost::optional out of the box. It will require some kind of mapping, which might be the reason the wrappers are not updated yet.
Post by CK TUNG
what I think is QuantLib Python interface file needs to be updated and wrap again. For this case just add this to scheduler.i
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));
Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as FixedRateBond won't work. The Schedule constructor exported to Python should be extended to support the additional parameters now available in C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015), Date(2,3,2015), Date(1,4,2015), Date(1,5,2015), Date(1,6,2015), Date(1,7,2015), Date(3,8,2015), Date(1,9,2015), Date(1,10,2015), Date(2,11,2015), Date(1,12,2015), Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar, rolling_convention)
for i, d in enumerate(schedule): print i+1, d
Post by TSchulz85
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
View this message in context: http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Luigi Ballabio
2017-05-12 11:17:15 UTC
Permalink
That's great to know. May you open a pull request?

Luigi
Post by CK TUNG
In fact I have tried it in Windows SWIG, it works.
Hmm. Unfortunately, I don't think that SWIG supports boost::optional out
of the box. It will require some kind of mapping, which might be the reason
the wrappers are not updated yet.
Post by CK TUNG
what I think is QuantLib Python interface file needs to be updated and
wrap again. For this case just add this to *scheduler.i*
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));
Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as
FixedRateBond won't work. The Schedule constructor exported to Python
should be extended to support the additional parameters now available in
C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015),
Date(2,3,2015), Date(1,4,2015),
Date(1,5,2015), Date(1,6,2015),
Date(1,7,2015), Date(3,8,2015),
Date(1,9,2015), Date(1,10,2015),
Date(2,11,2015), Date(1,12,2015),
Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar,
rolling_convention)
print i+1, d
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
CK TUNG
2017-05-12 11:36:30 UTC
Permalink
However, I don't know how to change it into named parameters in SWIG. The last parameter isRegular is always needed for the FixedRateBond. Others are really optional.
Post by Luigi Ballabio
That's great to know. May you open a pull request?
Luigi
Post by CK TUNG
In fact I have tried it in Windows SWIG, it works.
Hmm. Unfortunately, I don't think that SWIG supports boost::optional out of the box. It will require some kind of mapping, which might be the reason the wrappers are not updated yet.
Post by CK TUNG
what I think is QuantLib Python interface file needs to be updated and wrap again. For this case just add this to scheduler.i
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));
Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as FixedRateBond won't work. The Schedule constructor exported to Python should be extended to support the additional parameters now available in C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015), Date(2,3,2015), Date(1,4,2015), Date(1,5,2015), Date(1,6,2015), Date(1,7,2015), Date(3,8,2015), Date(1,9,2015), Date(1,10,2015), Date(2,11,2015), Date(1,12,2015), Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar, rolling_convention)
for i, d in enumerate(schedule): print i+1, d
Post by TSchulz85
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
View this message in context: http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Luigi Ballabio
2017-05-12 12:58:44 UTC
Permalink
Unfortunately, SWIG can't generate wrappers with named parameters if the
constructor is overloaded.
Post by CK TUNG
However, I don't know how to change it into named parameters in SWIG. The
last parameter isRegular is always needed for the FixedRateBond. Others are
really optional.
That's great to know. May you open a pull request?
Luigi
Post by CK TUNG
In fact I have tried it in Windows SWIG, it works.
Hmm. Unfortunately, I don't think that SWIG supports boost::optional out
of the box. It will require some kind of mapping, which might be the reason
the wrappers are not updated yet.
Post by CK TUNG
what I think is QuantLib Python interface file needs to be updated and
wrap again. For this case just add this to *scheduler.i*
and rebuild
Schedule(const std::vector<Date>&,
const Calendar& calendar = NullCalendar(),
const BusinessDayConvention
convention = Unadjusted,
boost::optional<BusinessDayConvention>
terminationDateConvention = boost::none,
const boost::optional<Period> tenor = boost::none,
boost::optional<DateGeneration::Rule> rule = boost::none,
boost::optional<bool> endOfMonth = boost::none,
const std::vector<bool>& isRegular = std::vector<bool>(0));
Thanks
TUNG Ching Kai
97782276
This will build the schedule, but passing it to other classes such as
FixedRateBond won't work. The Schedule constructor exported to Python
should be extended to support the additional parameters now available in
C++. Until then, schedules built in this way won't be very useful...
Luigi
Post by CK TUNG
Here is an example
https://leanpub.com/quantlibpythoncookbook/read
calendar = UnitedStates()
dates = [Date(2,1,2015), Date(2, 2,2015),
Date(2,3,2015), Date(1,4,2015),
Date(1,5,2015), Date(1,6,2015),
Date(1,7,2015), Date(3,8,2015),
Date(1,9,2015), Date(1,10,2015),
Date(2,11,2015), Date(1,12,2015),
Date(4,1,2016)]
rolling_convention = Following
schedule= Schedule(dates, calendar,
rolling_convention)
print i+1, d
Hi,
Is it possible to generate a QuantLib Schedule in python just with specific
defined dates?
I'm intending to just download a bond coupon schedule from bloomberg, thus
avoiding any problems with stubs.
Thanks,
Tobias
--
http://quantlib.10058.n7.nabble.com/Generate-Schedule-in-Python-with-given-dates-tp18266.html
Sent from the quantlib-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Continue reading on narkive:
Loading...