Aug 11, 2011

Plotting Cumulative FII & DII Inflow against Nifty spot index

Now that I have the FII and DII Inflow along with Nifty Index, I tried my hands on charting!

The objective is to plot the Cumulative FII, DII and Net Inflow and Nifty Index for current year (2011) on a single graph. This post takes inspiration from Deepak Shenoy's post, wherein he has plotted some nice graphs.

The approach is to read the file created earlier for FII & DII Stats, convert the object as zoo (package used is quantmod), filter the data to contain only current years figure values, and then calculate cumulative sum using cumsum() fuction.

The extra effort done here is the use of right axis to display Nifty Index values using axis() function.

The graph contains 4 lines on the same plot, with the legends. If you observe, there is a high co-relation between Nifty spot and Net FII inflow. 68% is what the following line tell. Does this mean our markets trends are dictated by FIIs?


Cumulative Institutional inflow in 2011

Aug 4, 2011

FII and DII turnover with effect on Nifty Downloader

My thirst for statistics has been increasing. IV had another requirement, which would eventually be useful to me as well. He currently downloads FII and DII buy and sell values and its impact on Nifty manually in Excel. He suggested me to try and automate this process in R. Wow! Some more learning of R, which would eventually help me in building my strategies!

Unlike in NSE EOD Bhavcopy and BSE EOD Bhavcopy downloaders, I tried a different approach to download FII + DII stats from NSEIndia website (as if I had a choice), along with the index Nifty values and change over previous day. The National Stock Exchange of India has different structures for different pages. To download index values, you have to refer to the link whereas for FII and DII stats, you need to visit

Both of these pages are HTML forms, you have to enter parameters like index name, start and end dates. Another challenge is that each of these pages displays a maximum of 100 rows in table and if you need all rows (more than 100), you have to download a csv (dynamically generated in temp location). I faced problem in accessing the csv, as for older dates, the link generated was not valid. Hence, I decided to read the page itself, parse the table to be consumed as data frame. For instances, where the parameters generate more than 100 rows, I decided to use while loop.

OK, now here is the solution for it.