Tuesday, August 20, 2013

Rupee takes a plunge

Recently rupee rolled down against the dollar, with the dollar being valued at over Rs. 63. This devaluation comes at a prime time when I've started working and so it certainly is a boon. Though it's important to understand why this is happening, is it a big deal and what is the future going to look like.

The value of Dollar vs Rupee is a simple case of supply and demand. The rise of the Dollar's value against the rupee implies that people are converting Rupees into Dollars. This cash flow is happening for a number of reasons -
The US Federal Bank is probably going to cut down on it's quantitative easing. (Quantitative Easing, or QE, is a phenomena in which Fed buys central bonds and hence maintains their high price which keeps the rates low. This incentivizes people to invest their money elsewhere like in stocks or maybe buy a house or a car. This helps in revitalizing the economy) With the Fed suspected of cutting down on this venture, investors plan on flocking back to the US bonds as a safety haven and hence taking their money out of other countries.
The Indian economy also doesn't seem to be doing to well. It's account deficit (which is the net value of imports - exports) has ballooned to about 4.8% of GDP, i.e. $88.2 bn. The stock markets seem sluggish and there are impediments to FDI in different sectors. The economy grew at just 5% in 2012-13, the lowest in a decade. This is leading foreign investors to take their money out of India which is leading to a drop in the Rupee.

As a result, Indian bonds have become less attractive and hence the yields have risen. Foreigners have taken out $10bn since May 22 and the 10 yr bond yields have risen to 9.23%. This means that the central govt will pay interest @ 9.23% if it borrows from anyone. This rise in interest has also led to a rise in interest across the board with both savings and loan interest rates rising that will make getting a loan more expensive.

Now, on the other hand we have a strong 25 million Indian diaspora that is taking advantage of this rate and pumping their homeland with much needed foreign reserves. Volumes in the last few months have been 20-30% than that seen during regular months.
The Indian government also recently introduced certain fiscal changes that restricts foreign investment by Indian citizens and corporations and it also restricted imports of gold that led to a jump in the price of the bullion.

It seems clear that the solution is a higher growth to attract the Foreign Investors back. The Rupee will probably continue to slide to 64-65 and maybe to 67 but then certain sectors need to be opened to FDIs and exports should be energized so interest in the Indian growth story is back.

Until then.. NRIs - Cash Out!!

Sunday, April 28, 2013

I saw a Cop!

And he went zooming past, on the deserted roads in Richmond district, as if with some urgent sense of purpose. And I'm not surprised...

West Coast, Bay Area, SF - these terms always carried away my mind into a world of sunny beaches, beautiful hikes, outdoor sports, night camping and nature trails, all centered around a lively and thriving city. And with that mindset I always wanted to work here. And now, I am!

As the time neared, I was quite apprehensive about leaving NYC as I felt I had got used to it. Quite the same way, in striking contrast, as I felt about leaving Ithaca (upstate NY, for those of you who don't know)! It didn't sink in that I had actually moved until I landed, pulled my luggage from the conveyor belt, hoarded a shuttle and came at the hotel I'd booked. It all seemed perfect - a bright sunny sky, lots of stores and restaurants around and happy faces. I had done my homework and had booked the day to go look at a few listings where I would be establishing my abode for the foreseeable future. I start off from Taylor and Post where I had arranged some temporary accommodation and start walking south west.

As I came out of my hotel I was absorbed in the revelry around the place and didn't feel that I had left New York at all. I started walking admiring the people, the buildings, the shops, streets, but most importantly, the weather. My thoughts were suddenly disturbed by a fowl stench, and, as my neurons registered it, a familiar one, from the cigarette a guy was smoking on the streets. In an utmost expression of joy he shouted "Hey buddy. How are you doing today? Enjoy Life!" Yes... it was something else, camouflaged as a cigarette. And then I was pulled out of my thoughts and sensed the transition that had brought me into a different neighborhood. I was scared for a bit and thankfully I had the Sun watching my back. I notched up my pace and entered a pretty silent building. It seemed well kept and the manager showed me the apartment. The windows of the apartment opened out to face a blank wall, a completely white wall, and that was the only view from the place. Next.
The office manager cautioned about the region and advised that his building was right at the edge of a neighborhood called tenderloin that is known for its notoriety. The area on Jones St. between O'Farrel and McAllister is what he suggested to avoid. And that was when I began to understand how stark the boundaries between neighborhoods in SF are and how distinct their culture is.

The next few days...
The next day I spoke with my friends who had inhabited the area for a while and asked them about their recommendations for places to live. Most of them had settled down in the Bay area and had little knowledge about the neighborhoods in the city. I thought of then doing some research online to figure out the pros and cons of different areas and headed to a Starbucks close to where my office was going to be. It was closed. AND - it closes at 6 pm on weekdays. I was almost shattered and couldn't help feeling bottomed out and I missed the zillions of results that yelp spat out at "24x7 cafes" in NYC. "Nearby". I decided I needed some freshness and some change and I moved over to stay at my family's in  Hayward City.

The week turned out to be pretty interesting as I worked in the day and had fun with my little cousins at home. At the end of the week I found a place to live at Haight. My colleagues had a nice impression of the place with the different eating and hanging joints and that helped me feel positive. But I guess a difference in perspective was again not on my side. As I roamed about Haight trying to explore around I wasn't completely at ease in my mind. I had felt quite similar as I had come out of 16th St. at Mission on BART and it suddenly seemed quite clear. There was quite a visual element to the buildings. Almost all of them were really graphic with the most plain ones also having some graffiti. All these areas - Tenderloin, Haight, Mission St. had some extreme visual graphics on the building walls - hypnotic patterns, dark designs, distorted figures of human body, graphic visualization of "plant leaves", hippie color combinations, etc. To further enrich this appeal these areas were populated by a different breed of adventurers some sporting braided hear, tattoos all over face, pierced lips and eyebrows, heavy beard, half torn clothing, etc. Add on to the fact that many of them have a very stout built, in the first few days I used to feel mildly threatened with their presence. Even as a New Yorker (if I may call myself that) who has seen his share of unique aspects in people, the ratio of such a breed together with their high visibility and coupled with an extremely graphic setting of the visually rich images on buildings construes an uneasy threatening feeling, especially for someone new. Like me. I remember the first time I walked down on Market St. towards Van Ness and after the 4th-5th st. the neighborhood took a sudden transformation. I wasn't surprised as the maps indicated I was at the border of Tenderloin. There were small groups of loud and stout men lingering around, smoking stuff and having music play around. Another group of street kids, the kind who looked up to the former group of men, huddled together with a basketball taking turns on passing it around without any regard to passers by. Add to all this a kind of ghetto appeal that the area has with bright and dark colored walls painted with some abstract art form and with the stores showcasing distorted mannequins with separated limbs sporting respective body accessories. I have never set foot in that area again.
One day I saw a guy walking on the streets completely naked with just a piece of cloth hanging on one side. The other day I was walking on Haight with some take out Thai and after every 10 steps someone would ask "Do you need that food"? I either ignored or gave a rather imperceptible nod without even looking at them. Not all of them were mature, respectable people - one of the "street kids" stomped his skate board that made a loud noise and as my reflexes made me turn he yelled "so you CAN hear me. The next time I ask something, you reply!" I scampered my way back home and was really disappointed with the worst Thai I had tasted. I wish I had actually given it away!

So yeah... the next week I went to check out the Richmond district and it turned out to be quite a residential place with rows and rows of houses lined up. And there he was... a cop, rushing towards the city with a sense of urgency. And you know now why I wasn't surprised!

Monday, March 18, 2013

Gathering my own data

I have recently started refreshing my knowledge in Perl and have, in the process, re-realized the amazing scripting power of linux. There's a whole lot that can be done with file structure and file contents than what is remotely possible in Windows. Keeping that as a separate topic I'll first dive into using Perl to connect with data sources to download stock quotes and store them in a mysql database that can be used for further analysis.

Creating a MySql Database:
I found a very useful resource on the web to help understand MySql especially for those who have a faint memory from using it in the past: http://www.yolinux.com/TUTORIALS/LinuxTutorialMySQL.html
This tutorial gives a very elaborate overview on how to obtain MySQL and then how to create and modify user accounts and databases.
After getting acquainted with the basics this tutorial will help to create the actual database and provides the syntax on how to insert data using Perl into the just created database: http://scriptingmysql.wordpress.com/2011/08/05/inserting-data-into-mysql-with-perl/

Obtaining Stock Quotes:
I looked for many different alternatives to obtain stock quotes using Perl and I found the Finance::QuoteHist package to be quite relevant to this purpose - http://search.cpan.org/~msisk/Finance-QuoteHist-1.19/lib/Finance/QuoteHist.pm

Final Code snippet:
With all the above information I wrote the following code to obtain the ticker symbols from a local file and then fetch the stock quotes and store them into a local mysql database:


#!/usr/bin/perl

use Finance::QuoteHist;
use DBI;

# Obtain the ticker symbols from file
my $tic_file = '<path of file>/tics2.txt';
 open (fh, "< $tic_file"); #Note the syntax
 my @lines = <fh>;
 close(fh);
#my @tics = @lines[0..99];
#print $#lines, $#tics;

#print "@lines[1..100]";
$dbh = DBI->connect('dbi:mysql:PerlTest','root','<my password>') or die "Connection Error: $DBI::errstr\n";
$q = Finance::QuoteHist->new
     (
      symbols    => \@lines,
      start_date => '03/14/2013', # or '1 year ago', see Date::Manip
      end_date   => 'today',
     );

  # Quotes
  foreach $row ($q->quotes())
  {
    print "@$row \n";   #double quotes displays properly
    ($symbol, $date, $open, $high, $low, $close, $volume) = @$row;


    $sql = "insert into SampleQuotes (ticker, date, closing) values ('$symbol','$date','$open') ";
    $sth = $dbh->prepare($sql);
    $sth->execute() or die "SQL Error: $DBI::errstr\n";
  }

There is a whole lot that needs to be done in this script around Error Handling, vis-a-vis connection issues, duplication issues, missing data, etc and that is going to be the next topic.


Sunday, January 20, 2013

Let's be humans

I don't even know where to begin talking about the incident. They both were just regular people, like you and me, doing something completely regular, watching a movie, on a very regular day. Little did they know what the night held for them. Every moment from there on they, in fact I and the whole of India, would have wished for them to change any one decision they made - maybe a different day for the movie, a different theater, a different time - but sadly they didn't. As I try to recall even the description of their trauma in the media my brain fails to comprehend, even in its wildest of imaginations, the inhuman treatment that was vetted out to them. How could a human forego their entire value system and loose their senses to such an extent that, forget treating another human with respect and courtesy or even indifference, they not only get insensitive to the pain and suffering of another person but they actually participate in the barbaric act that causes such pain? Even as I write this I feel my body contracting as I imagine the excruciating pain she suffered. And what breaks my heart is to think that she isn't the only one. Not even the tip of the iceberg. Hers was the story that caught widespread attention and united the whole nation for a common cause but sadly her story mirrors the atrocities that many innocent girls face throughout the nation.

The incident happened on Dec 16th, New Delhi - the unsafest metropolitan in India. She was with her friend and they finished watching a late night movie. The scarcity of public buses and probably the harassment by Delhi autos, who would charge astronomical amounts to exploit the situation, prompted them to take one of the private buses to go back home. The bus had tinted windows and, as they recount, they were lured onto the bus. What ensued in the next two hours can not be imagined as a part of even the most horrible scene behind the reels. Six men, all intoxicated, illiterate, shameless and wicked with lewd minds indulged in the most abhorrent act, treating the girl worse than an object, an object you were about to throw. The driver of the bus paid no heed to the imploring cries of the girl as he sped past stipulated stops and circled some deserted stretches to avoid catching attention. The men, six in number, overpowered the guy, stripped him off his clothes and beat him, making him incapable to even move a muscle in an attempt to salvage the situation. Then they stripped the girl and used an iron rod to conduct such deplorable acts that no one can classify them as, not only humans but, any creature capable of showing any respect towards one of their own. It is beyond my comprehension that how one can be so involved in revelry at the cost of someone else's life that they lose the emotional connect and a sense of sympathy to the resisting shrieks and struggle of the another person. And after two hours of extracting all the life out of the girl they disposed her and her friend's body off on the road in the biting cold. To even find a metaphor to describe this act fills my brain with muck and any anger or hatred expressed towards this brutal act can never compensate for what those two people suffered. The girl was transported to a hospital in Singapore on grounds of treatment where she succumbed to her injuries. From the testimony of the guy, he wasn't even offered any treatment and he took his own care while being besides her friend and helping the authorities investigate and ensure justice.

I feel that there are three fronts on which we need to work to at least begin eradicating this evil act our off our society. Of course modifying our laws to ensure a strict and swift verdict for the accused is an important milestone but more importantly I think there is a huge obstacle in what transpires between the incident itself and the lodging and investigation of the complaint. In this particular case the victims cried for help from the roadside and no one was ready to help until the police arrived about half an hour later. Personally, it's hard to blame the passerby. Imagine yourself walking, riding or driving on a road stretch and finding a profusely bleeding naked person on the side crying for help in the darkness of the night! How likely would you be to stop and take them to the hospital? It's tough! Even after the police came, the victims were suffering in the biting cold pleading for clothes, the officers were concerned about the jurisdiction under which the case should fall. I strongly think that it's more important for the law to change to focus on advocating immediate and unconditional help to those in need. To support the "Right to Live" above all else and to avoid trapping the helper in such legal intricacies that they hesitate to make somebody's fatal problem as their own. At the time when her body was bleeding and her internal organs were dislocated, had she been administered medical help without any bureaucracy the results might have been different. But it is the fear of getting caught in the legal web as a witness trying to help a crime victim that withholds the common man from stepping forward and helping someone in dire need.

Another obstacle that would come in the way of reporting such crimes is the mentality of our society. How can we progress to uproot this crime when our spiritual and political leaders blame the victim and the lifestyle of those protesting. Even though they are individuals presenting their viewpoint, the fact that they represent thousands of people who follow their ideology reflects the mentality of a big section of our society. Chetan Bhagat writes very well about working towards an inclusive growth to address this vast disparity. Globalization is impacting some regions more rapidly than others and there is still a large section in India that forbids a boy and girl to roam together in their youth. Quite understandably so, a case in such a society would be suppressed to avoid the "stigma" associated with the victim. But even the typical middle class parents would be concerned of their standing in the community if, God forbid, such an incident about their daughter is revealed in public. As we progress and integrate ourselves with the rest of the world it is the duty of our leaders to oversee the cultural transition that is bound to increase the interaction of women with the society and grant them the freedom that was earlier repressed. Our legal and judicial systems need to respect and support such transitions and not point at the resulting lifestyle as the reason for such mishaps. This is a BIG change and apart from needing a strong law to avoid harassment due to lifestyle I think it needs cooperation within the educated section to talk about such incidents rather than shun them.

But, most importantly, I think we need to get into the root of the atrocious crime. We can have all the laws we want but no person, in their rightest of minds, will be able to, even remotely, justify the brutal act. It's inhuman. So why would somebody engage in it? I think the reason when a gang is involved is different from one when just a person is accused. In the case of one person statistics reveal that many a times it's someone close. But in the case of a gang it would be worthy to assess their history. In this particular case all six accused hailed from a slum, were illiterate and used to drink, abuse and create a chaos in their slums. In their intoxicated state they had lost their reasoning to such an extent that satisfying their innate desires was more important than anything in the world. ANYTHING. They were, probably, not in a position to comprehend the consequences of this act. And they are not alone. In this case I think education and employment might have helped bring stability and the discipline to avoid them from entering a state in which they are blinded of the repercussions of their own actions.
But is it possible for someone to be aware of the consequences and still indulge in this act? Yes, when they think they are beyond the reach of the legal system. There have been cases where the rich and powerful have exploited their position either with a direct intention or to uphold their ego when challenged. With the rampant corruption and the power exercised by the higher echelons of the society many such cases are subdued by hook or crook and the few that emerge create a large outcry. Easily said than done, of late there have been many movements against corruption in India and a lot of emphasis is laid on a completely independent and speedy judicial system. Though we have a long way to go I think that painting a sharper picture of the consequences and ensuring proper execution might help in curtailing even the thought that could lead to such an inhuman act.

May God give courage to her family and others like her's. I hope we just don't get resilient but pay her a tribute with some concrete actions.

Saturday, January 5, 2013

How much money do you need?

Very recently the United States government averted the Fiscal Cliff, allegedly the biggest catastrophe that would have drawn its economy back into a recession. Now, you may ask, how would that have happened?It's simple - Bush, during his tenure, had passed on a bill for a tax reduction that was going to expire on 31st Dec 2012 after which the taxes would have gone up. In parallel, the government had raised the debt ceiling in July 2011 that came with a clause to implement a series of discretionary spending cuts beginning 2013 if the Congress is unable to bring down the deficit, which it couldn't. When these two forces combine together it would have caused an increase in the tax rates and at the same time would have lowered government spending that would have threatened to stall economic growth even before it could begin.

In simple terms, the government needs money to function and implement it's policies. That capital comes from income which are largely composed of tax revenue. With the financial crisis and the multiple wars that the Congress had to battle its reserves have been drying up faster than they could have been replenished that led US to borrow consistently. The tax cuts have further reduced its income stream while the unaltered spending has kept its appetite at its peak. Now the debt ceiling is a self proclaimed limit imposed by the Congress on the amount they can borrow which can only be changed by a majority ruling. Although politically complex, economically if US borrows over it's ceiling then it is considered a technical default that can results in a chaos about which I'll talk in a while. To avoid the ensuing chaos and for the government to be able to carry out its activities the debt ceiling was raised in July 2011. Just as it was raised US was deemed a slightly incredible entity to lend money to by one of the rating agencies which is not really surprising since the move is just an artificial measure to increase its borrowing capacity. But what is also surprising is that there was demand for such debt because in the middle of the Euro Crisis it was still considered a safe haven and US sold about $240bn of debt in one day, the largest such sale ever. This also helped keen the interest rates to a very low level.

During 2012 US managed to stay under the modified debt ceiling even after the QE rounds by Fed and the interest rates remained extremely low. The intent was to stimulate the economy and bring it on the path of growth and as we see it did manage to provide the markets with one of the best years that they had seen. But the future of such growth now remains uncertain as with the mismanaged deficit US seems to be drawing close to a debt crisis that could threaten the financial powerhouse of the world.

As for the tax cuts, Bush had enacted the law in 2003 when no crisis was looming and then Obama had a choice of either extending them or letting them expire in Dec 2010. After careful deliberation and analysis it was computed that an increase in rates would lead to an annual increase of about $3000 in middle class income taxes. At the time when the middle class was already grappling with the after effects of the crisis it would certainly have been a challenge, more political than economic, to thrust the public with a larger tax bill. And now, two years later, the same situation looked at the Congress in the face again and this time with an added sword of fiscal deficit hanging on its neck.

As the tax increases are coupled with a fiscal deficit, this time the Congress heeded to Obama's proposal of letting the taxes stay low for the middle class while allowing the tax increase to go into affect for the rich. It indeed seems to help bring in much needed income over the next couple of years while still not taking away any disposable income from the middle class. But the Congress did not get to any agreement on the debt ceiling and it only has two months before it can take a decision on its limit. Now it can be debated whether the increase in taxes would serve the purpose it is meant to as some studies show that the rich were more inclined to pay taxes when the rates were lower than when they are up. But the markets still haven't digested the brunt of the news and are aware of the looming danger of the debt in the coming months. This has led to a drop in the prices of US bonds as investors express their fear in US debt.

I think that this can have an enormous impact on the economy. US debt has been blatantly increasing since the turn of the previous decade without any focus on increasing the revenue. A weak economy led it to ease the burden on the troubled households by lowering the taxes which it was forced to increase a few days ago.  The effects of such actions are not felt in a day or two but they pile up only to explode at some stage. How can the country which cannot pay its obligations assure me of my bank's obligations towards me in the form of deposits? Bank deposits are insured by FDIC and so it might lead to a bank run which would further threaten the entire financial system.

The US debt has been enjoying a stable position with high prices and high demands, especially because of $ being the reserve currency but it seems like that notion is in its reversal. I think that in the next couple of years US treasuries will drop in value and with economic growth yet to come the true value will only be seen in real assets. Gold and other commodities and growth in developing nations would probably be the next target on investors' radar. I think US has started to realize that it needs to tighten it's reign and we should see some contraction in its spending in the coming few months. It's hard to balance that with an ailing economy but it's even hard to lose the faith and trust of being a financial powerhouse.

It is debatable as to what would happen. It's not easy to lose faith in US. As China works to keep US bonds in its reserves and investors around the world don't find a safe asset to invest in, US would continue to enjoy the position of being a safe haven.


[Update]
An interesting read: http://www.bloomberg.com/news/2013-01-02/ten-things-you-should-know-about-the-cliff-deal-so-far-.html

Friday, December 28, 2012

Statistical Arbitrage!

With my experience in statistical analysis and after further gaining information on equity markets I was curious to explore the possibility of generating alpha by combining the two skills. I got an opportunity where I worked on a similar idea and then I extended it on the data I had downloaded from yahoo.
In this strategy I try to find a statistical equivalent of pairs trading and try to extract inefficiencies in price movements.

Abstract

The objective of this analysis is to obtain an alpha that is based on statistically exploring ineffi ciencies in stock prices. The strategy involves decomposing stock prices in each industry into principal components that explain the most variance and then regress the stock prices on those components to obtain the stock's  dependence on them. Next the components are forecasted using GARCH model and hence the forecasted evolution of the stocks is also obtained based on the regression results. Based on these forecasts I will create a long-short neutral arbitrage strategy with the aim of achieving high risk adjusted returns.

Statistical Arbitrage on US Equity
https://github.com/kunalrajani/statistical-arbitrage

Disclaimer: Please read
Please note that this is my independent work where I have used data from yahoo finance to explore statistical concepts from a course I took in statistics. It may inadvertently have an overlap with a work that somebody else has already done and I have no intentions of replicating it. I would be glad to know of any such clash and post a clarification on this post.
I am open to having my work being redistributed or used but only after due credit and a reference has been made. Feel free to contact me to avoid any misunderstandings or if you need more details from this paper. 

*The analysis is still underway and the conclusions are under review