Re: How to calculate IRR using Cashflows:yield()

Posted by Peter Caspers-2 on
URL: http://quantlib.414.s1.nabble.com/How-to-calculate-IRR-using-Cashflows-yield-tp8734p8735.html

Hello Kenneth,

        Leg l;
        Date d = Settings::instance().evaluationDate();
        l.push_back(boost::shared_ptr<CashFlow>(new SimpleCashFlow(-1.0,d)));
        l.push_back(boost::shared_ptr<CashFlow>(new SimpleCashFlow(1.05,TARGET().advance(d,1*Years))));
        std::cout << "yield = " << CashFlows::yield(l,0.0,Actual365Fixed(),Continuous,NoFrequency,true,d,d) << std::endl;

is a simple example.

By the way, I think there is a litte bug in lines 625 and following in cashflows.cpp, which should be

            if (settlementDate == Date())
                settlementDate_ = Settings::instance().evaluationDate();

                if (npvDate == Date())
                    npvDate_ = settlementDate;

otherwise you can not leave out the defaulted parameters settlementDate und npvDate in the yield( ) - call.

Peter


Am 13.02.2012 09:35, schrieb Kenneth.Xiao.Jun Wang:
Hi All, 

I'm new to Quantlib. I want to calculate IRR of cash flows using  the QuantLib::CashFlows::yield() function.  But there is no examples about how to use the class QuantLib::CashFlows in the Examples folder. I don't know how to deal with it.  Do you have any example about this?

Thanks very much!

Kenneth







------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users