fmilthaler / FinQuant

A program for financial portfolio management, analysis and optimisation.
MIT License
1.38k stars 190 forks source link

Bugfix/fail example #76

Closed PietropaoloFrisoni closed 1 year ago

PietropaoloFrisoni commented 1 year ago

Fixes #74. The sum() method returns an instance of numpy.int64 if the allocation only contains integers.

An instance of numpy.int64 is not recognized as an instance of int, as they are two different classes.

This causes the error message since the total investment is not recognized as an integer.

Curious: trying with allocations equal to 20^(200), the returned number is an instance of "int" instead of "numpy.int64".

fmilthaler commented 1 year ago

Great, thanks again for working on this repo and fixing another long outstanding issue.

Just one thought. Since it did not accept np.int64 as int, including it in the condition will still not work if (for some weird reason) we get a np.int32 or other integer types. Let's use the parent np.integer here to check for all sorts of numpy integer types.

In addition, let's also include numpy floating point numbers. Here we should be able to use np.floating as another accepted type in the condition.

What are your thoughts?

PietropaoloFrisoni commented 1 year ago

I totally agree. I just pushed another commit.