Skip to content

Finding market price in multiperiod report #2379

Open
@oTnTh

Description

@oTnTh

hledger 1.42.1-gdaafa059a-20250312, windows-x86_64

With this example hledger file:

P 2025-01-25 BFPA 1.01
P 2025-02-25 BFPA 1.02
P 2025-03-25 BFPA 1.03

2025-01-10
	assets:cash		100
	equity:start

2025-01-15 bank financial product
	assets:cash		-100
	investment:bfp		100 BFPA @@ 100
# hledger.exe bal --value end
             -100.00  equity:start
              103.00  investment:bfp
--------------------
                3.00

This bal report appears normal.

# hledger.exe bal --value end --monthly
Balance changes in 2025Q1, valued at period ends:

                ||     Jan  Feb  Mar
================++===================
 equity:start   || -100.00    0    0
 investment:bfp ||  101.00    0    0
----------------++-------------------
                ||    1.00    0    0

However, after adding the --monthly parameter, the values for Feb and Mar both show as 0.

According to the documentation: For multiperiod reports, each period is valued on its last day.

But it seems the P directives for Feb and Mar are being ignored.

# hledger.exe roi --inv bfp --pnl xxx --value end --monthly
+-------++------------+------------++---------------+----------+-------------+------++--------++------------+----------+
|       ||      Begin |        End || Value (begin) | Cashflow | Value (end) |  PnL ||    IRR || TWR/period | TWR/year |
+=======++============+============++===============+==========+=============+======++========++============+==========+
|     1 || 2025-01-01 | 2025-01-31 ||             0 |   100.00 |      101.00 | 1.00 || 23.82% ||      0.00% |    0.00% |
|     2 || 2025-02-01 | 2025-02-28 ||        102.00 |        0 |      102.00 |    0 ||  0.00% ||      0.00% |    0.00% |
|     3 || 2025-03-01 | 2025-03-31 ||        103.00 |        0 |      103.00 |    0 ||  0.00% ||      0.00% |    0.00% |
+-------++------------+------------++---------------+----------+-------------+------++--------++------------+----------+
| Total || 2025-01-01 | 2025-03-31 ||             0 |   100.00 |      103.00 | 3.00 || 15.25% ||      0.00% |    0.00% |
+-------++------------+------------++---------------+----------+-------------+------++--------++------------+----------+

In this roi report, the Value (begin) for Feb and Mar also appear incorrect.

Since the value of 2025-01-31 is 101.00, the value of 2025-02-01 should be the same, right?

I'm new to hledger, so I'm not sure whether this is a bug, or if I've made some mistakes.

If I'm asking some silly questions, my apologies.

And thank you all very much for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.balanceroivaluation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions