Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger-style balance --lots, register --lots reports #1018

Open
alensiljak opened this issue May 13, 2019 · 1 comment
Open

Ledger-style balance --lots, register --lots reports #1018

alensiljak opened this issue May 13, 2019 · 1 comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance investing Related to investments, lots, capital gains, etc. register

Comments

@alensiljak
Copy link

alensiljak commented May 13, 2019

This is an issue specifically for adding Ledger's --lots flag. Ref #1015.

Examples

Here's Ledger's help for --lots and some related flags:

     --lot-dates
              Report the date on which each commodity in a balance report was
              purchased.

     --lot-notes
              Report the tag attached to each commodity in a balance report.

     --lot-prices
              Report the price at which each commodity in a balance report
              was purchased.

     --lots   Report the date and price at which each commodity was purchased
              in a balance report.

     --lots-actual
              Preserve the uniqueness of commodities so they aren't merged
              during reporting without printing the lot annotations.

Reference file: https://gitlab.com/snippets/1856416

; trades sample for hledger #1015

2019-01-05 Opening Balances
    Assets:Cash    1000.00 EUR
    Equity:Opening Balances    -1000.00 EUR

2019-01-10 Buy fund
    Assets:Shares    5 ETF @ 10 EUR
    Assets:Cash    -50 EUR

2019-01-15 Buy more
    Assets:Shares    5 ETF @ 12 EUR
    Assets:Cash    -60 EUR

2019-03-01 Sell
    Assets:Shares    -5 ETF {10 EUR} [2019-01-10] @ 15 EUR
    Assets:Shares    -1 ETF {12 EUR} [2019-01-15] @ 15 EUR
    Assets:Cash    90.00 EUR
    Capital Gains    -28.00 EUR

Ordinary balance report

$ ledger bal --flat
          980.00 EUR  Assets:Cash
               4 ETF  Assets:Shares
          -28.00 EUR  Capital Gains
        -1000.00 EUR  Equity:Opening Balances
--------------------
               4 ETF
          -48.00 EUR

Balance report showing lots at 1/20

At 1/20 there are two lots in Assets:Shares. {UNITCOST} [PURCHASEDATE] is shown after each amount (throwing off the alignment).

$ ledger bal --flat --lots -e 2019-01-20
          890.00 EUR  Assets:Cash
5 ETF {10.00 EUR} [2019-01-10]
5 ETF {12.00 EUR} [2019-01-15]  Assets:Shares
        -1000.00 EUR  Equity:Opening Balances
--------------------
5 ETF {10.00 EUR} [2019-01-10]
5 ETF {12.00 EUR} [2019-01-15]
         -110.00 EUR

Balance report after selling first lot and part of the second

$ ledger bal --flat --lots
          980.00 EUR  Assets:Cash
4 ETF {12.00 EUR} [2019-01-15]  Assets:Shares
          -28.00 EUR  Capital Gains
        -1000.00 EUR  Equity:Opening Balances
--------------------
4 ETF {12.00 EUR} [2019-01-15]
          -48.00 EUR

Ordinary register report

$ ledger reg shares
19-Jan-10 Buy fund               Assets:Shares                     5 ETF         5 ETF
19-Jan-15 Buy more               Assets:Shares                     5 ETF        10 ETF
19-Mar-01 Sell                   Assets:Shares                    -5 ETF         5 ETF
                                 Assets:Shares                    -1 ETF         4 ETF

Register report showing lots

$ ledger reg shares --lots
19-Jan-10 Buy fund               Assets:Shares             5 ETF {10.00 EUR} [19-Jan-10] 5 ETF {10.00 EUR} [19-Jan-10]
19-Jan-15 Buy more               Assets:Shares             5 ETF {12.00 EUR} [19-Jan-15] 5 ETF {10.00 EUR} [19-Jan-10]
                                                         5 ETF {12.00 EUR} [19-Jan-15]
19-Mar-01 Sell                   Assets:Shares             -5 ETF {10.00 EUR} [19-Jan-10] 5 ETF {12.00 EUR} [19-Jan-15]
                                 Assets:Shares             -1 ETF {12.00 EUR} [19-Jan-15] 4 ETF {12.00 EUR} [19-Jan-15]

Questions

How to reduce impact on alignment ? Other layout ideas ?

Any more intuitive/consistent display schemes than @/@@/{}/{=}/[]/etc. ?

Which other commands should support this ?

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. cli Command line parsing, options, arguments and suchlike. investing Related to investments, lots, capital gains, etc. labels May 13, 2019
@simonmichael simonmichael changed the title --lots syntax Ledger-style balance --lots report May 13, 2019
@simonmichael simonmichael added balance and removed cli Command line parsing, options, arguments and suchlike. labels May 13, 2019
@simonmichael simonmichael changed the title Ledger-style balance --lots report Ledger-style balance --lots, register --lots reports May 13, 2019
@alensiljak
Copy link
Author

alensiljak commented Nov 7, 2022

There is also the recently-added --average-lot-prices that shows the average lot prices for the whole holding:

> ~ $ l b ass and xyz --average-lot-prices
26073 XYZ {0.8264 CUR}  Assets:Investments
10080 XYZ {0.9907 CUR}    Broker1:Shares:XYZ
15993 XYZ {0.7228 CUR}    Broker2:Shares CUR:XYZ
--------------------
26073 XYZ {0.8264 CUR}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance investing Related to investments, lots, capital gains, etc. register
Projects
None yet
Development

No branches or pull requests

2 participants