Investing with pythons help | The Idea

A journey on how I’m planing to use python to help me change my investment strategy towards a more dividend focused approach.

Maximilian Pollak
4 min readJul 23, 2021
Photo by Precondo CA on Unsplash

It’s been a goal of mine for a while to change my approach in terms of investing.
I have to thank mainly my brother for this, he was the one that heavily influenced me and got me to invest in the first place.
He made it clear to me how important it is to invest especially while you are still young, so you can enjoy financial freedom in your later years.
So I started investing, but it became clear to me after a short period that I had to change my approach. So in my head I forged the idea of using python to help me figure out what way to invest.

That brings me to the gist of this article, lay out what the script should do, how it should work on a high level concept, and what input / outputs there should be.

Photo by Toàn Nghĩa on Unsplash

So let’s sit down and think. What should it do?

The script should be able to interpret the parameters and inputs you give it, and then should spit out a excel sheet, full with charts, and tables.

What inputs does it accept?
-Amount of money invested monthly.
-Amount of dividends you want to get monthly (End goal).
-If you want to reinvest dividends or not.
-What sectors to you want to exclude / include.
-How much a stock can contribute to your goal at the most. (To diversify)
-How many stocks you want in total(min / max)
-How many stocks you want per sector (min / max)
-?Maybe? Filter how risky you want the strategy to be.
There also should be a filter of stocks that you want to not be considered. Maybe your broker does not have them, or whatever other reason.

What should it output?
There should be a table of all the stocks that it advises you to invest in. Along with the number of stocks you will have (if you keep your current monthly investment + reinvest dividends (or not)) and how many years it will take to reach your end goal.
The table should also include yearly (up until 5 years maybe) updates on how many stocks you have then and what the dividends would then be (assuming dividends stays steady). It also should have graphs projecting it into the future, showing you how your portfolio is growing via stock price increase (conservative estimates) and via dividends.
I would like everything to fit on one page, but I think that would be impossible, especially with the graphs. So I thought of an option that only prints the table (and the graphs numerically), and the other option that is longer where it displays the graphs.
Another option I’m flirting with is that you can enter your E-Mail and the script will E-Mail you once a certain amount of time has passed, so you go over your portfolio and maybe run the script again to see new suggestions.

How to achieve this?

There are many things that need to be implemented, as we just saw. To do this, we need to first find the right libraries to do the jobs we want. I’m not yet 100% set on what I will use to get the dividends, and other information about the stocks we need, so far I have my eyes set on Yahoo Finance (yfinance library).

Final thoughts

I think overall there is still lots I have to figure out and nail down on exactly how I want it to work. In the next part of this series I will tell you my findings of that exploration.
Until then, I wish this maybe inspired you to also work on your own project, and as always if you have suggestions or comments, leave them below.

--

--

Maximilian Pollak

A 27 year old aspiring Data Engineer with an interest for programming, investing, reading and science. I hope to learn lots here