ghostfolio / ghostfolio

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
https://Ghostfol.io
GNU Affero General Public License v3.0
4.6k stars 468 forks source link

Dividends #512

Open fly-man- opened 2 years ago

fly-man- commented 2 years ago

Is there also an idea / implementation regarding dividend payment that can be registered ?

dtslvr commented 2 years ago

Hi @fly-man-

There is currently only a rough concept how to support dividends in Ghostfolio.

I think the first step would be to introduce a new type DIVIDEND besides BUY and SELL in the transaction management and adapt the portfolio calculations accordingly (performance, net worth).

In a second step, the import of dividends could possibly be automated.

What do you think of this idea? Are you interested in implementing this feature?

OliRafa commented 2 years ago

I thinks it's a good ideia.

I think we could build a dedicated page just for dividends in the app. Here's some inspiration from Kinvo:

Screenshot 2021-12-12 at 11 35 02

In this page we can see the total value (Total em proventos), amount invested (total investido), dividend yield (rentabilidade), average by month (Média mensal), and in the middle dividends by month and by stock (Proventos por mês). Here's a second screenshot for dividends by month and by stock:

Screenshot 2021-12-12 at 18 33 52

Bellow that we have all entries in dividends (Histórico) and total dividends by stock (proventos por ativo). On the right hand-side there's something very cool we could implement which is an Agenda with upcoming and past dividends in some timeframe. Maybe this part could be build in a second iteration - when importing dividends automatically.

What do you guys think?

I want to help build these features (mainly on back-end, where I'm more proficient). Where do I begin looking in the code?

FedericoComoglio commented 2 years ago

+1. This feature would be a pillar. I agree with @dtslvr's suggestion to take an incremental approach. Introducing a new transaction type, DIVIDEND, would be an excellent start.

dtslvr commented 2 years ago

I have set up #547 with the new type.

I think DIVIDEND is relevant for overall performance, but also it should be reported separately. So a first step could be to extend the tests (portfolio-calculator.spec.ts). Who would like to give it a try?

I can work on the frontend part that a user is able to create and update a dividend.

FedericoComoglio commented 2 years ago

Thank you very much for considering this feature request and all the great work you are putting into building Ghostfolio.

dtslvr commented 2 years ago

Current state of #547:

FedericoComoglio commented 2 years ago

I do not feel sufficiently familiar with the tool stack to help you developing but I am happy to test features.

fly-man- commented 2 years ago

Also I checked with the Nasdaq website and this might be an easy way to get the dividends as well.

The table is already in the correct format in which you'd expect the data to be

dividends

fly-man- commented 2 years ago

When trying to migrate to the latest version

root@ghostfolio:/opt/ghostfolio# docker-compose -f docker/docker-compose.build.yml exec ghostfolio yarn database:migrate
yarn run v1.22.15
$ prisma migrate deploy
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "ghostfolio-db", schema "public" at "postgres:5432"

19 migrations found in prisma/migrations

Error: P3005

The database schema for `postgres:5432` is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
dtslvr commented 2 years ago

What is the content of your table _prisma_migrations @fly-man-?

According to these instructions, you have to tell Prisma which migrations have already been applied.

I guess it's something like docker-compose -f docker/docker-compose-build-local.yml exec ghostfolio yarn prisma migrate resolve --applied <migration_name>

Edit: Official Prisma documentation to baseline a database

fly-man- commented 2 years ago

Remade the docker container, that fixed it for me

fly-man- commented 2 years ago

Dividends is part of the equation if a person makes a profit, at the moment I don't see that in the overview

FedericoComoglio commented 2 years ago

Thank you, @dtslvr, for releasing the dividend feature. It works well for me (currently purely for logging purposes). Happy to discuss further extensions as outlined in the checklist above.

dtslvr commented 2 years ago

Thank you, @dtslvr, for releasing the dividend feature. It works well for me (currently purely for logging purposes). Happy to discuss further extensions as outlined in the checklist above.

Thanks for the feedback @FedericoComoglio 🙂

Dividends is part of the equation if a person makes a profit, at the moment I don't see that in the overview

You're right @fly-man-. Currently you can only see the total dividend in the portfolio summary. I would prefer to sort out #554 first before adding more complexity. Any support would be much appreciated.

longstone commented 1 year ago

Just my two cent:

Keep in Mind that a dividend is a corporate action. There are more corporate actions like Splits, Rights, Spin-Offs and so on.. Also Dividend can be cash or stock. Sometimes a dividend is received with withholding tax.

Maybe it is a good idea to add Corporate Actions and Dividend as a type of it. Check also Corporate Actions on Investopdia

davidalo commented 5 months ago

Hello, I just came across ths project and I think is great. However, as @fly-man- said "Dividends is part of the equation if a person makes a profit" and this is the main point for Dividend Growth Investors.

Part of my portfolio is based on DGI strategy and the features I miss are:

The "main problem" I see here are taxes. Depending on your country you can have different origin and destination taxes. Unfortunately I have no experience with the tech stack you use, but I can help with testing or anything else.