The file below produces inconsistent --value=end results for -p 2020 and -p 2020 -Y; I have not calculated which one is correct. It's a bit hard to say - given that the last price is before the January purchase, I'd probably say there were no gains on that purchase, only on the one in December:
D 1,000.00€
commodity 1,000.00€
2019-12-23 buy 200 IE00BF4RFH31
assets:investments 200 "IE00BF4RFH31" @ 4.9785€
assets:investments -995.70€
2020-01-22 buy 103 IE00BF4RFH31
assets:investments 103 "IE00BF4RFH31" @ 5.033€
assets:investments -518.40€
P 2019/12/30 "IE00BF4RFH31" 4.957€
P 2020/01/02 "IE00BF4RFH31" 4.938€
The outcomes are:
; $ hledger -f f bal -p 2020 --value=end assets -Y
; Period-end value changes in 2020:
;
; || 2020
; ====================++=========
; assets:investments || -13.59€
; --------------------++---------
; || -13.59€
; $ hledger -f f bal -p 2020 --value=end assets
; -9.79€ assets:investments
; --------------------
; -9.79€