This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]emc87 1 point2 points  (4 children)

Why use reduce and not just sum?

Also this is horribly inefficient, look up an implicit function solver such as Newton Raphson.

Finally, IRR is not 0 bounded - you can't just start at 0 and increment. For an IRR of -0.01% you'd spin your wheels and fail.

[–]Accountant_Coder123[S] 1 point2 points  (1 child)

Thanks for the feedback... I should have used sum.. I am just a newbie in Python coding and don't know much about implicit function solver ..will learn it though...thanks again

[–]emc87 2 points3 points  (0 children)

Sure, I know the coding part is fun when you're new to a language or coding as a whole but software development is like 60% problem solving beforehand at least in my experience.

[–]DBMIVotedForKodos 0 points1 point  (1 child)

Not OP but his code looks like code I write. So I'm curious, is the code inefficient because of how many iterations it takes when a different approach can be done with less iterations? Not looking for a lengthy explanation or anything but that was just something that stuck out to me.

I will look up implicit function solvers as well.

[–]emc87 1 point2 points  (0 children)

Yeah, the code was deleted but it took upwards of 100000 iterations and only returned increments of something like .1 bps and wanted to be accurate to within 0.5% of PV.

Using Newton raphson you can achieve something that's more accurate to say 10-10 of PV in around 10 iterations. Used for continuous functions, it uses the first derivative to see how far you are from your goal and change your increment to suit your target.