how to make bean-price fetch historical prices

134 views
Skip to first unread message

Chary Chary

unread,
Feb 7, 2023, 4:51:49 PM2/7/23
to Beancount
Dear all,

I just can't figure out how to make bean-price fetch historical prices

I have the following mybean.bean
===================================================

* Commodities
2000-01-01 commodity EUR
  name: "Euro"
  assets-class: "cash"

2000-01-01 commodity USD
  name: "US dollars"
  assets-class: "cash"
  price: "EUR:yahoo/USDEUR=X"

2000-01-01 open Expenses:Misc

* Asset accounts
2000-01-01 open Assets:EU:Bank:Payment
2000-01-01 open Assets:US:Bank:Payment


2022-12-02 * "Buying something in Euro paying by European card"
    Assets:EU:Bank:Payment               -100 EUR
    Expenses:Misc                        100 EUR

2022-12-03 * "Buying something in USD, paying by USA card "
    Assets:US:Bank:Payment              -100 USD
    Expenses:Misc                        100 USD

2022-12-04 * "Buying in EU with US card, where the cost in euro is known"
    Assets:US:Bank:Payment             -100 USD
    Expenses:Misc                       50 EUR @@ 100 USD

2022-01-05 * "Buying something in US, paying with EU card "
    Assets:EU:Bank:Payment               -100 EUR
    Expenses:Misc                        200 USD @@ 100 EUR

======================================================

however bean-price fetches only current  USD /EUR.

But I would like to get exchange rate for every day starting from the earliest transaction to the last one. 

=======================
C:\_code\py\mybean>bean-price -vv --no-cache --update-rate daily "C:\_code\py\mybean\experiments\simpleSimulation\test_for_bean_price.bean"
INFO    : Processing at date: 2023-02-07
INFO    : Loading "C:\_code\py\mybean\experiments\simpleSimulation\test_for_bean_price.bean"
DEBUG   : Ignoring currency with no metadata: EUR
DEBUG   : -------- Currencies in primary list:
DEBUG   :                           USD /EUR
DEBUG   : -------- Currencies held in assets:
DEBUG   :                           EUR /USD
DEBUG   :                           USD /EUR
DEBUG   : -------- Currencies to fetch:
DEBUG   :                           USD /EUR
DEBUG   : Starting new HTTPS connection (1): query1.finance.yahoo.com:443
DEBUG   : https://query1.finance.yahoo.com:443 "GET /v7/finance/quote?symbols=USDEUR%3DX&fields=symbol%2CregularMarketPrice%2CregularMarketTime&exchange=NYSE&lang=en-US&corsDomain=finance.yahoo.com&.tsrc=finance HTTP/1.1" 200 661
2023-02-07 price USD                                     1 EUR

C:\_code\py\mybean>

=======================

So, is it possible to get historical rates?

William Bean

unread,
Feb 27, 2023, 2:02:24 PM2/27/23
to Beancount
Was doing a search for bean-price and noticed this thread did not have a response. To get the historical rates you also need --update, not just --update-rate.

Chary Chary

unread,
Feb 28, 2023, 3:37:43 AM2/28/23
to Beancount
Thank you for response, but I still didn't manage to make this working for my file

William Bean

unread,
Mar 2, 2023, 9:50:54 AM3/2/23
to Beancount
It looks like your price spec in the commodity is wrong. You are showing price: "EUR:yahoo/USDEUR=X". It seems that it should be price: "EUR:yahoo/EUR=X"

Chary Chary

unread,
Mar 2, 2023, 10:13:50 AM3/2/23
to Beancount
thanks, but still no success

I will probably log it like a bug in beanprice github

* Commodities
2000-01-01 commodity EUR
  name: "Euro"
  assets-class: "cash"
  price: "USD:yahoo/USD=X"

2000-01-01 commodity USD
  name: "US dollars"
  assets-class: "cash"
  price: "EUR:yahoo/EUR=X"

2000-01-01 price EUR 1 USD
2000-01-01 price USD 1 EUR

2000-01-01 open Expenses:Misc

* Asset accounts
2000-01-01 open Assets:EU:Bank:Payment
2000-01-01 open Assets:US:Bank:Payment


2022-12-02 * "Buying something in Euro paying by European card"
    Assets:EU:Bank:Payment               -100 EUR
    Expenses:Misc                        100 EUR

2022-12-03 * "Buying something in USD, paying by USA card "
    Assets:US:Bank:Payment              -100 USD
    Expenses:Misc                        100 USD

2022-12-04 * "Buying in EU with US card, where the cost in euro is known"
    Assets:US:Bank:Payment             -100 USD
    Expenses:Misc                       50 EUR @@ 100 USD

2022-12-05 * "Buying something in US, paying with EU card "
    Assets:EU:Bank:Payment               -100 EUR
    Expenses:Misc                        200 USD @@ 100 EUR



PS C:\_code\py\test\beancount_tests> bean-price -vv --no-cache --update --update-rate daily c:\_code\py\test\beancount_tests\simpleSimulation\test_for_bean_price.bean
INFO    : Processing at date: 2023-03-02
INFO    : Loading "c:\_code\py\test\beancount_tests\simpleSimulation\test_for_bean_price.bean"

DEBUG   : -------- Currencies in primary list:
DEBUG   :                           USD /EUR
DEBUG   :                           EUR /USD
PS C:\_code\py\test\beancount_tests>


Reply all
Reply to author
Forward
0 new messages