mcpiatkowski / dividend-printer

Tool for tracking and analysing dividend stocks.
MIT License
0 stars 0 forks source link

Intro #1

Open mcpiatkowski opened 6 months ago

mcpiatkowski commented 6 months ago

Idea

The idea is to build a tool that will help with tracking and analysing dividend stocks. I would like to also add tech stocks but with different factors to look at.

As a benchmark I have this site: https://www.simplysafedividends.com/

Proof of concept

Basic POC I am trying to do in google sheets using google Apps Scripts to fetch the data from an api.

Tooling

API

I have tried buch of different APIs and the one that I am working with at the moment is Financial Modelling Prep API.

This one I have found the most easy to use with the most comprehensive coverage of available data. It is also the best in terms of pricing.

Maybe we need to revisit yfinance. It is free?

I have tried:

Additionally I am using Trading212 API. It is very nice to use but it throttles really quickly. The solution is to get data in batch.

Google sheets

Just try it!

So far I have used Apps Script with FMP api to create custom function that I have used in google spreadsheets. Because T212 throttling I get a lot of errors. I would like to use google Cloud Functions to get data in batch ingest it into google BigQuery and then use that data in spreadsheet.

Pros:

Cons?

Questions

How do we create a project that we share?

kacperstyslo commented 6 months ago

Let's open discussion about yfinace

It's easier to share code than excel spreadsheets without VCS.

Easly we can get 40+ years of data, daily interval, no API key required, it's free

from datetime import datetime, timedelta

import pandas as pd
import yfinance as yf

end_date: datetime = datetime.today()
start_date: str = (end_date - timedelta(days=40*365)).strftime('%Y-%m-%d')

print(start_date)
df: pd.DataFrame = yf.download("KO", start=start_date, end=end_date.strftime('%Y-%m-%d'))

print(df.head())
print(df.tail())

# Check the number trading days
assert (252 * 40) - 4 == df.shape[0]
kacperstyslo commented 6 months ago

We can get also dividend & quarterly financials (i.e. revenue)

ticker = yf.Ticker("KO")

dividends: pd.DataFrame = ticker.dividends
quarterly_financials: pd.DataFrame = ticker.quarterly_financials
print(dividends)
print(quarterly_financials.loc['Total Revenue'].tail())
mcpiatkowski commented 6 months ago

Let's open discussion about yfinace

It's easier to share code than excel spreadsheets without VCS.

How do you want to create a dashboard? Any suggestions?

I have created simple cloud function that fetch the data. Next step is save data into BigQuery. From here there is already built in integration with spreadsheets.

If this will be working and we will like the results I am more than happy to start versioning the code with the repo connected to the cloud.

At the moment I am just trying to asses what is the proper way of implementing the solution.

kacperstyslo commented 6 months ago

Let's open discussion about yfinace It's easier to share code than excel spreadsheets without VCS.

How do you want to create a dashboard? Any suggestions?

I have created simple cloud function that fetch the data. Next step is save data into BigQuery. From here there is already built in integration with spreadsheets.

If this will be working and we will like the results I am more than happy to start versioning the code with the repo connected to the cloud.

At the moment I am just trying to asses what is the proper way of implementing the solution.

To quickly visualize data we can use Pycharm (no code, just single click in the notebook).

For more specific dashboards I would go with: https://hvplot.holoviz.org/

Additionally, it would be beneficial to create a database in PyCharm (SQLite one, almost 0 setup is required). We can upload this push this single database file so that the data can be easily accessed in PyCharm as well. All data can be saved into a single database file, which can then be easily imported into a cloud-based database.

mcpiatkowski commented 6 months ago

Do you know that you can deploy your sheet as an app with little html and basically one click? Later you can even use react.

For my personal use case viewing and refreshing the data in the notebook is not nice. I want to open a sheet and see the whole thing being refreshed in real time. Like in safe dividends. It is extremely easy with google. And after you have everything ready you are just step away from scaling this up. With notebook you just have a notebook.

The initial idea is to build something for myself. If that would be good enough we can scale it easily. Plus I find google cloud extremely friendly and easy to use. I want to explore more! :)

But yes the first step should be defining the initial database schema.

kacperstyslo commented 6 months ago

Sure, let's give it a try :).

It's not in real time, there can be a delay of up to 20 minutes. I'm not sure if this matters to you, but it's good to know.

mcpiatkowski commented 6 months ago

We are behind actual market prices that is right but I can poke the API nonetheless. In real time whenever a value in a sheet changes everything that depends on that field is automatically updated.