Schedule end of month business day convention

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Schedule end of month business day convention

igitur
Hi,

In schedule.cpp, lines 349 - 355:
            if (convention == Unadjusted) {
                for (Size i=1; i<dates_.size()-1; ++i)
                    dates_[i] = Date::endOfMonth(dates_[i]);
            } else {
                for (Size i=1; i<dates_.size()-1; ++i)
                    dates_[i] = calendar_.endOfMonth(dates_[i]);
            }
And calendar.hpp: lines 207-209:
    inline Date Calendar::endOfMonth(const Date& d) const {
        return adjust(Date::endOfMonth(d), Preceding);
    }
This is applicable when the endOfMonth rule is true. If the business day convention is Unadjusted, it works fine, but if the business day convention is e.g. Modified Following, the second part of the code is executed. But calendar_.endOfMonth is hardcoded to use Preceding. The actual business day convention isn't passed through. Is this a bug or maybe I don't understand something?

regards
Francois Botha

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Schedule end of month business day convention

Luigi Ballabio
You want the last business day of the month, so you take the last day
of the month and adjust it backwards. If you adjusted it forward,
you'd get the first business day of the following month instead.

Luigi

On Fri, Jun 6, 2014 at 10:56 AM, Francois Botha <[hidden email]> wrote:

> Hi,
>
> In schedule.cpp, lines 349 - 355:
>
>             if (convention == Unadjusted) {
>                 for (Size i=1; i<dates_.size()-1; ++i)
>                     dates_[i] = Date::endOfMonth(dates_[i]);
>             } else {
>                 for (Size i=1; i<dates_.size()-1; ++i)
>                     dates_[i] = calendar_.endOfMonth(dates_[i]);
>             }
>
> And calendar.hpp: lines 207-209:
>
>     inline Date Calendar::endOfMonth(const Date& d) const {
>         return adjust(Date::endOfMonth(d), Preceding);
>     }
>
> This is applicable when the endOfMonth rule is true. If the business day
> convention is Unadjusted, it works fine, but if the business day convention
> is e.g. Modified Following, the second part of the code is executed. But
> calendar_.endOfMonth is hardcoded to use Preceding. The actual business day
> convention isn't passed through. Is this a bug or maybe I don't understand
> something?
>
> regards
> Francois Botha
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Schedule end of month business day convention

igitur
Yes, that is what I want.

This specific bond pays coupons on 31 March and 30 September each year, and if those days fall on a non-business day, the next business day is used. So instead 2017-09-30 falls on a Saturday, so the coupon will pay on 2017-10-02.

I understood that I could use 'Following' instead of 'Modified Following' if I want to allow crossing over to the next month.

Francois Botha


On 6 June 2014 11:01, Luigi Ballabio <[hidden email]> wrote:
You want the last business day of the month, so you take the last day
of the month and adjust it backwards. If you adjusted it forward,
you'd get the first business day of the following month instead.

Luigi

On Fri, Jun 6, 2014 at 10:56 AM, Francois Botha <[hidden email]> wrote:
> Hi,
>
> In schedule.cpp, lines 349 - 355:
>
>             if (convention == Unadjusted) {
>                 for (Size i=1; i<dates_.size()-1; ++i)
>                     dates_[i] = Date::endOfMonth(dates_[i]);
>             } else {
>                 for (Size i=1; i<dates_.size()-1; ++i)
>                     dates_[i] = calendar_.endOfMonth(dates_[i]);
>             }
>
> And calendar.hpp: lines 207-209:
>
>     inline Date Calendar::endOfMonth(const Date& d) const {
>         return adjust(Date::endOfMonth(d), Preceding);
>     }
>
> This is applicable when the endOfMonth rule is true. If the business day
> convention is Unadjusted, it works fine, but if the business day convention
> is e.g. Modified Following, the second part of the code is executed. But
> calendar_.endOfMonth is hardcoded to use Preceding. The actual business day
> convention isn't passed through. Is this a bug or maybe I don't understand
> something?
>
> regards
> Francois Botha
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Schedule end of month business day convention

Luigi Ballabio
In this case you wouldn't use end-of-month = true.

On Fri, Jun 6, 2014 at 11:16 AM, Francois Botha <[hidden email]> wrote:

> Yes, that is what I want.
>
> This specific bond pays coupons on 31 March and 30 September each year, and
> if those days fall on a non-business day, the next business day is used. So
> instead 2017-09-30 falls on a Saturday, so the coupon will pay on
> 2017-10-02.
>
> I understood that I could use 'Following' instead of 'Modified Following' if
> I want to allow crossing over to the next month.
>
> Francois Botha
>
>
> On 6 June 2014 11:01, Luigi Ballabio <[hidden email]> wrote:
>>
>> You want the last business day of the month, so you take the last day
>> of the month and adjust it backwards. If you adjusted it forward,
>> you'd get the first business day of the following month instead.
>>
>> Luigi
>>
>> On Fri, Jun 6, 2014 at 10:56 AM, Francois Botha <[hidden email]> wrote:
>> > Hi,
>> >
>> > In schedule.cpp, lines 349 - 355:
>> >
>> >             if (convention == Unadjusted) {
>> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >                     dates_[i] = Date::endOfMonth(dates_[i]);
>> >             } else {
>> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >                     dates_[i] = calendar_.endOfMonth(dates_[i]);
>> >             }
>> >
>> > And calendar.hpp: lines 207-209:
>> >
>> >     inline Date Calendar::endOfMonth(const Date& d) const {
>> >         return adjust(Date::endOfMonth(d), Preceding);
>> >     }
>> >
>> > This is applicable when the endOfMonth rule is true. If the business day
>> > convention is Unadjusted, it works fine, but if the business day
>> > convention
>> > is e.g. Modified Following, the second part of the code is executed. But
>> > calendar_.endOfMonth is hardcoded to use Preceding. The actual business
>> > day
>> > convention isn't passed through. Is this a bug or maybe I don't
>> > understand
>> > something?
>> >
>> > regards
>> > Francois Botha
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> > http://p.sf.net/sfu/NeoTech
>> > _______________________________________________
>> > QuantLib-dev mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>> >
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Schedule end of month business day convention

igitur
If I use end-of-month = false, then the dates generated will be either 30 March (not 31) and 30 September, right? Maturity date is 30 September 2021 in this case.

Francois Botha


On 6 June 2014 11:19, Luigi Ballabio <[hidden email]> wrote:
In this case you wouldn't use end-of-month = true.

On Fri, Jun 6, 2014 at 11:16 AM, Francois Botha <[hidden email]> wrote:
> Yes, that is what I want.
>
> This specific bond pays coupons on 31 March and 30 September each year, and
> if those days fall on a non-business day, the next business day is used. So
> instead 2017-09-30 falls on a Saturday, so the coupon will pay on
> 2017-10-02.
>
> I understood that I could use 'Following' instead of 'Modified Following' if
> I want to allow crossing over to the next month.
>
> Francois Botha
>
>
> On 6 June 2014 11:01, Luigi Ballabio <[hidden email]> wrote:
>>
>> You want the last business day of the month, so you take the last day
>> of the month and adjust it backwards. If you adjusted it forward,
>> you'd get the first business day of the following month instead.
>>
>> Luigi
>>
>> On Fri, Jun 6, 2014 at 10:56 AM, Francois Botha <[hidden email]> wrote:
>> > Hi,
>> >
>> > In schedule.cpp, lines 349 - 355:
>> >
>> >             if (convention == Unadjusted) {
>> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >                     dates_[i] = Date::endOfMonth(dates_[i]);
>> >             } else {
>> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >                     dates_[i] = calendar_.endOfMonth(dates_[i]);
>> >             }
>> >
>> > And calendar.hpp: lines 207-209:
>> >
>> >     inline Date Calendar::endOfMonth(const Date& d) const {
>> >         return adjust(Date::endOfMonth(d), Preceding);
>> >     }
>> >
>> > This is applicable when the endOfMonth rule is true. If the business day
>> > convention is Unadjusted, it works fine, but if the business day
>> > convention
>> > is e.g. Modified Following, the second part of the code is executed. But
>> > calendar_.endOfMonth is hardcoded to use Preceding. The actual business
>> > day
>> > convention isn't passed through. Is this a bug or maybe I don't
>> > understand
>> > something?
>> >
>> > regards
>> > Francois Botha
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> > http://p.sf.net/sfu/NeoTech
>> > _______________________________________________
>> > QuantLib-dev mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>> >
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Schedule end of month business day convention

Luigi Ballabio
Right, this case is not covered. You're giving a nice workout to
Schedule... I'm starting to think that we should have a number of
different generating functions, instead of just one taking different
combinations of parameters...

Luigi


On Fri, Jun 6, 2014 at 11:21 AM, Francois Botha <[hidden email]> wrote:

> If I use end-of-month = false, then the dates generated will be either 30
> March (not 31) and 30 September, right? Maturity date is 30 September 2021
> in this case.
>
> Francois Botha
>
>
> On 6 June 2014 11:19, Luigi Ballabio <[hidden email]> wrote:
>>
>> In this case you wouldn't use end-of-month = true.
>>
>> On Fri, Jun 6, 2014 at 11:16 AM, Francois Botha <[hidden email]> wrote:
>> > Yes, that is what I want.
>> >
>> > This specific bond pays coupons on 31 March and 30 September each year,
>> > and
>> > if those days fall on a non-business day, the next business day is used.
>> > So
>> > instead 2017-09-30 falls on a Saturday, so the coupon will pay on
>> > 2017-10-02.
>> >
>> > I understood that I could use 'Following' instead of 'Modified
>> > Following' if
>> > I want to allow crossing over to the next month.
>> >
>> > Francois Botha
>> >
>> >
>> > On 6 June 2014 11:01, Luigi Ballabio <[hidden email]> wrote:
>> >>
>> >> You want the last business day of the month, so you take the last day
>> >> of the month and adjust it backwards. If you adjusted it forward,
>> >> you'd get the first business day of the following month instead.
>> >>
>> >> Luigi
>> >>
>> >> On Fri, Jun 6, 2014 at 10:56 AM, Francois Botha <[hidden email]>
>> >> wrote:
>> >> > Hi,
>> >> >
>> >> > In schedule.cpp, lines 349 - 355:
>> >> >
>> >> >             if (convention == Unadjusted) {
>> >> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >> >                     dates_[i] = Date::endOfMonth(dates_[i]);
>> >> >             } else {
>> >> >                 for (Size i=1; i<dates_.size()-1; ++i)
>> >> >                     dates_[i] = calendar_.endOfMonth(dates_[i]);
>> >> >             }
>> >> >
>> >> > And calendar.hpp: lines 207-209:
>> >> >
>> >> >     inline Date Calendar::endOfMonth(const Date& d) const {
>> >> >         return adjust(Date::endOfMonth(d), Preceding);
>> >> >     }
>> >> >
>> >> > This is applicable when the endOfMonth rule is true. If the business
>> >> > day
>> >> > convention is Unadjusted, it works fine, but if the business day
>> >> > convention
>> >> > is e.g. Modified Following, the second part of the code is executed.
>> >> > But
>> >> > calendar_.endOfMonth is hardcoded to use Preceding. The actual
>> >> > business
>> >> > day
>> >> > convention isn't passed through. Is this a bug or maybe I don't
>> >> > understand
>> >> > something?
>> >> >
>> >> > regards
>> >> > Francois Botha
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------------------------------------------------
>> >> > Learn Graph Databases - Download FREE O'Reilly Book
>> >> > "Graph Databases" is the definitive new guide to graph databases and
>> >> > their
>> >> > applications. Written by three acclaimed leaders in the field,
>> >> > this first edition is now available. Download your free book today!
>> >> > http://p.sf.net/sfu/NeoTech
>> >> > _______________________________________________
>> >> > QuantLib-dev mailing list
>> >> > [hidden email]
>> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> <https://implementingquantlib.blogspot.com>
>> >> <https://twitter.com/lballabio>
>> >
>> >
>>
>>
>>
>> --
>> <https://implementingquantlib.blogspot.com>
>> <https://twitter.com/lballabio>
>
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev