Python analysis of WIG

Two friends told me about their recent stock-trading experience. Having traded myself in high-school, I've had some sentiment and decided to see if I could make more rational decision that (the poor ones, admittedly) I've made then.

(Technical diversion in gray)
The first problem is that you don't "own" the financial statements data: by own I don't mean some intellectual property right – by own I mean having a file on my HDD with the data (be it a text file, db, hdf5, whatever) that one has the freedom to analyse. 

Scraping/HTML-parsing modules for Python came to help. Using mechanize, I was able to emulate a browser; BeautifulSoup was good for but failed for which then yielded to lxml.

A simple question would be: is WIG under- or overvalued? To answer, take the P/E and P/BV values for all 400+ companies, bin them and draw a histogram.

Fig 1. (A) Price-to-book value (per share) comparison, (B) Price-to-earnings (per share) comparison

Fig 1A. Shows that P/BV is less than 1 for most companies – this means that if the company was sold (all its cash, machines, factories, intellectual property rights and whatnot) and all that money would be given to the shareholders, you would get more cash per share than the share sells for now. Fig 1B. shows a similar processing done for earnings-per share; note the high bar at 0.0 – these are the companies generating losses.

Benjamin Graham would be happy to see these plots: WIG is undervalued. (I only wish I could dig-up the data from before the crisis!) Being undervalued does not mean it's a great idea to jump in – not many Polish stock-listed companies have any competitive advantage over EU/US/AS(ian) companies other than understanding the local environment better, which is not something that will last.

Plotting and analysis code is available at


Popular posts from this blog

React.js – edit and delete comments in CommentBox

ROCS-like shape overlap in rdkit

Example slurm cluster on your laptop (multiple VMs via vagrant)