This Machine Turns Trump Tweets into Planned Parenthood Donations

And it’s open source so you can help make it better

Artist’s impression

Like many who call the United States their home, I have been worried and confused by the start to Donald Trump’s presidency. It’s hard to know how to react to the misdirected anger, the blatant racism, and the “alternative facts”, which are increasingly threatening our civil liberties and our planet. It’s important that we take to the streets and fight back. Seeing that happen does give me hope.

Personally, I have a very particular set of skills, skills that allow me to have some fun with Mr. Trump’s emotional incontinence and maybe effect positive change along the way.

Our new President really likes to use Twitter. He uses it to express strong opinions about all sorts of things. Occasionally, those opinions are targeted at publicly traded companies. You see where this is going.

Take this recent outburst of his, directed at Toyota. Their stock price abruptly dropped right after Trump’s tweet.

Mr. Trump’s nuanced fiscal policy proposal. Sad!
Toyota’s NYSE:TM stock price on January 5th 2017

He does this a lot, a dozen times this January alone, and it’s not always negative. There’s also praise for companies who publicly act on his threats — or have it appear like they did.

He totally did this. Win!
Ford’s NYSE:F stock price on January 4th 2017 (Rio Grande for scale)

So here’s the idea:

What if you wrote some code that constantly monitors Trump’s feed and analyzes each tweet for mentions of publicly traded companies? Then, you’d immediately trade the affected stocks based on the detected sentiment: buy if positive and short if negative. The whole thing could be 100% automated.

I just finished writing a bot which does exactly that. For your convenience, it also tweets out a summary as @Trump2Cash each time it springs into action.

The bot knows that ABC is owned by Disney, hence the DIS ticker symbol

But does it actually work? Let’s look at the numbers.

Check out the benchmark report. It’s essentially a test run that shows you how the algorithm performs on past tweets and market data. You’ll see that it sometimes misses a company or gets a sentiment wrong, but it also gets it right a lot. The trading strategy sometimes leaves you up and sometimes down.

Overall, the algorithm seems to succeed more often than not: The simulated fund has an annualized return of about 59% since inception. There are limits to the simulation and the underlying data, so take it all with a grain of salt.

The results of running a simulated fund with a $100,000 initial investment

Think you can make it perform better? Fork the code on GitHub! There are a bunch of obvious things to improve and there’s a lot of room for creative ideas. I started collecting a list of them here.

I had fun building this. In fact, I started coding while on a plane to Europe and had the first version working by the time we touched down. (Shout-out to Cloud Platform!) But don’t bet your life savings on it. Markets are unpredictable. Trump is unpredictable.

As for my own fund, I’m donating the profits in equal parts to the American Civil Liberties Union, the Natural Resources Defense Council, and Planned Parenthood. (They always take your donations, even if the money wasn’t earned by a robot.)