Bug 492038 - Currency conversion from EUR to BTC fails at yahoo.com
Summary: Currency conversion from EUR to BTC fails at yahoo.com
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: importer (show other bugs)
Version: git (master)
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-22 10:53 UTC by Ralf Habacker
Modified: 2024-10-29 22:47 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 8.2
Sentry Crash Report:


Attachments
testcase (4.84 KB, text/xml)
2024-08-22 10:53 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2024-08-22 10:53:44 UTC
Created attachment 172854 [details]
testcase

SUMMARY

Currency conversion rates can be found e.g. from yahoo with the following url https://query1.finance.yahoo.com/v7/finance/download/%1-%2?events=history&includeAdjustedClose=true.  An example of this is BTC -> EUR.
The problem, however, is that it does not work the other way around, as can be seen in the attached example.

STEPS TO REPRODUCE
1.  start kmymoney
2. Add  an new online quote named "User" (systems with english language) or "Benutzer" (german language) with 

URL: https://query1.finance.yahoo.com/v7/finance/download/%1-%2?events=history&includeAdjustedClose=true
Download mode: Default
Data format: CSV
Identifier: 
Select by: Symbol
Price: Close
Price decimal separator: Period (.)
Date: Date
Date format: %y-%m-%d
Default identifier: EUR-USD
Remote source: not checked

2. load appended test case
3. add account 
Name: "checking (BTC)"
select "Online quotes"

OBSERVED RESULT
A message box appears that the update failed. 

EXPECTED RESULT
This message should not appear and the update should finish without errors.

SOFTWARE/OS VERSIONS
Linux: openSUSE Leap 15.5  
KDE Frameworks Version: 5.102
Qt Version: 5.15.8

ADDITIONAL INFORMATION
The problem is that the desired direction EUR -> BTC is not supported by the remote source. The reverse direction, on the other hand, is available. There should be a possibility that after a failed request, a new request is made with a reversed direction and, if successful, the returned price is inverted.
Comment 1 Ralf Habacker 2024-08-24 10:19:37 UTC
(In reply to Ralf Habacker from comment #0)
> ADDITIONAL INFORMATION
> The problem is that the desired direction EUR -> BTC is not supported by the
> remote source. The reverse direction, on the other hand, is available. There
> should be a possibility that after a failed request, a new request is made
> with a reversed direction and, if successful, the returned price is inverted.

To add such a function, the following points should be noted:
1. should online listings allow reverse search by default ?
2. adding the reverse search after the first search has failed requires an internal refactoring so that errors that occur during the first search are not forwarded directly to the application and thus already trigger error processing.
3. a simpler alternative to 2. would be to manage a list of currency assignments in the online source, which is used to control the direction of a query.
Comment 2 Thomas Baumgart 2024-10-20 07:32:25 UTC
The problem is even worse. All I get in both directions is:

{"finance":{"result":null,"error":{"code":"unauthorized","description":"User is not logged in"}}}

I doubt that there is a short term solution.
Comment 3 Ralf Habacker 2024-10-20 23:40:50 UTC
This issue has been reported for example at https://www.reddit.com/r/sheets/comments/1farvxr/broken_yahoo_finance_url/?rdt=38351. 

Yahoo changed the url and the output format to json, see https://query2.finance.yahoo.com/v8/finance/chart/BTC-EUR?events=history&includeAdjustedClose=true for an example.
Comment 4 Bug Janitor Service 2024-10-29 21:19:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/alkimia/-/merge_requests/50
Comment 5 Ralf Habacker 2024-10-29 22:47:55 UTC
Git commit 07b92d7e646e26982efa5e6ca39aaa573bb11a2b by Ralf Habacker.
Committed on 29/10/2024 at 21:17.
Pushed by habacker into branch 'master'.

Add support for reverse online quote search

If a request for the rate of a conversion is not successful, a search with
swapped symbols will be carried out afterwards, if activated, which can
increase the success rate.

As we are about to freeze the user interface, no changes to the user
interface will be introduced with this commit.
FIXED-IN:8.2

M  +11   -15   src/alkonlinequote.cpp
M  +18   -0    src/alkonlinequote.h
M  +51   -1    src/alkonlinequote_p.cpp
M  +4    -0    src/alkonlinequote_p.h

https://invent.kde.org/office/alkimia/-/commit/07b92d7e646e26982efa5e6ca39aaa573bb11a2b