How to calculate IRR using Cashflows:yield()

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

How to calculate IRR using Cashflows:yield()

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
Reply | Threaded
Open this post in threaded view
|

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

Peter Caspers-2
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
Reply | Threaded
Open this post in threaded view
|

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

Luigi Ballabio
On Tue, Feb 14, 2012 at 9:53 PM, Peter Caspers <[hidden email]> wrote:

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

Yes, you're right---it was already so in the other methods. I've just
committed the fix.

Thanks for the heads-up,
    Luigi

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users