Closed andres-erbsen closed 4 years ago
Sounds good :)
Thanks for fixing this, @yagebu . This is definitely a step in the right direction, but I feel like what's still missing is treating price directives the same way as transactions when drawing vertices on the graph. That way, we would see a vertex every time price changes, even if no transactions happened meanwhile. That would provide a great way to see portfolio value changes over time.
From the git history, it seems that this was the issue which prompted adding Price directives for determining time axis limits. Moreover, in #1593, the code was changed from using beancount.core.getters.get_min_max_date to using the code of beancount.core.getters.get_min_max_date directly. In that case, can the code be changed such that price is only considered when selecting _date_last, and not _date_start? The present implementation, i.e.
for entry in self.entries:
if isinstance(entry, (Transaction, Price)):
self._date_first = entry.date
break
for entry in reversed(self.entries):
if isinstance(entry, (Transaction, Price)):
self._date_last = entry.date + timedelta(1)
break
leads to a large part of the graph in the start containing no data if the price values for those are given (which happen in my file due to automatically fetching historical data). The plot with Price in filter:
vs the one with Price not in filter:
(There is a very small transaction at the start of the second plot hence the plot looks empty there)
The change for the same would be
for entry in self.entries:
if isinstance(entry, (Transaction,)):
self._date_first = entry.date
break
for entry in reversed(self.entries):
if isinstance(entry, (Transaction, Price)):
self._date_last = entry.date + timedelta(1)
break
Making this change would also not affect this change since there would be no assets whose values would be changing before the first transaction.
Under "Balance sheet", the end of the time axis is truncated to the last transaction. I believe it would be nicer if price directives were also considered when picking the span of the time axis. This is useful for comparing the total market value of some assets against an external reference after prices have changed but no transactions have taken place. On the other hand, I believe that event, commodity, note, balance, and document directives can be safely ignored as they do not change the displayed balance.
This would be a nice-to-have; it is already possible to achieve the desired display by generating a zero-value transaction for every time the prices are updated.