Problem setting the evaluation date on AIX for 64 bit application

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

Problem setting the evaluation date on AIX for 64 bit application

Rohit Rai
Hi
 
I am using Quantlib 0.9.7 for my Application.
 
And i set the evaluation date to 31 December 2008 for Fixed Rate Bond.
When i print the settlement date , for Window the Settlement Date is fine ..which is January 1st, 2009
But for AIX 64 bit application, the Settlement Date is bit weird...which comes out to be January 24th, 2011.
I guess , its pointing to the current date rather than taking the date which i have set to i.e. 31-December-2008.
 
Attaching the log file for both the Platforms.
 
Please guide me regarding this issue. Its having a huge impact on my application.
 
 
 
 
The code is given below:
 
cout<<" Fic Mis Date in Initialize Method: "<<this->mMisdate<<endl;
Settings::instance().evaluationDate() = this->mMisdate;
try
{
 Handle<YieldTermStructure> discountCurve(boost::shared_ptr<YieldTermStructure>(
  new ZeroCurve(instrumentInfoObj.vTermstructureDates,instrumentInfoObj.vTermstructureRates,instrumentInfoObj.dayCounter)));
 boost::shared_ptr<PricingEngine> bondEngine(new DiscountingBondEngine(discountCurve));
 Date effectiveDate = instrumentInfoObj.issueDate+instrumentInfoObj.settlementDays;
 cout<<" Effective Date "<<effectiveDate<<endl;
   cout<<" Issue Date "<<instrumentInfoObj.issueDate<<endl;
   cout<<" Settlement Days "<<instrumentInfoObj.settlementDays<<endl;
 cout<<" Maturity Date "<<instrumentInfoObj.maturityDate<<endl;
 Schedule schedule(effectiveDate,
  instrumentInfoObj.maturityDate,
  (QuantLib::Period)instrumentInfoObj.couponFrequency,
  instrumentInfoObj.calendar,
  QuantLib::Following,
  QuantLib::Following,
  DateGeneration::Forward,
  false);
  cout<<"Account Skey -------> "<<instrumentInfoObj.acctSkey<<"    COUPON RATE-------->"<<instrumentInfoObj.couponRate<<endl;

 this->mptrFixedRateBond = new FixedRateBond (instrumentInfoObj.settlementDays,
  100,
  schedule,
  vector<double> (1,instrumentInfoObj.couponRate),
  instrumentInfoObj.dayCounter,
  QuantLib::Following,
  100,
  instrumentInfoObj.issueDate);
 this->mptrFixedRateBond->setPricingEngine(bondEngine);
 cout.precision(10);
   cout<<"NPV "<<this->mptrFixedRateBond->NPV()<<endl;
   cout<<"Settlement Date:"<<this->mptrFixedRateBond->settlementDate()<<endl;
   cout<<"Issue Date:"<<this->mptrFixedRateBond->issueDate()<<endl;
 cout<<"Maturity Date:"<<this->mptrFixedRateBond->maturityDate()<<endl;
 return ClsUConstants::TASK_SUCCESS;
 
 
 
Regards
Rohit


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

WindowLog2.txt (2K) Download Attachment
AIXLog1.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem setting the evaluation date on AIX for 64 bit application

Geetika
This post was updated on .
Hi..

Even i am also facing the same Issue. The evalaution Date setting even doesn;t work for me.
And the NPV for the Instrument arrives to be zero on AIX machine for 64 bit build. I havn't checked for 32 bit.

Really looking for the solution..
I am using Quantlib 0.9.7 and even tried with the latest code.

Anyone ..who can clarify what this issue is??

Regards
Geetika








Rohit Rai wrote
Hi

I am using Quantlib 0.9.7 for my Application.

And i set the evaluation date to 31 December 2008 for Fixed Rate Bond.
When i print the settlement date , for Window the Settlement Date is fine
..which is January 1st, 2009
But for AIX 64 bit application, the Settlement Date is bit weird...which comes
out to be January 24th, 2011.
I guess , its pointing to the current date rather than taking the date which i
have set to i.e. 31-December-2008.

Attaching the log file for both the Platforms.

Please guide me regarding this issue. Its having a huge impact on my
application.




The code is given below:

cout<<" Fic Mis Date in Initialize Method: "<<this->mMisdate<<endl;
Settings::instance().evaluationDate() = this->mMisdate;
try
{
 Handle<YieldTermStructure> discountCurve(boost::shared_ptr<YieldTermStructure>(
  new
ZeroCurve(instrumentInfoObj.vTermstructureDates,instrumentInfoObj.vTermstructureRates,instrumentInfoObj.dayCounter)));

 boost::shared_ptr<PricingEngine> bondEngine(new
DiscountingBondEngine(discountCurve));
 Date effectiveDate =
instrumentInfoObj.issueDate+instrumentInfoObj.settlementDays;
 cout<<" Effective Date "<<effectiveDate<<endl;
   cout<<" Issue Date "<<instrumentInfoObj.issueDate<<endl;
   cout<<" Settlement Days "<<instrumentInfoObj.settlementDays<<endl;
 cout<<" Maturity Date "<<instrumentInfoObj.maturityDate<<endl;
 Schedule schedule(effectiveDate,
  instrumentInfoObj.maturityDate,
  (QuantLib::Period)instrumentInfoObj.couponFrequency,
  instrumentInfoObj.calendar,
  QuantLib::Following,
  QuantLib::Following,
  DateGeneration::Forward,
  false);
  cout<<"Account Skey -------> "<<instrumentInfoObj.acctSkey<<"    COUPON
RATE-------->"<<instrumentInfoObj.couponRate<<endl;

 this->mptrFixedRateBond = new FixedRateBond (instrumentInfoObj.settlementDays,
  100,
  schedule,
  vector<double> (1,instrumentInfoObj.couponRate),
  instrumentInfoObj.dayCounter,
  QuantLib::Following,
  100,
  instrumentInfoObj.issueDate);
 this->mptrFixedRateBond->setPricingEngine(bondEngine);
 cout.precision(10);
   cout<<"NPV "<<this->mptrFixedRateBond->NPV()<<endl;
   cout<<"Settlement Date:"<<this->mptrFixedRateBond->settlementDate()<<endl;
   cout<<"Issue Date:"<<this->mptrFixedRateBond->issueDate()<<endl;
 cout<<"Maturity Date:"<<this->mptrFixedRateBond->maturityDate()<<endl;
 return ClsUConstants::TASK_SUCCESS;



Regards
Rohit


------------------------------------Log File For MDurationExec-------------------------------------
----------------------------------------------------------------------------------------------------
                       Generation of MDurationExec Log started on : Tue Jan 18 23:42:21 2011
----------------------------------------------------------------------------------------------------

SMSDetails:
        Config File Path     :
        Log File Path        :
        Date Format          :
        Config User ID       : confrevdemo4
        Config Database Name : ORCL85
        User ID              : revuser4
        Database Name        : ORCL85
        Database Type        : ORACLE
        Database Locale      :

MIS Date: 20081231
Run Skey: 283

Started Config XML Parsing
Config XML Parsing Completed

End of Cursor
OCI_NO_DATA
Error Msg :-> 
No of Rows Selected :22

[ClsUNPVMD]-> Info: Instrument Details Population Successful

End of Cursor
OCI_NO_DATA
Error Msg :->
No of Rows Selected :180

[ClsUNPVMD]-> Info: Term Structure Details Population Successful

 Fic Mis Date in Initialize Method: December 31st, 2008
NPV 103.7561416
Settlement Date:January 1st, 2009
Issue Date:December 1st, 2006
Maturity Date:January 28th, 2010

[ClsUNPVMD]-> Info: NPV Calculation And Modified Duration Calculation Successful


[ClsUNPVMD]-> Info: Update Table Successful


----------------------------------------------------------------------------------------------------
                     End of MDurationExec Operations : Tue Jan 18 23:42:22 2011
----------------------------------------------------------------------------------------------------

------------------------------------Log File For MDurationExec-------------------------------------
----------------------------------------------------------------------------------------------------
                       Generation of MDurationExec Log started on : Tue Jan 18 23:53:21 2011
----------------------------------------------------------------------------------------------------

SMSDetails:
        Config File Path     : /home/revdemo4/ftpshare/ERMPROD/erwin/model/
        Log File Path        : /home/revdemo4/ftpshare/ERMPROD/logs
        Date Format          : mm-dd-yyyy
        Config User ID       : confrevdemo4
        Config Database Name : orcl
        User ID              : revuser4
        Database Name        : revuser4
        Database Type        : ORACLE
        Database Locale      : AMERICAN_AMERICA.US7ASCII

MIS Date: 20081231
Run Skey: 283

Started Config XML Parsing
Config XML Parsing Completed

End of Cursor
OCI_NO_DATA
Error Msg :->
No of Rows Selected :22

[ClsUNPVMD]-> Info: Instrument Details Population Successful

End of Cursor
OCI_NO_DATA
Error Msg :->
No of Rows Selected :180

[ClsUNPVMD]-> Info: Term Structure Details Population Successful

 Fic Mis Date in Initialize Method: December 31st, 2008
NPV 0
Settlement Date:January 20th, 2011
Issue Date:December 1st, 2006
Maturity Date:January 28th, 2010

[ClsUFixedRateBond]-> Error: Modified Duration Calculation Failed
Account Skey : 14354

../../ql/math/solver1d.hpp:199: In function `QuantLib::Solver1D<QuantLib::Brent>::solve<QuantLib::<unnamed>::YieldFinder>(const YieldFinder &, Real, Real, Real, Real) const':
root not bracketed: f[0,1] -> [NaNQ,NaNQ]

[ClsUNPVMD]-> Error: NPV Calculation OR Modified Duration Calculation Failed


[Main]-> Error: Terminating MDurationExec

----------------------------------------------------------------------------------------------------
                     End of MDurationExec Operations : Tue Jan 18 23:53:21 2011
----------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem setting the evaluation date on AIX for 64 bit application

Luigi Ballabio
In reply to this post by Rohit Rai
On Sun, 2011-01-23 at 13:35 +0530, Rohit Rai wrote:
> I am using Quantlib 0.9.7 for my Application.
>  
> And i set the evaluation date to 31 December 2008 for Fixed Rate Bond.
> When i print the settlement date , for Window the Settlement Date is
> fine ..which is January 1st, 2009
> But for AIX 64 bit application, the Settlement Date is bit
> weird...which comes out to be January 24th, 2011.
> I guess , its pointing to the current date rather than taking the date
> which i have set to i.e. 31-December-2008.

It looks like a singleton not working.
May you try replacing ql/patterns/singleton.hpp with the one I'm
attaching, recompile and try again?

Let me know if that works, so we can add the patch to next release.
Also, is there any compiler define (to be used in a #ifdef) that lets
one detect that one's on AIX?

Thanks,
        Luigi


--

Within C++, there is a much smaller and cleaner language struggling to
get out.
-- Bjarne Stroustrup


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

singleton.hpp (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem setting the evaluation date on AIX for 64 bit application

Rohit Rai
Hi Luigi

Thanks for your reply.
I tried with the singleton.hpp file attached in the mail. I took the complete build and pointed to the Application. When i create the  FixedRateBond object , the application gets hanged at this point of time, and  neither it releases the memory(doesn't comes out of the process) nor it fails eventhough i have enabled the error line , infact all the options at the time of running the configure file.  The Compiler flag is set to export CXXFLAGS='-qrtti=all'.

Also when i set the Compiler Flag to export CXXFLAGS='-qrtti=all -fvisibility=default -qcheck=all', the Application release memory(process ends) but i don't get any Quantlib exception or error message.
default fvisibility flag is Hidden and that is set to default. Reference : http://osdir.com/ml/finance.quantlib.user/2007-11/msg00054.html#
qcheck flag is set so as to check the Null Pointer, object bounds and divisibility by zero at run time.

Any idea regarding this? Am i missing any compiler option?
Please help on this regard

Also #ifdef for AIX used is

#### Uncomment only one of the flags below
#### FICPLATFORM        = -DAIX5L -D__UNIX__

# Uncomment for AIX5.2
FICPLATFORM         = -DAIX5L -D__UNIX__ -D__AIX52__    // Since i am using AIX5.2


Regards
Rohit.



From: Luigi Ballabio <[hidden email]>
To: Rohit Rai <[hidden email]>
Cc: [hidden email]
Sent: Tue, 25 January, 2011 4:02:30 PM
Subject: Re: Problem setting the evaluation date on AIX for 64 bit application

On Sun, 2011-01-23 at 13:35 +0530, Rohit Rai wrote:
> I am using Quantlib 0.9.7 for my Application.

> And i set the evaluation date to 31 December 2008 for Fixed Rate Bond.
> When i print the settlement date , for Window the Settlement Date is
> fine ..which is January 1st, 2009
> But for AIX 64 bit application, the Settlement Date is bit
> weird...which comes out to be January 24th, 2011.
> I guess , its pointing to the current date rather than taking the date
> which i have set to i.e. 31-December-2008.

It looks like a singleton not working.
May you try replacing ql/patterns/singleton.hpp with the one I'm
attaching, recompile and try again?

Let me know if that works, so we can add the patch to next release.
Also, is there any compiler define (to be used in a #ifdef) that lets
one detect that one's on AIX?

Thanks,
    Luigi


--

Within C++, there is a much smaller and cleaner language struggling to
get out.
-- Bjarne Stroustrup



------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem setting the evaluation date on AIX for 64 bit application

Geetika
In reply to this post by Luigi Ballabio
Hi Luigi

I have also tried with the singleton file posted by  you. The appilcation gets stuck in between.
Is this the problem due to multiple instance setting for evaluation Date ???

Regards
Geetika


Luigi Ballabio wrote
On Sun, 2011-01-23 at 13:35 +0530, Rohit Rai wrote:
> I am using Quantlib 0.9.7 for my Application.
>  
> And i set the evaluation date to 31 December 2008 for Fixed Rate Bond.
> When i print the settlement date , for Window the Settlement Date is
> fine ..which is January 1st, 2009
> But for AIX 64 bit application, the Settlement Date is bit
> weird...which comes out to be January 24th, 2011.
> I guess , its pointing to the current date rather than taking the date
> which i have set to i.e. 31-December-2008.

It looks like a singleton not working.
May you try replacing ql/patterns/singleton.hpp with the one I'm
attaching, recompile and try again?

Let me know if that works, so we can add the patch to next release.
Also, is there any compiler define (to be used in a #ifdef) that lets
one detect that one's on AIX?

Thanks,
        Luigi


--

Within C++, there is a much smaller and cleaner language struggling to
get out.
-- Bjarne Stroustrup


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

/*
 Copyright (C) 2004, 2005, 2007 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
 <quantlib-dev@lists.sf.net>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 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.
*/

/*! \file singleton.hpp
    \brief basic support for the singleton pattern
*/

#ifndef quantlib_singleton_hpp
#define quantlib_singleton_hpp

#include <ql/types.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <map>

namespace QuantLib {

    #if defined(QL_ENABLE_SESSIONS)
    // definition must be provided by the user
    Integer sessionId();
    #endif

    // this is required on VC++ (with a slightly different syntax depending
    // on the compiler version) when CLR support is enabled
    #if defined(QL_PATCH_MSVC71)
        #pragma unmanaged
    #elif defined(QL_PATCH_MSVC)
        #pragma managed(push, off)
    #endif

    //! Basic support for the singleton pattern.
    /*! The typical use of this class is:
        \code
        class Foo : public Singleton<Foo> {
            friend class Singleton<Foo>;
          private:
            Foo() {}
          public:
            ...
        };
        \endcode
        which, albeit sub-optimal, frees one from the concerns of
        creating and managing the unique instance and can serve later
        as a single implemementation point should synchronization
        features be added.

        \ingroup patterns
    */
    template <class T>
    class Singleton : private boost::noncopyable {
      public:
        //! access to the unique instance
        static T& instance();
      protected:
        Singleton() {}
      private:
        static std::map<Integer, boost::shared_ptr<T> > instances_;
    };

    // template definitions

    template <class T>
    std::map<Integer, boost::shared_ptr<T> > Singleton<T>::instances_;

    template <class T>
    T& Singleton<T>::instance() {
        #if defined(QL_ENABLE_SESSIONS)
        Integer id = sessionId();
        #else
        Integer id = 0;
        #endif
        boost::shared_ptr<T>& instance = instances_[id];
        if (!instance)
            instance = boost::shared_ptr<T>(new T);
        return *instance;
    }

    // reverts the change above
    #if defined(QL_PATCH_MSVC71)
        #pragma managed
    #elif defined(QL_PATCH_MSVC)
        #pragma managed(pop)
    #endif

}


#endif

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem setting the evaluation date on AIX for 64 bit application

Luigi Ballabio
In reply to this post by Rohit Rai
On Wed, 2011-01-26 at 14:01 +0530, Rohit Rai wrote:
> I tried with the singleton.hpp file attached in the mail. [...] the
> application hangs

Hmm.  May you try the original singleton.hpp with all optimizations off?
(it would be -O0 on gcc.)

Also, are you running configure with the --enable-sessions or not?

Thanks again,
        Luigi


--

Better to remain silent and be thought a fool than to speak out and
remove all doubt.
-- Abraham Lincoln



------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users