cmallwitz / Financials-Extension

Extension for LibreOffice Calc to access stock market data
Other
151 stars 21 forks source link

Do not return None on elements not found #91

Closed centove closed 11 months ago

centove commented 1 year ago

There are instances when you have a given Datacode item not available on yahoo or ft where the extension returns None, which LibreOffice turns into #N/A which messes up formulas something fierce. It would be better to return 0 or a blank which is easier to test for when writing formulas for the returned value. For instance, Yahoo don't seem to have the dividend info for ETF's so the yearly dividend winds up being #N/A if you are trying to estimate monthly dividend payouts, when #N/A / 12 don't exactly work really good. In the _return_value function in the baseclient, after checking for data is None: (Probably should return 0 here as well) something like: if data[Datacode(datacode)] is None: return 0 clears up all the #VALUE errors when trying to divide #N/A / 12

cmallwitz commented 11 months ago

There is a mix of return values for codes including text for name of securities. SO I return None when there is no value vs some default value. You can use ISNA() to check for that in your formulas.