Nov 23, 2011

Volume by Price Charts using R

R-Bloggers is a wonderful site which offers some great ideas for analysis.

While I have been busy of late, hence could not do much with R, I was inspired by this post by Eric Nguyen on Volume by Price chart. 

This chart can be used with a great effect in ones trading strategies. It helps in identifying the support and resistance zones, and a breakout from these levels used as entry/exit points

Extending the work done by Eric, and making few changes in his original code, here is what I have achieved.

Reliance EOD Volume by Price chart


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?

cor(as.numeric(z$Close),as.numeric(z$cumFIINetValue))

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 http://www.nseindia.com/content/indices/ind_histvalues.htm whereas for FII and DII stats, you need to visit http://www.nseindia.com/content/equities/eq_fiidii_archives.htm.

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.

Jul 24, 2011

BSE Bhavcopy with Delivery Quantity

One of my TI forum members IV had a requirement for BSE Quotes along with Delivery Quantity. This made me implement "merge" function of R (thanks to the great work done by people behind various packages and guidance available on R Mailing lists).

The task involves downloading files from two separate links and merging it on the basis of Symbol on any given date.


The output is a single file for one trading day. With a slight tweak in the code, single file can be generated for a week, a month, a year , or from beginning to end. If anyone is interested, let me know, and will offer the solution for the same

Without much write-up here is the code for the same.

For those, who want to take a shortcut, here are historical quotes

Jul 19, 2011

Extracting EOD Data from BSE

Earlier, I had worked around to download Bhavcopy from NSE. Now, I would make a similar attempt to download the BSE Bhavcopy

Objective: Download Bhavcopy (Equity) from http://www.bseindia.com and save only relevant columns Date, Symbol, Name, Open, High, Low, Close, Last and Volume.

[Fixed] Extracting EOD Data from NSE

My prime interest being the Indian financial markets, the first step would be to get the data to play around. NSE India provides EOD of data as bhavcopies. The same are stored as zipped files at their servers. Downloading them one by one for a larger time frame will be very tedious, hence I will attempt to automate the process.

There is a great tool for statistical computing called R. It is open-source with a lot of development being done across various packages. This interests me a lot because of it simplicity and power. I would make my attempt of automating bhavcopy downloads using this software. If you want to try the same, you can visit the downloads section of R-Project and get the latest version


Objective: Download Bhavcopy (Equity) from http://www.nseindia.com and save only relevant columns Date, Symbol, Open, High, Low, Close, Last and Volume.

To download the Bhavcopy (Equity) from http://www.bseindia.com refer to this post.

Jun 27, 2011

The Beginning of Learning Technical Analysis

Googling for financial lessons throws up thousands of website, few excellent, while the others doing self promotion or trying to sell their system or tips.

As I learn the trading techniques, I would like to share in this blog, along with my observations, keep re-visiting them over time and try to improve upon the techniques and strategies.

Of course, for analysis, and playing around with data, I would be requiring a tool. I have been fascinated by R-Project, being open source, and a lot of development and resources available on the net. I might support it with Excel/Google Spreadsheet. Let see, how my learning goes. My current skill set in R-Project is beginner, and with practical implementations, I would like to enhance it.

If there are any visitors, other than me, would request them to provide suggestions and criticize my approaches.


Thanks
Gaurav

Jan 31, 2011

FIIs in India Geographic Distribution

The Geographic spread of FIIs in India is depicted in the map below

Exploration and drilling the map to the lowest level (office address location) is possible.

Go ahead and explore!!





 

Details are available in spreadsheet below:

30-July-2013: The google spreadsheet linked to the data has got removed due to google upgrades. Will get this resolved soon.

Data Source: SEBI, 31-March-2011
Map Created using BatchGeo and Google Maps