QuantLibXL Russian Calendar

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

QuantLibXL Russian Calendar

Kirill Shemyakin
Hi, guys!

Is there any plan to add Russian calendar into QuantlibXL?

It's a bit tiresomely to add Russian holidays manually.

Thanks!

Best regards,
Kirill


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Hyung-Seok Hahm
 Hi,

I do not know who is going to add the Russian calendar to QuantLibXL, but here is what I did to add South Korean calendar.

1. Open up time/calendar/southkorea.cpp

2. Get the next x-years' calendar. Luckily if you have access to Bloomberg, you can easily look it up.

3. Add holidays manually in southkorea.cpp. There is no pattern in South Korean calendar as we follow lunar convention, but if you have a pattern in Russian calendar like united states, it would not be terrible. 

4. Compile and deploy QuantLibXL.

5. If you add a newly-compiled xll to your excel, it will show up.

BTW, in my version of russian calendar, russia.cpp is 

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2010 StatPro Italia srl

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <[hidden email]>. The license is also available online at

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/time/calendars/russia.hpp>
#include <ql/errors.hpp>

namespace QuantLib {

    Russia::Russia() {
        // all calendar instances share the same implementation
        // instance
        static boost::shared_ptr<Calendar::Impl> settlementImpl(
                                                  new Russia::SettlementImpl);
        impl_ = settlementImpl;
    }


    bool Russia::SettlementImpl::isBusinessDay(const Date& date) const {
        Weekday w = date.weekday();
        Day d = date.dayOfMonth();
        Month m = date.month();
        if (isWeekend(w)
            // New Year's holidays
            || (d >= 1 && d <= 10 && m == January)
            // Defender of the Fatherland Day (possibly moved to Monday)
            || ((d == 23 || ((d == 24 || d == 25) && w == Monday)) &&
                m == February)
            // International Women's Day (possibly moved to Monday)
            || ((d == 8 || ((d == 9 || d == 10) && w == Monday)) &&
                m == March)
            // Labour Day (possibly moved to Monday)
            || ((d == 1 || ((d == 2 || d == 3) && w == Monday)) &&
                m == May)
            // Victory Day (possibly moved to Monday)
            || ((d == 9 || ((d == 10 || d == 11) && w == Monday)) &&
                m == May)
            // Russia Day (possibly moved to Monday)
            || ((d == 12 || ((d == 13 || d == 14) && w == Monday)) &&
                m == June)
            // Unity Day (possibly moved to Monday)
            || ((d == 4 || ((d == 5 || d == 6) && w == Monday)) &&
                m == November))
            return false;
        return true;
    }

}

Looks like some part of it has already been implemented, Doesn't look so terrible. 

Hope this helps.

- Hyung


-- 

Hyungseok Hahm, PhD, FRM   

Quantitative Analyst 

Industrial Bank of Korea

Trading Department

Tel      : 82-2-729-7081

Fax       : 82-2-729-6084

E-mail  : [hidden email]

Yahoo Msn : hyungseok.hahm

Google Talk : hs.hahm.ibk[hidden email]

LinkedIn: http://kr.linkedin.com/pub/dir/Hyung-seok/Hahm


On Mon, Jun 11, 2012 at 9:14 PM, Kirill Shemyakin <[hidden email]> wrote:
Hi, guys!

Is there any plan to add Russian calendar into QuantlibXL?

It's a bit tiresomely to add Russian holidays manually.

Thanks!

Best regards,
Kirill


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users





------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Luigi Ballabio
In reply to this post by Kirill Shemyakin
The calendar is already defined in QuantLib, so it might have been an oversight.

Exporting it from QuantLibXL should be just a matter to add the
relevant entry to the
QuantLibAddin/gensrc/metadata/enumerations/enumeratedtypes.xml.  If
you open it, you'll find a part of the file where the calendars are
listed.  You can add the entry for Russia there and rebuild the addin,
at which point the calendar should be available.

If it works, send me a patch and I'll add it to next release.

Luigi


On Mon, Jun 11, 2012 at 2:14 PM, Kirill Shemyakin <[hidden email]> wrote:

> Hi, guys!
>
> Is there any plan to add Russian calendar into QuantlibXL?
> http://quantlib.org/quantlibxl/enums.html#enum_type_3
>
> It's a bit tiresomely to add Russian holidays manually.
>
> Thanks!
>
> Best regards,
> Kirill
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Kirill Shemyakin
Luigi,

Sorry, for the late answer. Yes, maybe, that's the thing.
I'm currently building the Add-in. Does it take so long time? I'm just newby...

The january holidays in Russia are from 1st to 8th. I've added that.
Here are the patch files.

Best regards,
Kirill


On 12 June 2012 13:55, Luigi Ballabio <[hidden email]> wrote:
The calendar is already defined in QuantLib, so it might have been an oversight.

Exporting it from QuantLibXL should be just a matter to add the
relevant entry to the
QuantLibAddin/gensrc/metadata/enumerations/enumeratedtypes.xml.  If
you open it, you'll find a part of the file where the calendars are
listed.  You can add the entry for Russia there and rebuild the addin,
at which point the calendar should be available.

If it works, send me a patch and I'll add it to next release.

Luigi


On Mon, Jun 11, 2012 at 2:14 PM, Kirill Shemyakin <[hidden email]> wrote:
> Hi, guys!
>
> Is there any plan to add Russian calendar into QuantlibXL?
> http://quantlib.org/quantlibxl/enums.html#enum_type_3
>
> It's a bit tiresomely to add Russian holidays manually.
>
> Thanks!
>
> Best regards,
> Kirill
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

russia.cpp (3K) Download Attachment
russia.hpp (2K) Download Attachment
enumeratedtypes.xml (80K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Kirill Shemyakin
Luigi,

If it isn't difficult, please, send me the built add-in with Russian calendar.
Many thanks!

Kirill

On 12 June 2012 23:02, Kirill Shemyakin <[hidden email]> wrote:
Luigi,

Sorry, for the late answer. Yes, maybe, that's the thing.
I'm currently building the Add-in. Does it take so long time? I'm just newby...

The january holidays in Russia are from 1st to 8th. I've added that.
Here are the patch files.

Best regards,
Kirill


On 12 June 2012 13:55, Luigi Ballabio <[hidden email]> wrote:
The calendar is already defined in QuantLib, so it might have been an oversight.

Exporting it from QuantLibXL should be just a matter to add the
relevant entry to the
QuantLibAddin/gensrc/metadata/enumerations/enumeratedtypes.xml.  If
you open it, you'll find a part of the file where the calendars are
listed.  You can add the entry for Russia there and rebuild the addin,
at which point the calendar should be available.

If it works, send me a patch and I'll add it to next release.

Luigi


On Mon, Jun 11, 2012 at 2:14 PM, Kirill Shemyakin <[hidden email]> wrote:
> Hi, guys!
>
> Is there any plan to add Russian calendar into QuantlibXL?
> http://quantlib.org/quantlibxl/enums.html#enum_type_3
>
> It's a bit tiresomely to add Russian holidays manually.
>
> Thanks!
>
> Best regards,
> Kirill
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Kirill Shemyakin
In reply to this post by Luigi Ballabio
Luigi,

Thank you a lot! Everyting works fine. 'register_types.cpp' must be also modified.

Best regards,
Kirill

On 12 June 2012 13:55, Luigi Ballabio <[hidden email]> wrote:
The calendar is already defined in QuantLib, so it might have been an oversight.

Exporting it from QuantLibXL should be just a matter to add the
relevant entry to the
QuantLibAddin/gensrc/metadata/enumerations/enumeratedtypes.xml.  If
you open it, you'll find a part of the file where the calendars are
listed.  You can add the entry for Russia there and rebuild the addin,
at which point the calendar should be available.

If it works, send me a patch and I'll add it to next release.

Luigi


On Mon, Jun 11, 2012 at 2:14 PM, Kirill Shemyakin <[hidden email]> wrote:
> Hi, guys!
>
> Is there any plan to add Russian calendar into QuantlibXL?
> http://quantlib.org/quantlibxl/enums.html#enum_type_3
>
> It's a bit tiresomely to add Russian holidays manually.
>
> Thanks!
>
> Best regards,
> Kirill
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

enumeratedtypes.xml (80K) Download Attachment
russia.cpp (3K) Download Attachment
russia.hpp (2K) Download Attachment
register_types.cpp (56K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: QuantLibXL Russian Calendar

Luigi Ballabio
'register_types.cpp' is generated automatically, so running gensrc
after modifying enumeratedtypes.xml will change it as required (you
might have missed this step).

Glad to hear it worked, anyway.  I'll add your patch.

Luigi

On Tue, Jun 12, 2012 at 11:08 PM, Kirill Shemyakin <[hidden email]> wrote:

> Luigi,
>
> Thank you a lot! Everyting works fine. 'register_types.cpp' must be also
> modified.
>
> Best regards,
> Kirill
>
> On 12 June 2012 13:55, Luigi Ballabio <[hidden email]> wrote:
>>
>> The calendar is already defined in QuantLib, so it might have been an
>> oversight.
>>
>> Exporting it from QuantLibXL should be just a matter to add the
>> relevant entry to the
>> QuantLibAddin/gensrc/metadata/enumerations/enumeratedtypes.xml.  If
>> you open it, you'll find a part of the file where the calendars are
>> listed.  You can add the entry for Russia there and rebuild the addin,
>> at which point the calendar should be available.
>>
>> If it works, send me a patch and I'll add it to next release.
>>
>> Luigi
>>
>>
>> On Mon, Jun 11, 2012 at 2:14 PM, Kirill Shemyakin <[hidden email]>
>> wrote:
>> > Hi, guys!
>> >
>> > Is there any plan to add Russian calendar into QuantlibXL?
>> > http://quantlib.org/quantlibxl/enums.html#enum_type_3
>> >
>> > It's a bit tiresomely to add Russian holidays manually.
>> >
>> > Thanks!
>> >
>> > Best regards,
>> > Kirill
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Live Security Virtual Conference
>> > Exclusive live event will cover all the ways today's security and
>> > threat landscape has changed and how IT managers can respond.
>> > Discussions
>> > will include endpoint security, mobile security and the latest in
>> > malware
>> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> > _______________________________________________
>> > QuantLib-users mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>> >
>
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users