bean-price fail with date

123 views
Skip to first unread message

Jacques Gagnon

unread,
Apr 4, 2016, 8:58:29 AM4/4/16
to Beancount
I'm getting error when specifying a date:

bean-price -e 'CAD:google/USDCAD' -d '2016-03-31'
ERROR   : Could not fetch for job: DatedPrice(base='USDCAD', quote='CAD', date=datetime.date(2016, 3, 31), sources=[PriceSource(module=<module 'beancount.prices.sources.google' from '/usr/local/lib/python3.4/dist-packages/beancount-2.0b9-py3.4-linux-x86_64.egg/beancount/prices/sources/google.py'>, symbol='USDCAD', invert=False)])

Bug? or i'm missing something?

Martin Blais

unread,
Apr 4, 2016, 2:55:19 PM4/4/16
to Beancount
Not a bug.
AFAIK the Google Finance price source does not work for historical prices on currencies.
You can try improving the price source fetcher.
Personally I think we ought to build one for OANDA, which should work for historical prices.




--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/7ac5c4a0-c5bf-4a5d-a57a-e20c285cd112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
Apr 4, 2016, 2:56:17 PM4/4/16
to Martin Blais, Beancount
Here, if you feel like having a go at it:
http://developer.oanda.com/rest-live/development-guide/


Martin Blais

unread,
Apr 4, 2016, 3:03:51 PM4/4/16
to Martin Blais, Beancount
This works:


{
        "instrument" : "EUR_USD",
        "granularity" : "D",
        "candles" : [
                {
                        "time" : "2016-03-27T21:00:00.000000Z",
                        "openMid" : 1.11649,
                        "highMid" : 1.12201,
                        "lowMid" : 1.115295,
                        "closeMid" : 1.11951,
                        "volume" : 29958,
                        "complete" : true
                },
                {
                        "time" : "2016-03-28T21:00:00.000000Z",
                        "openMid" : 1.119645,
                        "highMid" : 1.130345,
                        "lowMid" : 1.11691,
                        "closeMid" : 1.12923,
                        "volume" : 98827,
                        "complete" : true
                },
                {
                        "time" : "2016-03-29T21:00:00.000000Z",
                        "openMid" : 1.129125,
                        "highMid" : 1.136565,
                        "lowMid" : 1.12836,
                        "closeMid" : 1.13375,
                        "volume" : 109954,
                        "complete" : true
                },
                {
                        "time" : "2016-03-30T21:00:00.000000Z",
                        "openMid" : 1.133835,
                        "highMid" : 1.141205,
                        "lowMid" : 1.13102,
                        "closeMid" : 1.138,
                        "volume" : 106513,
                        "complete" : true
                },
                {
                        "time" : "2016-03-31T21:00:00.000000Z",
                        "openMid" : 1.138035,
                        "highMid" : 1.143815,
                        "lowMid" : 1.13349,
                        "closeMid" : 1.13917,
                        "volume" : 120812,
                        "complete" : true
                },
                {
                        "time" : "2016-04-03T21:00:00.000000Z",
                        "openMid" : 1.140095,
                        "highMid" : 1.141285,
                        "lowMid" : 1.13577,
                        "closeMid" : 1.139715,
                        "volume" : 77691,
                        "complete" : false
                }
        ]

Martin Blais

unread,
Apr 4, 2016, 3:44:42 PM4/4/16
to Martin Blais, Beancount
I just built one real quick; I'll add some tests and push this later today.

Martin Blais

unread,
Apr 4, 2016, 6:11:47 PM4/4/16
to Martin Blais, Beancount
Turns out I need to deal with timezone and I ran out of time for today. It's mainly working - albeit could give you the wrong rate depending in which time zone you're calling - if you want to test it out, try the "price_source_oanda" branch. I'll try to finish this soon.

Jacques Gagnon

unread,
Apr 4, 2016, 6:58:58 PM4/4/16
to bean...@googlegroups.com, Martin Blais
Very cool, I can wait.

I'm planning to add price retroactively in my file to make some report with market price history.

Jacques Gagnon
GTalk/E-Mail: darth...@gmail.com
WLM (MSN): clou...@msn.com

Reply all
Reply to author
Forward
0 new messages