...

This happens when we call IRR (Internar Return on Investment), using Newton method. We need to actualize each cash-flows of a loan to the number of days from the initial date of the loan. As we are calculating this in a dayly base, and the operation have 4 years duration, it makes around 1460 day for the last flow.

...

Luis

whilst this discussion is interesting around the merit and performance of ** versus fgl_decimal_power versus util.math.pow() (I'd forgotten that the second argument of ** is an integer, so 4**0.5 gives you 1, not 2 !!!) , what Luis had was a function calculating IRR or Internal Rate of Return. if I was to guess Luis and other developers with financial software have similar functions written many years ago

When I put together my example

https://github.com/FourjsGenero/fgl_apache_poi showing how you can utilise the Java Apache POI libraries to interact with Word and Excel I had an example in

https://github.com/FourjsGenero/fgl_apache_poi/blob/master/fgl_excel_calculation_test.4gl that showed you could create an Excel sheet in memory, populate the cells in memory, put a Excel formula in one cell, evaluate that formula, and return the value of the formula back to the 4gl program. The example I used with IRR or Internal Rate of Return but any financial formula in Excel could've been similarly exposed and made available to a 4gl program.

I was curious how the performance would compare but then I thought what if I could do that without the overhead of creating an Excel workbook and worksheet in memory, do the Apache POI libraries expose those Excel formulas?. Sure enough they do so I have added to the repository a 4gl module that exposes some of those functions and some quick tests

https://github.com/FourjsGenero/fgl_apache_poi/blob/master/fgl_financial.4glhttps://github.com/FourjsGenero/fgl_apache_poi/blob/master/fgl_financial_test.4glIMPORT FGL fgl_financial

...

CALL list_of_values.clear()

LET list_of_values[1] = -100000

FOR i = 1 TO 240

LET list_of_values[i+1] = 592.89

END FOR

LET irr = fgl_financial.irr(list_of_values,0.10/12)

In short you do not have to rewrite and maintain financial formulas from scratch in 4gl, you can utilise Java libraries that do the same thing. I would be curious to know from a precision and performance point of view, how these stack up. (Of course one day we could go one better and add a package e.g. IMPORT financial, that has these financial methods)

Reuben