There is already an algorithm that measures mood, actually, that was created by developers at Google, called the Google-Profile of Mood States (GPOMS).
The Indiana study attempted to farm 9.7 million tweets posted over ten months in 2008 by 2.7 million twitter users, measured them using the GPOMS and a few other computer science methods, and checked the closing movement of the Dow Jones industrial average for each day.