-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Improve degiro v3 parsing #148
base: main
Are you sure you want to change the base?
Conversation
@dickwolff I just spotted #146. It's still a half-measure, I believe. There are complex cases when one sale or purchase can include two or more buy/sell records and multiple transaction fee records. Please take a look at the description for examples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions on how to improve the mapping for DEGIRO. I have done an initial review of the changes. Overall I think you’re on the right path, but I have some remarks, questions or suggestions.
Please note that I have reviewed it on my iPad, so I might not have the full picture of all the changes. I will look into it some more later when I can get on a pc.
src/converters/degiroConverterV3.ts
Outdated
* since buy/sell txs are in EUR. | ||
* | ||
* This hack allows to buypass all internal heuristic and hardcode correct results. | ||
* Format: IE00B02KXK85=FXAC.AS,foo=bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen a similar thing with the isin of VWRL resulting in VWRL.L instead of VWRL.AS (see comment on line 92 on main).
I think you’re on the right path to a solution, but I think it can be improved upon. I’d then rather use a simple text file with mappings which you as a user can provide.
I have created #149 for this to make this separate of this change. Could you revert any change regarding this mapping override, so the this PR is moreso a better fix for the transaction matching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have ready code? If not, I can write it since I need it. Do you have any particular preferences implementation wise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I have no code yet, but your suggestion gave me an idea on how to do it.
You can give it a go, but preferably separate from, and after this change has been merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I have no code yet, but your suggestion gave me an idea on how to do it.
You can give it a go, but preferably separate from, and after this change has been merged
so, just a plain file with foo=bar
pairs on each line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was basically what I was going for. Then read it when present, and also provide a file volume mount in Docker.
But as stated, I’d prefer it separate from this PR
8f96285
to
98b28af
Compare
btw, do you prefer rebase + force-push or extra commits? |
I recently tried to switch to rebasing, so please |
98b28af
to
10612a2
Compare
@dickwolff I fixed all your suggestions and added tests. But I didn't figure out how to update Yahoo Finance mock file to include info about new ISINs. How do I do it? |
@dickwolff I just realized that the import logic seriously messes up with currencies. It just replaces record currency with looked-up-from-yahoo currency without any proper conversation. I understand why, but it affects results. In my case, with INRG.L, quite seriously. Asked question: ghostfolio/ghostfolio#4139 (comment) What was your thinking when you wrote it? |
See the wiki for instructions how to do this.
This was a fix for GBP to GBp matching. I have since made some changes in a branch to revert that change, in response to #129. I have not merged that yet due to something I wanted to verify with the reporter first. But I think I will do that merge tomorrow, so you can continue working on this. |
Some other samples of multi line transaction record that are currentlly not really well processed:
|
@jonathanR79 Thanks for providing these. Of the first set, the first records should be ignored. I think that currently is already the case. Of the second set, would you want there to be 2 buy records, or is it fine to combine all these 6 lines into one activity for Ghostfolio? |
On the first, it's detected as a divident for now. On the second, the purchase price is different. So , ideally it should be two different records. A single entry with the average of the 2 should work as well but I'm not sure what is the easiest. |
10612a2
to
821fb3e
Compare
@dickwolff I've pushed an improved version. Unfortunately, I'm unable to test it locally. For some reason, ghostfolio tells me, "Don't have a currency rate from EUR to USD." I'm unable to work around it for now. |
@jonathanR79 this code will do two records. One with combination of TX costs, second one without one tx cost. |
You should be able to this via Admin Control. Click the I will hopefully have some time this weekend to go through your changes and leave review. |
I tried that. It doesn't help. I'm kinda stuck. I see that ghostfolio extracts and adds historical data for USDEUR, but it fails with the opposite conversation: EURUSD. I don't know/see a way to import it. |
oh, I figured it out. It's a bug in ghostfolio. I'm preparing a PR. |
submitted ghostfolio/ghostfolio#4187 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked at the changes and they seem to make sense overall. I might do some testing and code cleanup myself after merging, but the idea is sound. Great work!
Finally, can you bump the versions to 0.23.0?
@@ -35,7 +35,7 @@ describe("degiroConverterV3", () => { | |||
// Assert | |||
expect(actualExport).toBeTruthy(); | |||
expect(actualExport.activities.length).toBeGreaterThan(0); | |||
expect(actualExport.activities.length).toBe(26); | |||
expect(actualExport.activities.length).toBe(43); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the tests are currently failing. V2 converter is missing 1 (as V2 and V3 tests are sharing the same input file for testing), and V3 only got 31 instead of expecting the 43 you put in the test. Can you take a look at this and make changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dickwolff I need help with tests:
- to update Yahoo Finance information. I think the instructions from the wiki are not complete. I got a missing import of a Mock object, which I didn't figure out how to import. Note that I'm a first-time user of Typescript
- How do I print debug statements (to stdout/stderr) in tests? I'm getting unexpected behavior, which I need to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Hope this helps:
- If you use an IDE like VSCode, you can to
CTRL + .
(dot) and then import all usings. - In the tests, console statements are supressed. You can comment the whole
beforeEach(() => {
function, then you'll get the console log statements in your console. For debugging purposes I usually addconsole.log(...)
statements on places that could help me debug.
This commit re-works degiroConverterV3 logic. The main change is that the code now can consider a set of records as one, instread action+tx record. The following set of records are one sell with two transaction fees records. They can be reported as one in ghostfolio. The previous code didn't handle this. 23-12-2020,10:03,23-12-2020,ISHARES GLOBAL CLEAN ENERGY UCITS ETF,IE00B1XNHC34,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-0.79,EUR,,1d2e7a85-cf67-4325-82c7-d5994a0afb98 23-12-2020,10:03,23-12-2020,ISHARES GLOBAL CLEAN ENERGY UCITS ETF,IE00B1XNHC34,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-4.00,EUR,,1d2e7a85-cf67-4325-82c7-d5994a0afb98 23-12-2020,10:03,23-12-2020,ISHARES GLOBAL CLEAN ENERGY UCITS ETF,IE00B1XNHC34,Verkoop 120 @ 1.202 GBX,,GBP,1442.40,GBP,,1d2e7a85-cf67-4325-82c7-d5994a0afb98 Another example is below. It has two sells and one tx record. 11-07-2024,16:46,11-07-2024,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,"Verkoop 16 @ 124,28 EUR",,EUR,1988.48,EUR,,56e1f16b-4142-4373-851d-45d0505fe12c 11-07-2024,16:43,11-07-2024,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-1.00,EUR,,56e1f16b-4142-4373-851d-45d0505fe12c 11-07-2024,16:43,11-07-2024,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,"Verkoop 8 @ 124,28 EUR",,EUR,994.24,EUR,,56e1f16b-4142-4373-851d-45d0505fe12c Or this 24-03-2020,13:10,24-03-2020,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-0.26,EUR,,810d6e1d-af8e-43a4-830e-0b85bf90c818 24-03-2020,13:10,24-03-2020,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-2.00,EUR,,810d6e1d-af8e-43a4-830e-0b85bf90c818 24-03-2020,13:10,24-03-2020,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,DEGIRO Transactiekosten en/of kosten van derden,,EUR,-0.02,EUR,,810d6e1d-af8e-43a4-830e-0b85bf90c818 24-03-2020,13:10,24-03-2020,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,"Verkoop 14 @ 61,7 EUR",,EUR,863.80,EUR,,810d6e1d-af8e-43a4-830e-0b85bf90c818 24-03-2020,13:10,24-03-2020,VANGUARD FTSE ALL-WORLD UCITS ETF,IE00B3RBWM25,"Verkoop 1 @ 61,7 EUR",,EUR,61.70,EUR,,810d6e1d-af8e-43a4-830e-0b85bf90c818
a01e3db
to
9a92844
Compare
Added
This commit re-works degiroConverterV3 logic.
The main change is that the code can now consider a set of records as one instead action+tx record.
The following set of records is one sale with two transaction fee records. They can be reported as one in ghostfolio. The previous code didn't handle this.
Another example is below. It has two sells and one tx record.
Or this
To make it even more complicated. There are cases of taxes without any associated buy/sell:
There are also a bunch of cosmetic changes.
This is quite a significant change, so I'm looking into your feedback. I've collected a corpus of tests while debugging. I'm ready to write tests for them, but I would like your feedback to ensure you're comfortable accepting this PR.
Fixes
Checklist
package.json
Related issue (if applicable)
Possibly resolves #140