beancount / beanprice

Daily price quotes fetching library for plain-text accounting
GNU General Public License v2.0
69 stars 37 forks source link

fix TypeError when no price is returned #66

Open daniel-wells opened 2 years ago

daniel-wells commented 2 years ago

Sometimes the yahoo source will return None as a price (I think due to the date being too recent), this will result in a TypeError "conversion from NoneType to Decimal is not supported" when conversion of the price to a Decimal is attempted.

See #60

mbafford commented 2 years ago

I didn't see this PR when I fixed this in https://github.com/beancount/beanprice/pull/68 as well. So these two are duplicates. My PR also has a test for this case.

Nexus2k commented 2 years ago

Keep corrupting the cache for me with these changes applied...

mbafford commented 2 years ago

As mentioned here (https://github.com/beancount/beanprice/issues/60#issuecomment-1056918222), the issue @Nexus2k is mentioning (timestamp missing in the Yahoo response JSON) was solved already in an earlier commit, and is unrelated to what this is fixing (null price values in the prices arrays in the Yahoo response JSON).