Out of pure curiosity I wanted to have a closer look at insider tradings / director’s dealings of people associated with the top 30 corportations in Germany – currently listed in the DAX. By law high-ranking managers of a company and people closely related to them have to report their tradings of the respectives company’s stocks. To make this pile of tradings more easily accessible I wrote a tool using the JavaScript library d3.js that shows the stock quotes on a weekly basis (red bar from lowest quote to highest quote that week) and an orange bar for the weeks where insider tradings were done. When you click on an orange bar then a table below the chart is displayed / updated where the details are listed of the separate deals that were executed.
The selection of a week where tradings happened (shown with orange bars) works by hovering over an orange bar – this bar’s year and week is then shown next to the select box (currently week 12 of year 2003) at the top. If you now click on this bar or (without hovering over another orange bar) somewhere on the chart then this orange bar turns green and the tradings for this week are displayed below in a table.
The deal type tells you if the stocks have been bought (B / green) or sold (S / red). For some deal types I couldn’t figure out what they were supposed to mean – mostly because they were just short snippets from the whole deal type description of the original trade report – they are colored gray. The rest should be evident.
The reporter’s position and sometimes the deal type are given in German. Check out Google Translator or dict.cc for the translations. I did my best to clean up the data and make it homogenous but I didn’t want to take this further as it would have consumed too much time.
Corporate metamorphosis and one company several stocks
Mind that during those 10 years some companies merged or split which also affects the respective stocks of course. On the right side I added a column which keeps the ISIN or WKN of the traded stocks. If it differs (it is colored red in that case) then it is not clear if the traded stocks correspond to the quotes chart. That depends on what happened in detail. For example there is one deal referring to VW but to the no-par value share and not to the charted preferred stock which is listed in the DAX.
d3.js is fun to work with
Next to making the information on director’s deals browsable, this project also served as my first hands-on d3.js experience – and I must say I really like this library! It seems to be very thoughtfully structured and well documented. I am going to use it for future projects for sure. The code I wrote is quite a mess and the result from tinkering around for three days. I am quite amazed that this tool works so smooth and performant despite the hacks I blessed it with. For example, when loading the application from the web then I always got a “d3 not defined” error b/c the code using d3.js was executed before d3 was loaded. I finally solved the issue by delaying the execution 3 seconds (other attempts failed). Mind that 60 JavaScript files are loaded keeping the data for the stock quotes and the dealings. Originally I planned to locate the data-files on pastebin.com (but pastebin was refusing due to current server workload – might do that if a lot of people start using this tool).
(original article published on www.joyofdata.de)