GithubHelp home page GithubHelp logo

Comments (2)

isagarzazu avatar isagarzazu commented on August 11, 2024

Here is another example:

dates= [date(2017,11,30),date(2018,1,31),date(2018,2,28),date(2018,3,31),date(2018,4,30),date(2018,5,31),date(2018,7,28),date(2018,7,31),date(2018,8,30),date(2018,8,30),date(2018,8,31),date(2018,8,31),date(2018,10,30),date(2018,10,30),date(2018,11,30),date(2018,12,31),date(2018,12,31),date(2018,12,31),date(2019,2,28),date(2019,3,31),date(2019,5,31),date(2020,1,28),date(2021,3,31),date(2021,10,30),date(2021,10,30),date(2022,2,28),date(2022,2,28),date(2022,4,30),date(2022,6,30),date(2022,10,28),date(2022,11,28),date(2022,11,28),date(2022,11,30)]

cashflow=[-1000,-1050,-1000,-650,-500,-1085,1472.5,1180,1600,7.5,1547.5,132.5,874,100.2,-1500,-1200,-500,1735,-1000,2080,-500,1900,1491.25,3300,1030,-1000,-500,1667.5,-21457.5,1808.71,1043.23,0.01,9153.25]

xirr(dates, cashflow)

xirr with a guess of 0.1 is 0.1798; in excel with the same guess is -0.6488

from pyxirr.

Anexen avatar Anexen commented on August 11, 2024

Hi @isagarzazu, sorry for the late response.

I've checked the data, pyxirr returns the correct result. This can be proven using the xnpv function. By the definition, xirr is equals to the rate at which xnpv = 0. If you use the result from Excel, xnpv will not be equal to 0.

# must be close to zero
xnpv(xirr(dates, cashflow), dates, cashflow)

Excel sometimes gives the wrong result.
Basically xirr is a solution to the minimization problem. I think Excel returns "garbage" if the algorithm does not converge. At the same time, pyxirr has additional checks and returns None if xnpv != 0.

I also checked the calculation in libreoffice and it matched the result of pyxirr.

image

from pyxirr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.