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

implement Ledger's -V (& -X ?) feature, for converting to a desired currency and showing market value #131

Open
tphyahoo opened this Issue Jul 28, 2013 · 29 comments

Comments

Projects
None yet
8 participants
@tphyahoo

tphyahoo commented Jul 28, 2013

Hledger should have some notion of exchange rates over time, as sketched out in

#115 (comment)

The currency reported should be an allowed "view" that changes if currency rates over time data changes. To make it clear that this is a view and not core data, computed values should be reported in parenthesis, or otherwise distinguished somehow.

This is a feature intended for use in --require-balanced=true mode. Context: #115

Example of usage:
hledger print --currency-numeraire=USD --currency-conversions=currency-conversions.txt

where currency-conversions.txt file is something like

2013/01/01 USD1=CAD1.31
2013/01/02 USD1=CAD1.32

This is similar use case as print --cost, but requires --require-balanced=true.
For backwards compatibility, I think we should keep current behavior for print --cost/-B where require-balanced=false.

For concreteness, consider this transaction

    2013/01/01  Canadian in the USA Buys food with US dollars (1 USD = 1.30 CAD)
       assets:cash          -USD40
       equity:forex         USD40
       equity:expense:food  CAD52 
       equity:forex         -CAD52 

If conversions file (as above) specifies 1USD=1.31 CAD, contradicting recorded ledger rate of 1.30,
then for the food purchase above
print --numeraire=USD --numeraire-file=currency-conversions=conversions.txt
would yield something like

    2013/01/01  Canadian in the USA Buys food with US dollars (1 USD = 1.30 CAD)
       assets:cash          -USD40
       equity:forex         USD40
       equity:expense:food  CAD52 (USD39.69)
       equity:forex         -CAD52 (-USD39.69)

Q Does print --currency-numeraire=USD imply --currency-conversions specified somewhere, or can it work without the numeraire file?
A There are two reasonable behaviors
1) require the flag
2) don't require the flag, but have very boring behavior: compute the conversions from information available in file, and then reports numbers in parenthesis that agree everywhere like:

    2013/01/01  Canadian in the USA Buys food with US dollars (1 USD = 1.30 CAD)
       assets:cash          -USD40
       equity:forex         USD40
       equity:expense:food  CAD52 (USD40)
       equity:forex         -CAD52 (-USD40)

The numbers in parentheses are computed from the conversions file, unparenthesized are recorded direct in ledger file.
If it's desired, the user could correct these versions using some manual or (maybe later) automated means.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Jul 29, 2013

Owner

Is this a request for ledger's -X feature, mentioned at http://ledger-cli.org/3.0/doc/ledger3.html#Commodity-Reporting ? It lets you report all amounts in terms of a chosen commodity (if it knows how to make the conversion).

Owner

simonmichael commented Jul 29, 2013

Is this a request for ledger's -X feature, mentioned at http://ledger-cli.org/3.0/doc/ledger3.html#Commodity-Reporting ? It lets you report all amounts in terms of a chosen commodity (if it knows how to make the conversion).

@tphyahoo

This comment has been minimized.

Show comment
Hide comment
@tphyahoo

tphyahoo Jul 30, 2013

Seems like it. Not implemented in hledger, right?
On Jul 29, 2013 4:36 PM, "Simon Michael" notifications@github.com wrote:

Is this a request for ledger's -X feature, mentioned at
http://ledger-cli.org/3.0/doc/ledger3.html#Commodity-Reporting ? It lets
you report all amounts in terms of a chosen commodity (if it knows how to
make the conversion).


Reply to this email directly or view it on GitHubhttps://github.com/simonmichael/hledger/issues/131#issuecomment-21759832
.

tphyahoo commented Jul 30, 2013

Seems like it. Not implemented in hledger, right?
On Jul 29, 2013 4:36 PM, "Simon Michael" notifications@github.com wrote:

Is this a request for ledger's -X feature, mentioned at
http://ledger-cli.org/3.0/doc/ledger3.html#Commodity-Reporting ? It lets
you report all amounts in terms of a chosen commodity (if it knows how to
make the conversion).


Reply to this email directly or view it on GitHubhttps://github.com/simonmichael/hledger/issues/131#issuecomment-21759832
.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Jul 30, 2013

Owner

Right, not yet.

Owner

simonmichael commented Jul 30, 2013

Right, not yet.

@simonmichael simonmichael changed the title from hledger print --currency-numeraire=USD ... view multi-currency ledger through single currency lens to implement Ledger's -X feature, for converting to a desired currency May 19, 2015

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael May 19, 2015

Owner

From the ledger manual:

-exchange COMMODITY
-X COMMODITY

Display values in terms of the given COMMODITY. The latest available price is used. The syntax -X COMMODITY1:COMMODITY2 displays values in COMMODITY1 in terms of COMMODITY2 using the latest available price, but will not automatically covert any other commodities to COMMODITY2. Multiple -X arguments may be used on a single command-line (as in -X COMMODITY1:COMMODITY2 -X COMMODITY3:COMMODITY2), which is particularly useful for situations where many prices are available for reporting in terms of COMMODITY2, but only a few should be displayed that way.

Owner

simonmichael commented May 19, 2015

From the ledger manual:

-exchange COMMODITY
-X COMMODITY

Display values in terms of the given COMMODITY. The latest available price is used. The syntax -X COMMODITY1:COMMODITY2 displays values in COMMODITY1 in terms of COMMODITY2 using the latest available price, but will not automatically covert any other commodities to COMMODITY2. Multiple -X arguments may be used on a single command-line (as in -X COMMODITY1:COMMODITY2 -X COMMODITY3:COMMODITY2), which is particularly useful for situations where many prices are available for reporting in terms of COMMODITY2, but only a few should be displayed that way.

@simonmichael simonmichael added this to the 1.0 milestone May 19, 2015

@simonmichael simonmichael added the cli label May 19, 2015

@thdox

This comment has been minimized.

Show comment
Hide comment
@thdox

thdox commented May 19, 2015

+1 :-)

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael May 19, 2015

Owner

Thanks for reminding me about this, thdox.

It's not something I've needed yet. In the simple case of travelling abroad I typically:

  • record in the local currency specifying a unit or total price (@ or @@) in my home currency, and use -B/--cost when I want to see it converted to the home currency.
  • more often, just record the amount in my home currency as converted by the bank (I may find out the exact amount later) with the local currency amount in a comment.

It would be useful to be reminded with an example or two of real-world situations where -B isn't enough and you need -X.

Owner

simonmichael commented May 19, 2015

Thanks for reminding me about this, thdox.

It's not something I've needed yet. In the simple case of travelling abroad I typically:

  • record in the local currency specifying a unit or total price (@ or @@) in my home currency, and use -B/--cost when I want to see it converted to the home currency.
  • more often, just record the amount in my home currency as converted by the bank (I may find out the exact amount later) with the local currency amount in a comment.

It would be useful to be reminded with an example or two of real-world situations where -B isn't enough and you need -X.

@thdox

This comment has been minimized.

Show comment
Hide comment
@thdox

thdox May 19, 2015

In the simple case of traveling abroad

Fully agree, me too, I do not bother to complicate the things

example or two of real-world situations

The typical use case is an account in foreign currency

  • probably a lot of people living near a border have an account in a foreign currency
  • I was hired by a US company, and they offered me stock option in USD. So any employee hired by a foreign company. Also, your local company may be bought by a foreign company, this is more and more frequent.
  • trading on a foreign stock exchange, with a foreign account
  • and another example, that you may find weird, but that all people living in Europe faced, we can have two national currencies during a period (could last several years depending on the country)

I am experiencing with the last 3

thdox commented May 19, 2015

In the simple case of traveling abroad

Fully agree, me too, I do not bother to complicate the things

example or two of real-world situations

The typical use case is an account in foreign currency

  • probably a lot of people living near a border have an account in a foreign currency
  • I was hired by a US company, and they offered me stock option in USD. So any employee hired by a foreign company. Also, your local company may be bought by a foreign company, this is more and more frequent.
  • trading on a foreign stock exchange, with a foreign account
  • and another example, that you may find weird, but that all people living in Europe faced, we can have two national currencies during a period (could last several years depending on the country)

I am experiencing with the last 3

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael May 19, 2015

Owner

Great high-level examples, thanks. I guess I can assume -B is not practical in those situations ? Yes, without thinking too hard I can see it would be at least painful.

Related to this feature, we need to enable historical prices, which we currently ignore.

Edit: also harmonize fixed prices syntax.

Owner

simonmichael commented May 19, 2015

Great high-level examples, thanks. I guess I can assume -B is not practical in those situations ? Yes, without thinking too hard I can see it would be at least painful.

Related to this feature, we need to enable historical prices, which we currently ignore.

Edit: also harmonize fixed prices syntax.

@thdox

This comment has been minimized.

Show comment
Hide comment
@thdox

thdox May 20, 2015

I can assume -B is not practical in those situations ?

Well, --exchange (=-X) will give you, like --market (-V), the today evaluation of your assets, and when you have stock option, or long acquired shares, this is what you are interested in, the today value, not the --basis(-B) value.

thdox commented May 20, 2015

I can assume -B is not practical in those situations ?

Well, --exchange (=-X) will give you, like --market (-V), the today evaluation of your assets, and when you have stock option, or long acquired shares, this is what you are interested in, the today value, not the --basis(-B) value.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Aug 15, 2015

Owner

There has been progress on this; the balance command now supports -V.

Owner

simonmichael commented Aug 15, 2015

There has been progress on this; the balance command now supports -V.

@simonmichael simonmichael changed the title from implement Ledger's -X feature, for converting to a desired currency to implement Ledger's -X (& -V) feature, for converting to a desired currency and showing market value Aug 17, 2015

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Aug 21, 2015

Owner

A puzzling interaction of -V and the default commodity directive, from private email:

; when you uncomment this directive, hledger bal -V's final balance changes from 0 to 0.48 D
; (also D symbol is placed inconsistently, cf #230)
D 1000.00 D

P 2015/08/14 AAAA   41.66
P 2015/08/14 BBBB   74.62
P 2015/08/14 CCCC  32.39

2015/08/15
    a  2.4120 AAAA @@ 100
    a  0.3350 BBBB @@ 25
    a  0.7718 CCCC @@ 25
    b
$ hledger bal 
         2.4120 AAAA   
         0.3350 BBBB   
         0.7718 CCCC  a
           -150.00 D  b
--------------------
         2.4120 AAAA
         0.3350 BBBB
         0.7718 CCCC
           -150.00 D
$ hledger bal -V
                D150  a
           -150.00 D  b
--------------------
              0.48 D
Owner

simonmichael commented Aug 21, 2015

A puzzling interaction of -V and the default commodity directive, from private email:

; when you uncomment this directive, hledger bal -V's final balance changes from 0 to 0.48 D
; (also D symbol is placed inconsistently, cf #230)
D 1000.00 D

P 2015/08/14 AAAA   41.66
P 2015/08/14 BBBB   74.62
P 2015/08/14 CCCC  32.39

2015/08/15
    a  2.4120 AAAA @@ 100
    a  0.3350 BBBB @@ 25
    a  0.7718 CCCC @@ 25
    b
$ hledger bal 
         2.4120 AAAA   
         0.3350 BBBB   
         0.7718 CCCC  a
           -150.00 D  b
--------------------
         2.4120 AAAA
         0.3350 BBBB
         0.7718 CCCC
           -150.00 D
$ hledger bal -V
                D150  a
           -150.00 D  b
--------------------
              0.48 D

@simonmichael simonmichael modified the milestones: 0.27, 1.0 Sep 29, 2015

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Oct 11, 2015

Owner

Quite a chase! Here's what was happening:

D 1000.00 H

P 2015/08/14 EEEE   41.66
P 2015/08/14 FFFF   74.62
P 2015/08/14 GGGG  32.39

2015/08/15
    a  2.4120 EEEE @@ 100
    a  0.3350 FFFF @@ 25
    a  0.7718 GGGG @@ 25
    b
$ hledger bal -V
                H150  a
           -150.00 H  b
--------------------
              0.48 H
  • as the D directive was parsed, it set the default commodity (H) and
    amount style (right symbol, 2 decimal places)

  • as the P market price amounts were parsed, they were assigned this
    default commodity and style

  • as the posting amounts were parsed, their commodityless @@ prices
    were also assigned the default commodity and style

  • after parsing, all of the journal's posting amounts and market price
    amounts were canonicalised. But, only the primary posting amounts
    determined canonical styles, so there was no canonical style for H,
    so all the H amounts were reset to the null style (left symbol, 0
    decimal places)

  • a balancing amount of -150.00 H was assigned to the b posting

  • the standard balance report summed the postings to get a and b's
    balances, and summed those to get the total. Respectively those were:

    a:     2.4120 EEEE @@ 100.00 H + 0.3350 FFFF @@ 25.00 H + 0.7718 GGGG @@ 25.00 H
    b:     -150.00 H
    total: 2.4120 EEEE @@ 100.00 H + 0.3350 FFFF @@ 25.00 H + 0.7718 GGGG @@ 25.00 H + (-150.00 H)
    
  • -V called balanceReportValue to convert each of these amounts to today's value
    in the commodity in which they were most recently priced. So they became:

    a:     2.412 * 41.66 H + 0.3350 * 74.62 H + 0.7718 * 32.39 H
         = 150.480222 H
    b:     -150 H (no market price for H, remains unchanged)
    total: 150.480222 H + (-150 H)
         = 0.480222 H
    
  • As each amount was valued, it was assigned the style from the market price,
    which had been reset to the null style, so a's balance got rendered confusingly as H150.

In short: a display problem. But 0 decimal places tends to be so
confusing, I'm thinking the default style should have 2 instead.

Owner

simonmichael commented Oct 11, 2015

Quite a chase! Here's what was happening:

D 1000.00 H

P 2015/08/14 EEEE   41.66
P 2015/08/14 FFFF   74.62
P 2015/08/14 GGGG  32.39

2015/08/15
    a  2.4120 EEEE @@ 100
    a  0.3350 FFFF @@ 25
    a  0.7718 GGGG @@ 25
    b
$ hledger bal -V
                H150  a
           -150.00 H  b
--------------------
              0.48 H
  • as the D directive was parsed, it set the default commodity (H) and
    amount style (right symbol, 2 decimal places)

  • as the P market price amounts were parsed, they were assigned this
    default commodity and style

  • as the posting amounts were parsed, their commodityless @@ prices
    were also assigned the default commodity and style

  • after parsing, all of the journal's posting amounts and market price
    amounts were canonicalised. But, only the primary posting amounts
    determined canonical styles, so there was no canonical style for H,
    so all the H amounts were reset to the null style (left symbol, 0
    decimal places)

  • a balancing amount of -150.00 H was assigned to the b posting

  • the standard balance report summed the postings to get a and b's
    balances, and summed those to get the total. Respectively those were:

    a:     2.4120 EEEE @@ 100.00 H + 0.3350 FFFF @@ 25.00 H + 0.7718 GGGG @@ 25.00 H
    b:     -150.00 H
    total: 2.4120 EEEE @@ 100.00 H + 0.3350 FFFF @@ 25.00 H + 0.7718 GGGG @@ 25.00 H + (-150.00 H)
    
  • -V called balanceReportValue to convert each of these amounts to today's value
    in the commodity in which they were most recently priced. So they became:

    a:     2.412 * 41.66 H + 0.3350 * 74.62 H + 0.7718 * 32.39 H
         = 150.480222 H
    b:     -150 H (no market price for H, remains unchanged)
    total: 150.480222 H + (-150 H)
         = 0.480222 H
    
  • As each amount was valued, it was assigned the style from the market price,
    which had been reset to the null style, so a's balance got rendered confusingly as H150.

In short: a display problem. But 0 decimal places tends to be so
confusing, I'm thinking the default style should have 2 instead.

@simonmichael simonmichael changed the title from implement Ledger's -X (& -V) feature, for converting to a desired currency and showing market value to implement Ledger's -V (& -X ?) feature, for converting to a desired currency and showing market value Oct 28, 2015

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Oct 28, 2015

Owner

-X isn't implemented yet. Needed ?

Owner

simonmichael commented Oct 28, 2015

-X isn't implemented yet. Needed ?

@dashed

This comment has been minimized.

Show comment
Hide comment
@dashed

dashed Jan 24, 2016

@simonmichael I'm quite interested in the -X option which is basically -V used with the last known price of each commodity from the ledger file(s).

dashed commented Jan 24, 2016

@simonmichael I'm quite interested in the -X option which is basically -V used with the last known price of each commodity from the ledger file(s).

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Jan 24, 2016

Owner

I would say: hledger's -V uses the last known market price (and its commodity) as of report end date; -X adds the ability to select the target commodity.

Owner

simonmichael commented Jan 24, 2016

I would say: hledger's -V uses the last known market price (and its commodity) as of report end date; -X adds the ability to select the target commodity.

@dashed

This comment has been minimized.

Show comment
Hide comment
@dashed

dashed Jan 25, 2016

@simonmichael Ah I see. Are there still plans for -X to implemented? Or is that a wontfix?

I'm interested in -X (especially when used together with -V), mainly because representing accounts in my local fiat currency is more meaningful to me in discerning if sub-total values have changed wrt to market prices.

dashed commented Jan 25, 2016

@simonmichael Ah I see. Are there still plans for -X to implemented? Or is that a wontfix?

I'm interested in -X (especially when used together with -V), mainly because representing accounts in my local fiat currency is more meaningful to me in discerning if sub-total values have changed wrt to market prices.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Jan 25, 2016

Owner

I think we should implement it. Just needs some developer-hours.

Owner

simonmichael commented Jan 25, 2016

I think we should implement it. Just needs some developer-hours.

@jeevcat

This comment has been minimized.

Show comment
Hide comment
@jeevcat

jeevcat Jul 4, 2017

Collaborator

Just started with hledger yesterday, and I'd love the -X option. I am constantly working with a number of different currencies.

As a workaround, I've made a number of market price-only journals with my desired currency always being the 2nd value, like so:

P 2017/06/30 USD 1.30248 AUD
P 2017/06/30 GBP 1.694173 AUD
P 2017/06/30 EUR 1.486247 AUD

I then include the corresponding journal before I run hledger bal -V. This would return balances converted to the AUD in this example.

This works but is not ideal. I have to ensure I never have any market value entries with a different 2nd currency, or I won't get a single currency output.

I'd be interested in helping implement this, but I'm not well-versed in any functional programming languages, let alone Haskell.

Collaborator

jeevcat commented Jul 4, 2017

Just started with hledger yesterday, and I'd love the -X option. I am constantly working with a number of different currencies.

As a workaround, I've made a number of market price-only journals with my desired currency always being the 2nd value, like so:

P 2017/06/30 USD 1.30248 AUD
P 2017/06/30 GBP 1.694173 AUD
P 2017/06/30 EUR 1.486247 AUD

I then include the corresponding journal before I run hledger bal -V. This would return balances converted to the AUD in this example.

This works but is not ideal. I have to ensure I never have any market value entries with a different 2nd currency, or I won't get a single currency output.

I'd be interested in helping implement this, but I'm not well-versed in any functional programming languages, let alone Haskell.

@simonmichael simonmichael reopened this Jul 4, 2017

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Jul 4, 2017

Owner

Neat trick @jeevcat. I can imagine making different shell aliases with the different -f args. But you sound like the ideal person to push this forward, please ask for support eg on #hledger channel. First step would be to follow the contributor guide and try to build latest hledger.

For future reference, currently the -V flag is defined here and here and applied here and here. I think you can handle -X COMMODITY there as well. -V and -X are alternatives and there should probably be an options validation step that complains if both are used at the same time. In ReportOpts perhaps we should change value_ :: Bool to value_ :: Maybe Commodity or something. That would be a good place to start.

Owner

simonmichael commented Jul 4, 2017

Neat trick @jeevcat. I can imagine making different shell aliases with the different -f args. But you sound like the ideal person to push this forward, please ask for support eg on #hledger channel. First step would be to follow the contributor guide and try to build latest hledger.

For future reference, currently the -V flag is defined here and here and applied here and here. I think you can handle -X COMMODITY there as well. -V and -X are alternatives and there should probably be an options validation step that complains if both are used at the same time. In ReportOpts perhaps we should change value_ :: Bool to value_ :: Maybe Commodity or something. That would be a good place to start.

@jeevcat

This comment has been minimized.

Show comment
Hide comment
@jeevcat

jeevcat Jul 4, 2017

Collaborator

Okay @simonmichael, I'd be happy to look into it. Please understand that it will take some significant time: turns out I'm learning Haskell 😄.

Collaborator

jeevcat commented Jul 4, 2017

Okay @simonmichael, I'd be happy to look into it. Please understand that it will take some significant time: turns out I'm learning Haskell 😄.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Mar 26, 2018

Owner

Here are some related docs from ledger --help:

COMMANDS
     register [report-query]
              --exchange commodity (-X)
                               Render all values in the given commodity, if a price
                               conversion rate can be determined.  Rates are always
                               displayed relative to the date of the posting they are
                               calculated for.  This means a register report is a his-
                               torical value report.  For current values, it may be
                               preferable to use the balance report.

              --market (-V)    Show current market values for all amounts.  This is
                               determined in a somewhat magical fashion.  It is proba-
                               bly more straightforward to use --exchange option.

OPTIONS
     --exchange COMMODITY [, COMMODITY, ...] (-X)
              Display values in terms of the given COMMODITY.  The latest available
              price is used.

     --revalued
              Report discrepancy in values for manual reports by inserting <Revalued>
              postings.  This is implied when using the --exchange (-X) or --market
              (-V) option.
Owner

simonmichael commented Mar 26, 2018

Here are some related docs from ledger --help:

COMMANDS
     register [report-query]
              --exchange commodity (-X)
                               Render all values in the given commodity, if a price
                               conversion rate can be determined.  Rates are always
                               displayed relative to the date of the posting they are
                               calculated for.  This means a register report is a his-
                               torical value report.  For current values, it may be
                               preferable to use the balance report.

              --market (-V)    Show current market values for all amounts.  This is
                               determined in a somewhat magical fashion.  It is proba-
                               bly more straightforward to use --exchange option.

OPTIONS
     --exchange COMMODITY [, COMMODITY, ...] (-X)
              Display values in terms of the given COMMODITY.  The latest available
              price is used.

     --revalued
              Report discrepancy in values for manual reports by inserting <Revalued>
              postings.  This is implied when using the --exchange (-X) or --market
              (-V) option.
@NorfairKing

This comment has been minimized.

Show comment
Hide comment
@NorfairKing

NorfairKing Mar 26, 2018

"It would be useful to be reminded with an example or two of real-world situations where -B isn't enough and you need -X."

I naturally use multiple currencies in my life, but -B forces me to use one as the default, and I can never view reports in terms of the others.

Secondly: sometimes currency conversions only specify a conversion from B to C. If A is my default currency, and I have a price for B or C from A, then hledger should be able to connect the dots.

NorfairKing commented Mar 26, 2018

"It would be useful to be reminded with an example or two of real-world situations where -B isn't enough and you need -X."

I naturally use multiple currencies in my life, but -B forces me to use one as the default, and I can never view reports in terms of the others.

Secondly: sometimes currency conversions only specify a conversion from B to C. If A is my default currency, and I have a price for B or C from A, then hledger should be able to connect the dots.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Mar 26, 2018

Owner

Possible good next step: add --exchange/-X COMM option that works exactly like our -V but automatically finds a path among known market prices.

Example doc:

  -V --value              convert amounts to their market value on the report
                          end date (using the most recent applicable market
                          price, if any)
  -X --exchange COMM      convert amounts to their market value in the given commodity
                          on the report end date, if possible, using the most recent applicable market
                          prices. Like -V but you can specify the target commodity. hledger will
                          convert using known market prices (exchange rates), possibly in multiple steps
                          (in whatever sequence it thinks best).

Question: -V currently shows amounts in their original commodity when a market price is not available (same as Ledger, I think). Should -X be similarly forgiving, or should it raise an error when it can't convert all amounts to the target commodity ? Should -V ?

Owner

simonmichael commented Mar 26, 2018

Possible good next step: add --exchange/-X COMM option that works exactly like our -V but automatically finds a path among known market prices.

Example doc:

  -V --value              convert amounts to their market value on the report
                          end date (using the most recent applicable market
                          price, if any)
  -X --exchange COMM      convert amounts to their market value in the given commodity
                          on the report end date, if possible, using the most recent applicable market
                          prices. Like -V but you can specify the target commodity. hledger will
                          convert using known market prices (exchange rates), possibly in multiple steps
                          (in whatever sequence it thinks best).

Question: -V currently shows amounts in their original commodity when a market price is not available (same as Ledger, I think). Should -X be similarly forgiving, or should it raise an error when it can't convert all amounts to the target commodity ? Should -V ?

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Mar 26, 2018

Owner

Could also provide --value-in as a synonym if we want.

Owner

simonmichael commented Mar 26, 2018

Could also provide --value-in as a synonym if we want.

@gavinedwards

This comment has been minimized.

Show comment
Hide comment
@gavinedwards

gavinedwards Apr 29, 2018

I'm really keen on seeing the -X functionality implemented in hledger. This is currently the only reason I still revert to ledger by default.

gavinedwards commented Apr 29, 2018

I'm really keen on seeing the -X functionality implemented in hledger. This is currently the only reason I still revert to ledger by default.

@ony

This comment has been minimized.

Show comment
Hide comment
@ony

ony Apr 29, 2018

Collaborator

Question: -V currently shows amounts in their original commodity when a market price is not available (same as Ledger, I think). Should -X be similarly forgiving, or should it raise an error when it can't convert all amounts to the target commodity ? Should -V ?

As long as that error will report both currency and report entry it is probably fine. Though it might be hard to pinpoint actual posting.

As for using cross-rate via intermediate currencies - I'm not sure it is good for representing market value since conversion is asymmetric (by default P directive is not reversible and it shouldn't be). I.e. such conversion will not answer the question "How much I'll get if I'll exchange all I got for currency that I'm interested in?" which might be useful when you decide to which country you want to move and somehow useful when you plan budget in other currency.

Note that it should be possible to "play" with "reference reports" introduced by @adept for budgeting for -V and -X, I guess.

Collaborator

ony commented Apr 29, 2018

Question: -V currently shows amounts in their original commodity when a market price is not available (same as Ledger, I think). Should -X be similarly forgiving, or should it raise an error when it can't convert all amounts to the target commodity ? Should -V ?

As long as that error will report both currency and report entry it is probably fine. Though it might be hard to pinpoint actual posting.

As for using cross-rate via intermediate currencies - I'm not sure it is good for representing market value since conversion is asymmetric (by default P directive is not reversible and it shouldn't be). I.e. such conversion will not answer the question "How much I'll get if I'll exchange all I got for currency that I'm interested in?" which might be useful when you decide to which country you want to move and somehow useful when you plan budget in other currency.

Note that it should be possible to "play" with "reference reports" introduced by @adept for budgeting for -V and -X, I guess.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Apr 29, 2018

Owner
Owner

simonmichael commented Apr 29, 2018

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Apr 29, 2018

Owner
Owner

simonmichael commented Apr 29, 2018

@simonmichael

This comment has been minimized.

Show comment
Hide comment
Owner

simonmichael commented Jun 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment