Zarathustra2 / TradeRepublicApi

Unofficial trade republic API
MIT License
275 stars 68 forks source link

Count of stocks is sometimes a float value, could we round it? #5

Open bufemc opened 3 years ago

bufemc commented 3 years ago

When trying to import myTransactions.csv by "Datei - Importieren" to Portfolio Performance, via:

some stocks in the CSV file have a float amount, e.g. 19,7505 Morphosys. I guess it should normally be 20.

I don't know exactly why, and I guess the fault is for TR, it could be they somehow include their fee in this calculation or so.

A workaround could be to round this number (really, otherwise 19,75 would become 19, which is wrong, but e.g. 19,3 should be 19). This could happen by default or if you really wish you could turn it off by parameter.

Extract to reproduce this:

2021-05-04;Verkauf;20.1461;55.32;1114.48;1.0;CA0084741085;Agnico Eagle Mines
2021-05-04;Verkauf;0.9973;2791.0;2783.4;1.0;US0231351067;Amazon
2021-05-04;Kauf;5.0000;141.95;710.75;1.0;DE0005810055;Deutsche Boerse
2021-05-03;Kauf;50.1497;7.95;399.69;1.0;FR0000054900;Télévision Française 1
2021-04-30;Kauf;100.0000;7.59;760.0;1.0;DE000A289Q91;Schaeffler

Additionally we should enforce to use either . or , when creating the CSV. After importing I was triple-millionaire :)

Zarathustra2 commented 3 years ago

I don't think this is a mistake. TR allows you to buy fractional shares, that is why the count is a float. You probably bought a fractional share

bufemc commented 3 years ago

No, I never buy fractional shares. Really. Either it is TR which somehow wants to be smart and include the fee, or something else. But also here I might do a breakpoint next time to check out what the unprocessed incoming data is.

For above: I know for 1000% sure I bought 20 Agnico, 1 Amazon, 5 Deutsche Boerse (no fraction), 50 TF1 and 100 Schaeffler (no fraction).

Jolg42 commented 2 years ago

If you buy through the Savings feature which allows to buy every month for example for 100e of one action then it will buy the necessary amount of shares to match the monthly amount defined, likely not an integer. Did you use that maybe?

bufemc commented 2 years ago

If you buy through the Savings feature which allows to buy every month for example for 100e of one action then it will buy the necessary amount of shares to match the monthly amount defined, likely not an integer. Did you use that maybe?

NO, really not. Sorry for the late reply. I only buy full (integer) shares. The only time I got fractional shares was once when Stellantis gave out "free papers", but I sold them.

bufemc commented 2 years ago

So to settle this, too:

This was once the result: 2021-05-04;Verkauf;20.1461;55.32;1114.48;1.0;CA0084741085;Agnico Eagle Mines

Now it is: Date;Type;Amount;Value;Price;Fees;ISIN;Name 2021-05-04;Sell;20.2633;55.0;1114.48;1.0;CA0084741085;Agnico Eagle Mines

The "cashChangeAmount": 1114.48, is correct. But I have no clue how they calculcate the other stuff, even if I add/subtract 1 Euro fee, I don't get it..

    {
        "type": "timelineEvent",
        "data": {
            "id": "***",
            "timestamp": 1620136190924,
            "icon": "https://assets.traderepublic.com/img/icon/timeline/Arrow-Left.png",
            "title": "Agnico Eagle Mines",
            "body": "Limit Sell order executed at 55.32 \u20ac\nProfit: \ufffc 3.35 %",
            "cashChangeAmount": 1114.48,
            "action": {
                "type": "timelineDetail",
                "payload": "***"
            },
            "attributes": [
                {
                    "location": 45,
                    "length": 8,
                    "type": "positiveChange"
                }
            ],
            "month": "2021-05"
        }
    },
raptor0815 commented 2 years ago

I think the time line event is not sufficiently detailed. The number if shares is missing so the tax can not be calculated. or the other way: shares can not be calculated without knowing the fees/taxes. Is there a way to access fees/taxes/shares with the API?