dickwolff / Export-To-Ghostfolio

Convert transaction history export from your favorite broker to a format that can be imported in Ghostfolio.
https://hub.docker.com/r/dickwolff/export-to-ghostfolio
Apache License 2.0
43 stars 8 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined at DeGiroConverter #6

Closed JahFyahh closed 9 months ago

JahFyahh commented 10 months ago

I just installed Ghostfolio the docker compose way and thats up and running. Now im trying to import my deGiro transactions from the last couple year, but after running npm run start degiro I get the following error:

> trading212-to-ghostfolio@1.0.0 start
> nodemon "degiro"

[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,js
[nodemon] starting `ts-node ./src/index.ts degiro`
Processing file using DeGiro converter
Read CSV file sample-trading212-export.csv. Start processing..
(node:2894272) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at DeGiroConverter.<anonymous> (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:52:49)
    at Generator.next (<anonymous>)
    at /home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:31:71
    at new Promise (<anonymous>)
    at __awaiter (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:27:12)
    at /home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:40:45
    at Parser.<anonymous> (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/node_modules/csv-parse/dist/cjs/index.cjs:1392:7)
    at Parser.emit (events.js:314:20)
    at Parser.EventEmitter.emit (domain.js:483:12)
    at errorOrDestroy (internal/streams/destroy.js:108:12)
(node:2894272) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2894272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[nodemon] clean exit - waiting for changes before restart
JahFyahh commented 10 months ago

I found out that the export was incorrect. So i exported it again and it is running now but it doesn't do much it seems. This is the output:

> trading212-to-ghostfolio@1.0.0 start
> nodemon "degiro"

[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,js
[nodemon] starting `ts-node ./src/index.ts degiro`
Processing file using DeGiro converter
Read CSV file Account.csv. Start processing..
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% | ETA 1020s | Duration: 10s | 8/891(node:3030357) UnhandledPromiseRejecti.
    at DeGiroConverter.<anonymous> (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/deg)
    at Generator.next (<anonymous>)
    at fulfilled (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:28)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:3030357) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwin)
(node:3030357) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise reje.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% | ETA 1020s | Duration: 68178s | 8/891
dickwolff commented 10 months ago

Hi there!

Could you try and run the tool with debug logging on? If you set ‘DEBUG_LOGGING’ to true in the environment variables you will get more logging.

Also, I know there are some issues currently with the exporter, see #4

I have a work in progress branch that should work better than the current main branch. It’s not done yet.

JahFyahh commented 10 months ago

Hi @dickwolff Thank you for your reply, I'm doing a run now with the debug on true. The export had about 800+ rows, so i removed the majority to check if that would help. When i ran it with about 5 it did create a json file, but that contained no activities. I am running it now with 170 rows and its showing the below for the last 20 min (not sure its doing anything). where would I see the log files?:


     getSecurity(): Found 1 matches by ISIN US00206R1023
        getSecurity(): Found 1 matches by ISIN US00206R1023
        getSecurity(): Found 1 matches by ISIN US00206R1023
        getSymbol(): Match found for US00206R1023
        getSecurity(): Found 1 matches by ISIN US92343V1044
        getSecurity(): Found 1 matches by ISIN US92343V1044
        getSecurity(): Found 1 matches by ISIN US92343V1044
        getSymbol(): Match found for US92343V1044
        getSecurity(): Found 1 matches by ISIN NL0011540547
        getSymbol(): Match found for NL0011540547
        getSecurity(): Found 1 matches by ISIN NL0011540547
        getSymbol(): Match found for NL0011540547
        getSecurity(): Found 1 matches by ISIN NL0011540547
        getSymbol(): Match found for NL0011540547
        getSecurity(): Found 1 matches by ISIN NL0011540547
        getSymbol(): Match found for NL0011540547
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1% | ETA 489s | Duration: 10s | 10/891(node:3793770) UnhandledPromiseRejecti.
    at DeGiroConverter.<anonymous> (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/deg)
    at Generator.next (<anonymous>)
    at fulfilled (/home/ingz/docker/compose/apps/Ghostfolio/Export-To-Ghostfolio/src/converters/degiroConverter.ts:28)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:3793770) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwin)
(node:3793770) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise reje.
        getSecurity(): Found 1 matches by ISIN LU1959429272
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1% | ETA 489s | Duration: 1438s | 10/891
dickwolff commented 10 months ago

I haven't seen this error before. No clear notion of what went wrong. I don't think it will complete the run.

Could you send a part of the export so I can take a look at it?

JahFyahh commented 10 months ago

I've been going through it and one of the line it is failing on is 03-04-2023,09:04,03-04-2023,VANGUARD FTSE AW,IE00B3RBWM25,"Koop 1 @ 97,93 EUR",,EUR,-97.93,EUR,43.62,07d17d6b-cb47-4949-b9d7-2c506537783e Not sure why but when I remove this it continues, until the next failure which is: 23-02-2023,04:21,23-02-2023,FBR LTD,AU000000FBR4,"PRODUCTWIJZIGING : Koop 500 @ 0,039 EUR",,EUR,0,EUR,18.3, 23-02-2023,02:30,23-02-2023,FBR LTD.,AU000000FBR4,"PRODUCTWIJZIGING : Verkoop 500 @ 0,039 EUR",,EUR,0,EUR,18.3, I had to remove both lines here to continue. Next error line is 16-02-2021,14:42,16-02-2021,FBR LTD.,AU000000FBR4,"Koop 500 @ 0,039 EUR",,EUR,-19.5,EUR,51.92,1bb91f96-6356-4b37-be74-bb6d6b8996fb

Maybe you can debug with this, i do not see a clear correlation between them that could be the error. I suspected ", but that is also part of other lines which it does proces and removing it caused the following error TypeError: Cannot read property 'length' of undefined

Hope this helps somewhat. Either way thank you very much for everything you've done for this project so far.

PS1: I have exported data al they back from 2020, not sure if that breaks anything. It really shouldn't. PS2: The above lines are from the Rekeningoverzicht i downloaded from deGiro. PS3: The (somewhat strange) headers: Datum,Tijd,Valutadatum,Product,ISIN,Omschrijving,FX,Mutatie,,Saldo,,Order Id

dickwolff commented 10 months ago

Weirdly enough, the lines you sent in your post are processed on my machine. The last line are two orders, a buy and sell order, but the tool interpreted them both as sell-orders because the amount is positive with both orders. (No money was "withdrawn" for the buy order). The order above is an actual buy order (and I presume there also is a sell order somewhere in your order book) which is why I am inclined to say that the PRODUCTWIJZIGING is a line that needs to be skipped in the processing.

@ PS1: It shoudn't @ PS3: These are the same headers as I have in my example export.

I'm pushing my changes to the main branch and I would like you to try again with that code and see if the issue persists. If so, please let me know and I will look into it further.

JahFyahh commented 10 months ago

Hi @dickwolff ,

It is running through the list without error now, but on import into ghostfolio im getting import errors:

image

I have created my own PowerShell script based on yours that works for me, so if this works for others no need to put more effort in it and you can close this issue.

Here's my code: https://github.com/JahFyahh/Scripts/blob/master/Ghostfolio/deGiro2Ghostfolio.ps1

dickwolff commented 10 months ago

Seems like something went wrong with the processing of the previous line. I’ll take a look at your PowerShell script and see if I can take some inspiration from it.

dickwolff commented 9 months ago

Hi @JahFyahh, can you provide me with a (partial) export of transactions that aren't processed by my converter? That way I can look into why this issue occurs. Thanks!

JahFyahh commented 9 months ago

hi @dickwolff to be honest i am using my powershell scripts to process my activities, with these scripts i can import them directly to ghostfolio using the api

dickwolff commented 9 months ago

This is on my roadmap. The thing that is keeping me from doing this right now is because you wont ever be 100% right with converting using the Yahoo Finance api. I want users to have control over what they are importing. Using the manual import option you can verify for yourself if the conversion was successful and make corrections if needed.

dickwolff commented 9 months ago

If you no longer have issues with this tool I propose to close the issue.

JahFyahh commented 9 months ago

@dickwolff

I will close this issue.

Thank you very much to you and all who helped for all the time spent creating and helping me and others with this tool.