Skip to content
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

Option between FIFO and MA selling stocks #4503

Open
MrTempiko opened this issue Feb 1, 2025 · 12 comments · May be fixed by #4546
Open

Option between FIFO and MA selling stocks #4503

MrTempiko opened this issue Feb 1, 2025 · 12 comments · May be fixed by #4546

Comments

@MrTempiko
Copy link

It would be a nice feature, if we could choose between FIFO (First in, First Out) and MA (Moving Average) method when selling stocks. I am not from Germany, so my broker uses the MA method.

Because of this, my gross profit is different in PP and my broker.

Are there any plans for adding this feature in the future?

@mierin12
Copy link
Contributor

mierin12 commented Feb 1, 2025

I agree it would be nice. The difference does not occur when selling (it is the same sell) but in the calculation afterwards.
In some area there are already the option to show MA realized/unrealized gains (columns Performance/Capital Gains MA), but I think it would be worth to have it in the Calculation tab/widget. I once tried to look into the code to see how to adapt this part to MA, but it was not super straight forward. I can try again but no promise of success.

@MrTempiko
Copy link
Author

Definitely would be nice, if you could try again, as I have no coding skills.

@MrTempiko
Copy link
Author

I agree it would be nice. The difference does not occur when selling (it is the same sell) but in the calculation afterwards. In some area there are already the option to show MA realized/unrealized gains (columns Performance/Capital Gains MA), but I think it would be worth to have it in the Calculation tab/widget. I once tried to look into the code to see how to adapt this part to MA, but it was not super straight forward. I can try again but no promise of success.

Any progress yet? Can I support you in any way?

@mierin12
Copy link
Contributor

Any progress yet? Can I support you in any way?

Hello, yes I think I managed to get something !
Work in progress here :
master...mierin12:portfolio:calculation_FIFO_vs_moving_average

It applies to

  • The Calculation view (including Forex capital gains)
  • The Securities Performance view with two new columns (including Forex capital gains)
  • The Calculation widget

I still need to polish a bit the different labels for all languages and add more tests.
Then what remains are the "record", what you can see as tooltips in the Calculation view. But maybe for a first implementation it can be done without them.

@mierin12 mierin12 linked a pull request Feb 25, 2025 that will close this issue
@MrTempiko
Copy link
Author

Looks promising, can‘t wait to test ist.

One question: Is the moving average method also added in the Trades view?

@mierin12
Copy link
Contributor

Ah no, I missed it. Maybe not complicated, what I understand : the Trades themselves are the same, but it would mean duplicating the columns:

  • Entry value

  • Entry value per share

  • Profit loss

  • Gross profit loss

As per Moving average ? That's all ?

If you want to test it in advance, it is possible if you install Eclipse.

@MrTempiko
Copy link
Author

Yes, I guess these are the main columns.
I have to look at it later, if we missed one.

Tried installing eclipse, but for me it‘s not so easy to get everything running, lol

@MrTempiko
Copy link
Author

So I looked into it. The columns you mentioned need to be changed, and also maybe the Return (Rendite in German) one?
Depends on how the Return is calculated.

General the Moving Average may also should be considered in the Payment View?
I personally didn't use the Payment View yet, but I think it's also effected by FIFO/Moving Average

@mierin12
Copy link
Contributor

Ok yes, the Return in Trade view is the "simple return", exitvalue/entryvalue -1 so impacted by the entry value.

For Payment, maybe too, but a very small cases, "Closed trades" and "Sum" maybe.

All of those should not be complicated, but I am wondering about the UI. This will create many new available columns in the Trades view, a quite long menu to select from. Maybe with lots of submenu.

@MrTempiko
Copy link
Author

Yeah, maybe it‘s an option that there is one general setting, where you can switch between FIFO/MA.
The columns then adjust to which setting is chosen.
I don‘t know if thats possible or too complex.

Hope you kind of know what I mean?

@mierin12
Copy link
Contributor

So I double checked for the Trades, it is more complex than just new columns. Trades are inherently FIFO. Closed Trades are related using the first bought stocks, and the remaining Open Trades are the latest bought stocks.
So if something has to be added for the moving average it would be a new definition of open/closed Trades based on Moving average.

@MrTempiko
Copy link
Author

Ah sh.., that sounds complex.
I definitely use the Trades View and I always get „wrong“ results because it‘s based on FIFO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants