Date problem in swaptionhelper.cpp

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

Date problem in swaptionhelper.cpp

Perissin Francesco
Hi,
I see a problem in the current implementation of the class SwaptionHelper:
when the value date is close to the end of month, the class gives an error
like: "Start date is Holiday and end of month" on some market swaptions.

This is caused by the definition of start date in line 59 in
ql/ShortRateModels/CalibrationHelpers/swaptionhelper.cpp, which does not
adjust for the holidays.

At the moment in Ql 0.3.0 and also in CVS the line is:

Date startDate = termStructure->settlementDate(). plus(maturity.length(),
maturity.units());


The line should be changed in something like

Date startDate =
termStructure->calendar().advance(termStructure->settlementDate(),
                    maturity.length(), maturity.units());



which works fine. I am not able to commit the change.

Ciao


     Francesco Perissin
          Derivatives Team
     Banca del Gottardo
          Via R. Simen 14
    6900 Lugano (Switzerland)
  Direct line: +41 91 808 37 30
           Fax: +41 91 808 24 43



--
############################### DISCLAIMER #################################

This  message  (including  any  attachments)  is  confidential  and  may be
privileged.  If you have received it by mistake please notify the sender by
return  e-mail  and  delete this message from your system. Any unauthorised
use  or  dissemination  of  this  message  in  whole or in part is strictly
prohibited.  Please  note  that e-mails are susceptible to change. Banca del
Gottardo (including  its  group  companies)  shall not be liable for the
improper  or  incomplete  transmission of the information contained in this
communication  nor  for  any delay in its receipt or damage to your system.
Banca del Gottardo  (or its group companies) does not guarantee that the
integrity   of  this  communication  has  been  maintained  nor  that  this
communication is free of viruses, interceptions or interference.

############################################################################


Reply | Threaded
Open this post in threaded view
|

Re: Date problem in swaptionhelper.cpp

Luigi Ballabio-2
At 04:54 PM 9/26/02 +0200, Perissin Francesco wrote:
>I see a problem in the current implementation of the class SwaptionHelper:

I committed the fix. Thanks!

Bye,
         Luigi



Reply | Threaded
Open this post in threaded view
|

Compilation Bug in Quantlib Array

Bill Shortall
Hi Folks,

  I am experiencing compilation problems with
  Microsoft VC6 on quantlib section Array.h.
    It compiles and runs fine in DEBUG mode but
 in release mode it generates errors. The
 problem is only experienced when running
 with expression templates turned off. The bug
 seems to be in sections like

  inline Array Abs(const Array& v) {
            Array result(v.size());
            std::transform(v.begin(),v.end(),result.begin(),
                std::ptr_fun(QL_FABS));
       
            return result;
        }

 where QL_FABS is abs  the std C function. I believe
 the problem is in the std::ptr_fun  it won't run in
 release mode  gives strange error messages like not enough
 arguments.Since its function is to make abs derive from
 std::unary function the trick is to do it the long way.
 Replace the above code with


  template <class T1, class T2>
  struct qlfabs : public std::unary_function<T1, T2>
  {  T1 operator() (T2 x ) const
   {return ::abs(x) ; }
  };


        inline Array Abs(const Array& v) {
            Array result(v.size());
            std::transform(v.begin(),v.end(),result.begin(),
                //std::ptr_fun(QL_FABS));
        qlfabs<double, double>());
            return result;
        }


  You also have to do this with Sqrt, Log,and Exp.  
 
  Regards...Bill




Reply | Threaded
Open this post in threaded view
|

Re: Compilation Bug in Quantlib Array

Luigi Ballabio-2
Hi Bill,

At 11:08 AM -0400 9/28/02, Bill wrote:
>  I am experiencing compilation problems with
>  Microsoft VC6 on quantlib section Array.h.
>  I believe the problem is in the std::ptr_fun  it won't run in
>  release mode  gives strange error messages like not enough
>  arguments.

Hmm. Could you send me the error, to see if I can make head or tail of it?


>Since its function is to make abs derive from
>  std::unary function the trick is to do it the long way.
>  Replace the above code with
>
>
>   template <class T1, class T2>
>   struct qlfabs : public std::unary_function<T1, T2>
>   {  T1 operator() (T2 x ) const
>    {return ::abs(x) ; }
>   };
>
>         inline Array Abs(const Array& v) {
>             Array result(v.size());
>             std::transform(v.begin(),v.end(),result.begin(),
>                 //std::ptr_fun(QL_FABS));
>         qlfabs<double, double>());
>             return result;
>         }
>
>
>   You also have to do this with Sqrt, Log,and Exp.

Well, the purpose of using std::ptr_fun was brevity. If it gives
problems, I guess the next simplest way would be to write

         inline Array Abs(const Array& v) {
             Array result(v.size());
             for (unsigned i=0; i<v.size(); i++)
                 result[i] = QL_FABS(v[i]);
             return result;
         }

Thanks for the report,
                        Luigi


Reply | Threaded
Open this post in threaded view
|

Re: Compilation Bug in Quantlib Array

Bill Shortall
Hi Luigi,

Here is the error message it points to the line where
   std::ptr_fun(QL_FABS)  appears  and only happens in release mode
not in debug and when expression templates are off

Compiling...
main.cpp
C:\Cprogs\Expression Templates\Quantlib\array.h(1343) : error C2780: '_OI
__cdecl std::transform(_II1,_II1,_II2,_OI,_Bop)' : expects 5 arguments - 4
provided
        C:\Language\Microsoft Visual Studio\VC98\INCLUDE\algorithm(247) :
see declaration of 'transform'
Error executing cl.exe.

msft1.exe - 1 error(s), 0 warning(s)


----- Original Message -----
From: "Luigi Ballabio" <[hidden email]>
To: "Bill" <[hidden email]>; <[hidden email]>
Sent: Sunday, September 29, 2002 7:07 AM
Subject: Re: [Quantlib-users] Compilation Bug in Quantlib Array


>
> Hi Bill,
>
> At 11:08 AM -0400 9/28/02, Bill wrote:
> >  I am experiencing compilation problems with
> >  Microsoft VC6 on quantlib section Array.h.
> >  I believe the problem is in the std::ptr_fun  it won't run in
> >  release mode  gives strange error messages like not enough
> >  arguments.
>
> Hmm. Could you send me the error, to see if I can make head or tail of it?
>
>
> >Since its function is to make abs derive from
> >  std::unary function the trick is to do it the long way.
> >  Replace the above code with
> >
> >
> >   template <class T1, class T2>
> >   struct qlfabs : public std::unary_function<T1, T2>
> >   {  T1 operator() (T2 x ) const
> >    {return ::abs(x) ; }
> >   };
> >
> >         inline Array Abs(const Array& v) {
> >             Array result(v.size());
> >             std::transform(v.begin(),v.end(),result.begin(),
> >                 //std::ptr_fun(QL_FABS));
> >         qlfabs<double, double>());
> >             return result;
> >         }
> >
> >
> >   You also have to do this with Sqrt, Log,and Exp.
>
> Well, the purpose of using std::ptr_fun was brevity. If it gives
> problems, I guess the next simplest way would be to write
>
>          inline Array Abs(const Array& v) {
>              Array result(v.size());
>              for (unsigned i=0; i<v.size(); i++)
>                  result[i] = QL_FABS(v[i]);
>              return result;
>          }
>
> Thanks for the report,
> Luigi
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>