Using Twitter Sentiment for Market Decisions

Using Twitter Sentiment for Market Decisions

This is a repost from TradeTheSentiment.com

In October 2014, I successfully defended my dissertation titled “Analysis of Twitter Messages for Sentiment and Insight for use in Stock Market Decision Making.” This dissertation was the final step in earning more D.Sc. in Information Systems.

In my dissertation, I reported on my research into using natural language processing (NLP) to perform sentiment analysis on Twitter messages. This sentiment is then analyzed to determine if this sentiment can be used for stock market investing decisions using the idea of the Bear/Bull ratio which is a quantitative measure of sentiment from Twitter. The research conducted for my dissertation is the baseline for the services on this website.

You can view a video of my dissertation defense below (or click over to Vimeo to watch it there).  Additionally, I’ve created a PDF version of my dissertation and I’ve listed it for sale on my Trade The Sentiment website  for $50 per copy. You can purchase this dissertation and read up on some of the research that is the basis of this site by buying a copy for yourself. on this site. When you purchase a copy, you’ll have access to download a PDF version of my dissertation. To purchase a copy for yourself, you can click here and use Paypal or Stripe to buy a copy.

Note: If you are an academic research or doctoral student, please contact me directly and I’ll share a copy of my dissertation for free.

Using Twitter Sentiment in the Stock Market from Eric D Brown on Vimeo.

Introducing the New Trade The Sentiment – From Theory to Product

Originally posted on TradetheSentiment.com

Today, I launched the new version of Trade The Sentiment.

Rather than just following along on my blog with static charts, you can now access all the signal information you want / need with the new interactive service on the website.

On the new site, I have a few free charts available for users to review. These charts will always be freely accessible without the need to signup or login to the site.  My hope is that you’ll find these freely available charts valuable and want to join the site to access the many thousands of symbols being tracked and reported on. To access these additional symbols and charts, you’ll need to signup for an account. You’ll receive access to the paid side of the website for 30 days for free…after those 30 days, you’ll need to sign up for a ‘paid’ account, which is currently $75 per month for a short introductory time.

Check out the site. Sign up for an account and dig into the services I’m offering….and please do let me know any feedback you may have.

I’ll be sharing more about the new features of the coming days here on the blog. While you are waiting, feel free to read bout the features and check out the site for yourself.

For now, here’s a sneak peak of the new charts and what the service has to offer.

Lastly – if you do check out the new site and have any issue or have any questions, please contact me and I’ll be happy to help you out.

chart

 

 

Using Twitter Sentiment for Intraday Signals

This is a cross-post from Trade The Sentiment. Originally published as Using Twitter Sentiment for Intraday Signals.

While most of my research on Twitter Sentiment has been for use on larger time-frames (Daily, Weekly, etc), I’ve been very curious about using sentiment for intraday signals.

I finally found some time to hack together a script that would look at sentiment data intraday…and now i’m a bit unhappy that I did…because I’m fascinated with the intraday signals I’m seeing.

An Example

On Feb 25, we saw a nice little sell-off. The S&P500 gapped up to open the day and sold off for the remainder of the day for a loss of almost 38 points on the $SPX.

The following day, Feb 26, saw another move down until about mid-day when the markets ‘turned’ and started heading up…and we saw a retrace of about 40 points over the next three days.

Everyone seemed to be looking for a breakdown on Feb 25 and Feb 26 but it didn’t happen.

As luck would have it, over the weekend I had built my script to look at intraday sentiment.  It was a quick hack (like most of my stuff) that allowed me to run a quick query to see what sentiment looks like at time “now”.     On Feb 25, I was occasionally calling out the the intraday sentiment values in @gtotoy’s trading room over at DayTraderBootCamp (you should join if you aren’t a member…some GREAT traders there).

As the day wore on, I was noticing the sentiment was getting much more bearish…to the extent that it was in ‘bearish extreme’ levels by a large margin. At one point, the sentiment for the day was around 1.5 or so (1.0 is neutral, anything over 1.25 is considered a bearish extreme).

Twitter users were extremely bearish on the market on Feb 25 and the morning of Feb 26.  On Feb 26th at 9:30 Central and again at 11:30 Central, there were 2 large bearish sentiment spikes…those times marked the same times that we saw the bottom in the market on that day (looking at at 15 minute chart).

At the time, I didn’t have the sentiment loaded up into a platform to view it against price action…but I’ve since fixed that.

Take a look at the following….a chart showing a 15 minute candle chart of SPY Action (in green), Intraday Sentiment sampled in 15 minute increments (in Orange) and the 21 period EMA of the Intraday Sentiment (in Magenta).

You’ll notice that the sentiment chart is fairly noisy…but the 21 EMA is much cleaner and provides a couple nice ‘signals’ over the last few weeks. On the 21 EMA chart (bottom pane), you’ll see a Red oval that highlights a Sell signal with Bullish Extreme on Feb 19  and a Green oval that highlights a Buy Signal on Feb 25 / 26th with Bearish Extreme readings).

Note:  a few days of data don’t make something useful.  It could be pure happenstance that the below signals did what they did…but I’ll  be looking at more historical data to see what I can find.

Click image for larger version

k5vAoWU

Comparing Sentiment Extreme Entries with Random Entries – Multiple Symbols

This is a cross-post from Trade The Sentiment

In my post titled Correlations – Twitter Sentiment, AAII Sentiment Survey and the S&P 500 Index I mentioned the following:

Using my training data set and the Python Natural Language Toolkit’s Naive Bayesian Classification methods and performing statistical correlations using the Pearson Correlation method, there is virtually no correlation between the overall market Daily Twitter sentiment and the Daily closing price of the SPX.

While there isn’t any correlation between daily/weekly SPX closing prices and the overall Twitter market sentiment (using my analysis methods), there are some interesting signals coming out of this research into twitter sentiment.

The most interesting signal so far has been that of an “extreme” in sentiment.    I’ve been running quite a lot of analysis using Twitter Sentiment Extremes as signals for entries and have been quite impressed with using Twitter Sentiment Extremes as entry signals.

I’ve shared a number of these analyses over the last few months. A few examples can be found in the following posts:

For the purposes of understanding how accurate these signals are, I setup the following test to compare Twitter Sentiment Extreme Signals vs Random Entries.  I’ve run a portion of this test before in the Comparing Twitter Sentiment vs Random Numbers for Entry Signals post but I wanted take it a step further and test multiple symbols and compare Twitter Signals with Random Entries.

The strategy

Rather than just use one or two symbols, I wanted to take a look at how these Extreme signals would work across multiple symbols and markets.  In addition, I have used the full market sentiment signal rather than the individual symbol sentiment signal in order to test the market sentiment signal in general.

I used the following symbols:


Using Tradestation as my test platform, I ran through each symbol using Twitter Sentiment Data.  The strategy details are:

  • Date Range: Nov 1 2011 to Dec 31 2012.
  • Strategy is Long only
  • Use overall Market Sentiment
  • Extreme is defined as a Bear / Bull Ratio of 1.1 or higher
  • For futures, use 5 contracts. For Stocks/ETF’s, buy 500 shares
  • Buy at open following day after an extreme is found
  • Hold position for 6 days
  • Commission and Slippage are included
  • Returns are calculated on $300,000 account

Results of Twitter Sentiment Signals


As you can see, the returns found while trading futures are quite impressive with returns a factor of 10 higher than trading the ETF’s or the majority of the S&P 10 symbols (other than AAPL).

Testing Random Signals

Next, I wanted to take a look at this same strategy and symbols using random entry signals.  In order to get a good sampling of data, I created ten random signals using a random number generator and input these signals into Tradestation and ran the same strategy as above.

The results of the ten random entry signals averaged together:

Comparing Results

A quick glance of the Futures results shows a dramatic difference between the Twitter Signals and Random Entries.


As you can see, in general, the Twitter sentiment signal provides a pretty good indicator.  The average return from Twitter sentiment is higher than the average return on random signal entries.   In addition, the media return is higher for twitter sentiment for futures and ETF’s but not for the S&P 10 symbols.

When compared with the return of the S&P500 Index from Nov 1 2011 to Dec 31 2012 of 8.58% (found using Tradestation’s “Buy and Hold Return” performance statistic), the Twitter Sentiment signals provide an excellent market entry signal with excellent returns when used in the Futures markets.  The returns found with ETF’s are surprising, but if we increase the number of shares purchases, returns increase a good deal (e.g., with SPY @ 500 shares, return 2.91% and with 1000 shares, return = 5.41%).

To improve performance, a lot of work can be done on risk management and exit criteria, which would most likely improve performance, but the purpose of this particular test was to compare random signals vs twitter sentiment…and I think the results speak for themselves: There seems to be a definite edge to be found in using Twitter Sentiment Extreme signals for entry signals.

This is a cross-post from Trade The Sentiment

Correlations – Twitter Sentiment, AAII Sentiment Survey and the S&P 500 Index

This is a cross-post from Trade The Sentiment

I just finished presenting a paper titled Bulls, Bears…and Birds? Studying the Correlation between Twitter Sentiment and the S&P 500 Index at the Business Intelligence Congress 3 in Orlando Florida.  Once the paper is formally published, I’ll share a link to the PDF.  Oh….and the paper won best Research paper at the conference 🙂

A quote from the abstract of the paper:

This research had three main goals: 1.) To determine if data analytics can be used to automate sentiment analysis from Twitter messages; 2.) To determine whether the outcome of the analytical engine is comparable to existing survey methods and finally; 3.) To determine if there is any actionable knowledge contained within Twitter sentiment that can be used to make investing decisions.

Each of the above goals was accomplished. Twitter data can be collected and analyzed using standard sentiment analysis methods. Additionally, using Bayesian Classification techniques combined with a manually generated training data set, resulted in an outcome which is correlated to existing sentiment survey methods (e.g., the AAII Sentiment Survey). Lastly, using standard statistical methods, there is very little statistical correlation between the Twitter Sentiment found within this study’s sentiment analysis methods and the closing price of S&P 500 Index.

Using my training data set and the Python Natural Language Toolkit’s Naive Bayesian Classification methods and performing statistical correlations using the Pearson Correlation method, there is virtually no correlation between the overall market Daily Twitter sentiment and the Daily closing price of the SPX.

Using Pearson Correlation methods is a standard method of determining whether a linear relationship exists between between two sets of data. The correlation values range from +1 to -1 with a value of +1 meaning that there is a perfect linear correlation between the two data sets and a value of -1 meaning that there is a perfect inverse linear relationship between the two data sets. A value of 0 means there is no correlation between the two data sets.  Note: looking for a linear relationship between sentiment and SPX Close price might be naive here, but its the simplest relationship to begin with.

A Scatterplot of Daily Twitter Sentiment Data and Daily SPX Close prices shows virtually no linear relationship exists.

Bears-BullsBirds.pptx-Microsoft-PowerPoint-non-commercial-use_2012-12-15_11-29-00

Correlation Details of the Daily Bear/Bull Ration and SPX Close:

Bulls, Bears and Birds - Final-name.docx - Microsoft Word non-commercial use_2012-12-15_11-09-57

Additionally, there is virtually no correlation between the AAII Sentiment Survey and the SPX Weekly Closing Price nor is there any correlation between the Weekly Twitter Sentiment and the SPX Weekly Closing price.

Bulls, Bears and Birds - Final-name.docx - Microsoft Word non-commercial use_2012-12-15_11-12-51

There is, however, a fairly strong correlation between Twitter Sentiment on a Weekly Basis and the Weekly Sentiment Survey released by the American Association of Individual Investors (AAII) with a Pearson Correlation value of 0.583 being found.

Correlation Details of the AAII Weekly Sentiment Survey and Weekly Twitter Bear/Bull Ratio:

Bulls, Bears and Birds - Final-name.docx - Microsoft Word non-commercial use_2012-12-15_11-13-11

The conclusion?

Using my training dataset and my implementation of the Naive Bayesian classifier, there is no significant correlation between Twitter Sentiment and SPX Close Price on a Daily or Weekly Basis.  That said, there is a High Correlation between Weekly Twitter Sentiment and the AAII Sentiment Weekly Survey.

Does this lack of correlation mean that Twitter Sentiment (or AAII Sentiment) is useless?

I don’t think so.  In fact, I believe it is very important data.

I’ve written about the use of Sentiment Extremes as a buy/sell signal in the past and I see some real value in these signals. There a number of academic and industry articles describing the use of sentiment and sentiment extremes as contrarian signals. In fact, the AAII has even published an article that discusses the use of sentiment as a contrarian signal.

I’ve been focusing most of my efforts on identifying sentiment extremes and using those values as inputs into investing strategies.  These entry signals appear to be providing exceptional returns with little drawdown when using proper risk management methods.

Additionally, these entry signals from extremes seem to be a better entry method than just taking a random entry as described in my post that compares a Bearish Extreme signal compared to entries taken with a random signal. In that article, it appears that additional returns found using Bearish Extremes from Twitter as an entry signal when compared to entering on a random entry signal.

In fact, using the overall sentiment from Twitter and using extreme levels as an entry signal has delivered pretty good returns over the past year…better than I even initially expect.

How good are the results?  Check back in a few days for a report. 🙂

This is a cross-post from Trade The Sentiment

Comparing Twitter Sentiment vs Random Numbers for Entry Signals

This is a cross-post from Trade The Sentiment

One of the concerns that I have of my research into using Twitter Sentiment for entry signals in the market has been that the market has, in general, been in an up-trend over the last year.   With that up-trend, there’s a good change that any entry, made enough times over the course of the year, would have resulted in a profitable trading year.

So…I developed a basic random number generation script in Python that generates a random signal between 0 and 2 to try to mimic the ranges found in the overall market bear/bull sentiment.

With this random signal, I then used the same strategy for an entry signal used in my Twitter Sentiment entries.   The comparisons are below

Trading Rules

  • Enter when Bearish Extreme found in Raw Bear/Bull when Sentiment (or Random Signal) > 1.1
  • Buy 500 Shares of the SPY ETF. This strategy is Long Only.
  • Hold for 6 trading Days.
  • Timeframe: Nov 1 2011 to Nov 30 2012
  • Commission = $10
  • Slippage = $0.05 per share

Using Tradestation, I ran my strategy with both the Twitter Sentiment Signal and the Random Signal without optimizing any of the strategy inputs.  Both systems closed out their last trade before Friday so no trades are held.

The outcome of both systems are provided below.  Below the table, I’ve provided the

Note: The Buy and Hold Rate of Returns are different due to the date of the first trade made by each system. Trade #1 for Random Signals was taken on Nov 9 2011 while Trade #1 for the Twitter Sentiment was taken on Nov 14 2011.

Based on this particular test, I’d say the twitter sentiment entry signals are much more robust and accurate. This signal delivers more profit, more return and much less drawdown than the random signals entries.

Each strategy’s entry / exits are shown in the graphs below.

Twitter Sentiment Signals

Random Signals Entries

This is a cross-post from Trade The Sentiment