Using 'Sentiment Analysis' To Understand Trump's Tweets

Apr 13, 2017
Originally published on April 13, 2017 5:10 am
Copyright 2017 NPR. To see more, visit http://www.npr.org/.

RACHEL MARTIN, HOST:

To Wall Street now where there is a shift afoot, a move to replace the humans who make investment decisions with computers. To understand this, our Planet Money podcast is building their very own stock-picking computer program. Reporter Alex Goldmark says the first step is choosing a strategy.

ALEX GOLDMARK, BYLINE: I needed to find something that moves stock prices, something a computer can recognize and react to. And you know what moves stock prices - at least sometimes? Tweets on Twitter, specifically the tweets of President Donald J. Trump. When he says something nice about a company, the stock price has tended to go up, and when he says something negative, the stock price has tended to go down - at least for a period of time. So here's my idea - I want to build a computer program that reads the president's tweets and then buys and sells stocks. Of course, as a radio reporter, I have no idea how to do this, so I found professional help.

MANI MAHJOURI: Yeah, this is definitely doable.

GOLDMARK: Mani Mahjouri heads investments at a hedge fund called Tradeworx. They do a bunch of things but among them, automated trading with computer programs. And he explained the essence of automated trading.

MAHJOURI: You know, if you take a simple idea and do it 3,000 times four times a year, it doesn't have to be right. That - it can be, like, just slightly right, you know, and over time, it's like a casino, except you're the house.

GOLDMARK: These simple ideas, these computer trading programs, they are known as bots, trading bots. And for our bot, the problem is, can the computer read Trump's tweets and figure out whether the president is saying something positive or negative?

MAHJOURI: This is more than just positive and negative words. This is a computer actually determining the sentiment of a tweet. You can type any sentence in, and it will give you a sense of what the sentiment is.

GOLDMARK: And this is just an algorithm you have lying around the office.

MAHJOURI: More or less.

GOLDMARK: This is something called sentiment analysis. Computers have gotten much, much better at it over the past few years. Companies use it to scour social media to see how people feel about movies, new products, whatever. It's so common now that it took almost no time at all for Mani and his team to run a little test.

MAHJOURI: So let's pull out the spreadsheet. We did 200, yeah?

GOLDMARK: They put hundreds of Donald Trump's tweets through this algorithm, this computer program they use to find the sentiment. And then, we humans, we took a look at what kind of decisions the computer had made. We checked its work.

Let me read to you some of Trump's tweets.

MAHJOURI: OK.

GOLDMARK: You followed...

So the computer read Trump's tweets, like this one from January. The tweet says, Toyota Motor said we'll build new plant in Baja, Mexico, to build Corolla cars for U.S. And then, in caps, no way. Build plant in U.S. or pay big border tax.

Go negative on that one.

MAHJOURI: Go negative on that one.

GOLDMARK: Humans say negative and computer says negative. We went through the list, and almost every time, the computer agreed with us humans. Sentiment analysis on Trump's tweets works.

MAHJOURI: Because he uses words like bad and sad and great, you know, and they always mean what he means them to mean, so from that perspective, he makes it really easy for computers.

GOLDMARK: So first problem - solved. The computer can label Trump's tweets positive and negative. With positive tweets about a company, we'll buy; negative tweets, we'll sell. But buy and sell what? Which company? Next problem is how will the computer recognize which company he's talking about? Building a trading bot is solving little puzzle after little puzzle like this, and the next one is way harder. Alex Goldmark, NPR News.

(SOUNDBITE OF THE FLASHBULB'S "ROSE HIERARCHY") Transcript provided by NPR, Copyright NPR.