GNOME Bugzilla – Bug 698769
Support for querying the price of Bitcoin via Finance::Quote
Last modified: 2018-06-29 23:15:10 UTC
Created attachment 242344 [details] [review] fq-bitcoin.patch This patch adds support for querying the price of Bitcoin/Litecoin/Namecoin, etc. based on the code recently merged to Finance::Quote.
Comment on attachment 242344 [details] [review] fq-bitcoin.patch Committed to trunk as r22988 and to 2.4 as r22990. Thank you for your contribution!
Sorry for the delay, but I had a problem with my computer. I am not happy with this patch. Until now we had _one_ source for over hundred real currencies. Why should we add about a dozen sources for one virtual currency?
Sam, can you point me to the RT entry of the F::Q change?
Sure, no worries. Here's the RT entry: <https://rt.cpan.org/Public/Bug/Display.html?id=84790> I don't like the massive list of currencies either. The problem is that the market where BTC is sold for USD is separate from the market where it's sold for EUR, and so on. I believe that calling set_currency is not sufficient, because that would fetch the price in one market and then convert it to another currency, as opposed to fetching the price for the market for that other currency in the first place. I considered using a suffix to the symbol to determine the market, but didn't do so because then the security symbol used in the Gnucash UI would be rather ugly: "BTC.USD" for instance. So the current F::Q code ends up with a rather large list of methods being added--one for each virtual currency/real currency pair that an exchange supports. Not a problem for code calling in to F::Q, but obviously the UI for choosing which method is used is no longer ideal. I could try making the quote source menu hierachical--there would then only be a single "Bitcoin" entry in the menu, that leads to a submenu with an entry for each currency. Alternatively, and after thinking about it for a bit, I suppose the ugliness of the suffix method isn't really all that bad, and it does have precedence (e.g., for symbols quoted on the London Stock Exchange I already have to create a security such as "ISF.L"). Anyway, let me know what you think.
Thanks for your quick answer! The traditional currencies are fetched from yahoo and IIRC the symbol has the form aaaXbbb, where aaa and bbb are the ISO codes of the currencies. E.g. run gnc-fq-dump -v currency USD EUR You can find examples in the comments in src/scm/price-quotes.scm For other commodities one market only offers one base currency, so they have only the commodity symbol as criteria. E.g. Siemens at NYSE is noted in USD, in Frankfurt in EUR. So the base currency can often be derived from the place but .L returns GBP or GBp (=1/100 GBP) I would prefer, if MtGox would expect 2 symbols as the currency module does. Later in the price DB you would see a section BitCoin with lines of the form Currency: GBP; Security: BitCoin; Date:...;Source:Finance::Quote; Type: Last; Price: x.yz Also adding the market as suffix would be fine, if you could exchange e.g. GBP against Bitcoin at different places with probably different rates. So in the current situation this is IMHO overkill. So as far as I understand your module, its name is mtgox, the market is Mt.Gox so the entry should look like { FALSE, 0, 0, "Mt.Gox Bitcoin/Litecoin exchange, JP", "mtgox", "mtgox" }, and probably one or two fallback entries { FALSE, 0, 0, "Bitcoin (MtGox, ...)", "bitcoin", "bitcoin" }, { FALSE, 0, 0, "Litecoin (MtGox, ...)", "litecoin", "litecoin" }, and the rest could be part of the symbol like in the currencies. So I assume the F::Q modules currency and that in the yahoo directory could give you a clue. Later an update of gnucash-docs/help/C/tips-appendix.xml would be fine too. Just for completeness: https://en.bitcoin.it/wiki/MtGox/API is linked by mtgox.com
What should happen here ? Should I revert the commits while we wait for an improved patch or will the improvements be made on top of the current patches ?
Feel free to revert for the time being.
Comment on attachment 242344 [details] [review] fq-bitcoin.patch Per comment 1.
Comment on attachment 242344 [details] [review] fq-bitcoin.patch Change r22988 reverted in r23119 per comment 8.
I've reverted the changes and I'm closing this bug. OP, when you've worked out a new patch, please file a new bug.
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=698769. Please update any external references or bookmarks.