26
Automating personal investment reports with Gitlab Pages and CI/CD pipelines
Iโve been investing in stocks and mutual funds in the Indian stock market for a couple of years. The reports available on the trading platforms are not sufficient. Moreover, I use multiple platforms making it impossible to look at the health of my portfolio as a whole. So I set out to create my personal investment report. These were my expectations:
- Reports should be available at my fingertips
- Minimal cost and maintenance
You can read about my investment strategy here.
To create reports I needed two datasets:
- Trades (buys and sells)
- Latest prices
The trading platform I use doesnโt provide APIs to fetch my trades automatically ๐. So I manually export the trade book (as CSV) end of every month and store them in a โdataโ folder in the repository.
I wrote a python script that crawls the stock exchange sites. It collects the end of day prices which is good enough for my usecase. You can check out the code here.
With all my trades and their latest prices, I could calculate the metrics that I was interested in:
- Total investment
- Current value of the portfolio
- Returns (absolute and percentage)
- XIRR (code to calculate XIRR)
I segregated my trades into equity and debt and calculated the same metrics for the two categories as well. With these metrics, I used Jinja templating engine to display these numbers in a simple cards design ๐
Finally, I set up Gitlabโs pipeline schedule to generate the above HTML file every day after the markets closed. And with Gitlab pages, served the same HTML by placing it inside the public folder. For private repositories, only members can access the Gitlab pages thus making it my personal investment report ๐ป
Are you an investor looking to create a personal investment report just like this one? Feel free to drop your comments (or reach out to me on Twitter), I can share more details.
If you liked this article, you can subscribe to my newsletter to get new articles directly in your inbox ๐
26