Correlation between INR values of different currencies

Correlation between INR values of different currencies 2012-09-05 11:31 data clojure

This is an interesting take away example from the class which Anand is teaching at NIAS. Here we are trying to correlate between the INR values of various currencies like AUD, CNY (Chinese Yen), EUR, GBP (Great Britain Pound), JPY, SGD, USD and find the positive or negative correlations. The focus is on data collection and transformation.

The first part is the identification of a proper source to get the data. oanda.com is one such source from which historic currency exchange rates can be obtained.

The next part is the development of an automated/easy way of obtaining the data from the site, suitable for transformation. With some help from develpment tools in the browser the url of the download link can be found. It looks something like

<script src="https://gist.github.com/3638650.js?file=data2_url.sh"></script>
<br/>
Here we can find that SGD is the currency that is being used, with
little exprimentation it can be found that we can download data
for other currencies by altering this URL (example - replace SGD
with JPY for downloading data for Japanese yen)

The next is the transformation part, the downloaded csv files contains data that are not required for further analysis that should be filtered to get the required data. In this case we have to filter the first 5 lines, that is done by using tail -n +6, which prints starting from the 6th line and we have to also filter the last 4 lines and this is done by using head -n -4, which prints all lines but the last 4 lines.

We also combine the data and make a single csv file containing data of all currencies for easy consumption, this can be done using

paste AUD.csv CNY.csv EUR.csv GBP.csv JPY.csv SGD.csv USD.csv |sed ’s/\t/,/g’>alldata.csv

The complete code for the steps so far

The next step is the visualization, The choice of tools for visualization is left open, I prefer clojure with incanter. Here is the clojure snippet

load the data
plot it

Here is how it looks -
data2_currency_correlation_notnormalized

It can be found that it is difficult to compare data on different scales, normalization helps us in this case (data-mean/mean)
Here is a function to normalize data

and the plot is updated to show the normalized data

Here is how it looks
data2_currency_correlation_normalized

the complete code

No comment