π Introduction
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.
πΈ Data collection
To create reports I needed two datasets:
- Trades (buys and sells)
- Latest prices
1. Trades
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.
2. Latest prices
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.
π Report generation
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 π
Top comments (0)