Published on

November 24, 2023

Sentiment Analysis

Using AI to Trade on Elon Musk's Tweets

Explore how to use AI to get notified when Elon Musk tweets about any asset, understanding positive or negative sentiment.
Ekin Keserer
Co-Founder, Head of Design, Akkio
Sentiment Analysis

Analysts spend years trying to find reliable stock signals, largely unsuccessfully

What moves the markets? Do news headlines impact stock prices? How about WallStreetBets posts? What about earnings estimates, corporate site visits, The Federal Reserve’s policies, or macroeconomic variables? Innumerable research papers and countless hours are dedicated to finding what makes stock prices tick.

One factor that has reliably moved markets, time and time again, is Elon Musk’s Twitter account. When Elon tweeted “Gamestonk!!”, GME shares “rocketed as much as 157%.” Musk also “sent Dogecoin soaring 60% in minutes with a tweet.” After tweeting, “I kinda like Etsy,” ETSY stock jumped around 10%.

The problem for stock traders is that Elon is tweeting constantly. The vast majority of his tweets aren’t related to any asset, so unless you want to get inundated with innumerable, irrelevant notifications (to a stock trader), you need a way to only get notified with relevant tweets. You also need to know if it’s a positive or negative tweet. Will the tweet cause an asset to increase or decrease in value?

Let’s explore how to use AI to get notified when Elon Musk tweets about any asset, including understanding positive or negative sentiment. We’ll also look at an option to connect this to a trading account. These same principles could be applied to any personality (not just Elon Musk), or even any source of text data (not just Twitter).

Note that this article is not investment advice.

Creating a Zapier Flow

With Zapier, we can build this whole system effortlessly. First, we’ll create a “trigger” that gets activated when Elon Musk tweets. You can select any personality or business account you want, or even duplicate these steps for any number of accounts you’re interested in.

Every time Elon tweets, Zapier will automatically access that tweet, just by specifying his username. We can then set up the flow to run sentiment analysis with Akkio. I added an intermediate step that uses OpenAI’s GPT-3, a natural language model, to extract the specific asset mentioned, but you can go directly to sentiment analysis instead. 

Our example tweet mentioned Dogecoin, so my engineered GPT-3 prompt extracted “DOGE.” If no asset was found, it would return the word “none,” so we want to add a filter that stops the sequence if no asset was found.

This filter ensures that we’ll only do sentiment analysis on a tweet that mentions an asset.

I then created a Python snippet, below, to clean the tweet. We want to remove symbols like “@” or “#”, so we can run sentiment analysis on just the text.

We’re now ready to send the text off to a sentiment analysis model in Akkio. If you haven’t already, sign up for a free Akkio account. To activate Akkio in Zapier, visit this link.

When you log in to Akkio, you’ll see that there’s a “text classification demo,” which we can use to classify sentiment. You could also build your own sentiment analysis model on a dataset of just tweets to potentially improve accuracy.

We’ll click to deploy that demo model in Akkio, and then we can send a tweet via Zapier to get classified. Below, in Zapier, we select the “text classification demo” and add in our cleaned tweet text, and we’re done!

Akkio will now predict the sentiment of the tweet. To recap, we’ve now extracted any asset that was mentioned in an Elon Musk tweet, and predicted the sentiment of the associated tweet with Akkio. From here, the sky’s the limit. You could email or SMS yourself a notification, or even use this information to trade real money using Alpaca or Cryptowatch.

For now, let’s make Zapier send us an SMS with the tweet and sentiment prediction whenever Elon tweets about an asset.

Super easy! We now get an SMS with the mentioned asset and sentiment anytime Musk tweets about a financial asset. If you trust your model enough, you could even directly place an order in the stock market with a tool like Alpaca.

While Alpaca doesn’t support cryptocurrencies like Dogecoin, you could use an integration like Cryptowatch to place crypto orders. 

If you want to trade both traditional financial assets and cryptocurrencies, you could classify an asset as a “stock” or a “crypto asset,” and then create a “Path” in Zapier to either place an order in Alpaca or Cryptowatch, depending on which asset it is.

Scaling Up

Nowadays, tweet-based trading is easier than ever before, and you can use tools like Akkio to do it for you. That said, Elon Musk's tweets aren't the only potentially predictive sources of information out there.

In fact, some believe that sentiment analysis will be key to future success in trading. After all, it can provide an early warning system for changes in market conditions. For example, if you see that sentiment towards a particular stock is beginning to turn negative, you may want to sell before the price starts to drop.

Of course, scaling up sentiment analysis is no easy task. But if you can do it, you could have a real edge over other traders. So, if you're looking for an edge in the markets, keep an eye on sentiment analysis - it just might be the key to success.

At the same time, a scalable AI system would be needed to process the large number of tweets, news, and other data sources to accurately predict market changes. Akkio is designed for just this purpose, and can scale according to your needs.

For instance, suppose you were interested in sentiment analysis to support a thematic investing strategy focused on the marijuana industry. You could use Akkio to monitor a variety of sources for changes in sentiment around key topics like legalization, regulation, and public opinion. This would give you an early warning system for changes in the industry that could affect your investments.

The same principle can be applied to any industry or market you're interested in, from CRISPR to cryptocurrencies. Beyond Twitter, there are many other data sources that can provide valuable insights into market conditions. For example, you could monitor news headlines, corporate filings, meeting transcripts, analyst reports, and more.

But be careful not to put too much weight on any one source of data. Remember, the goal is to gain an edge on the competition, not to blindly follow the advice of some algorithm. The best traders always combine a variety of data sources, both quantitative and qualitative, to make informed decisions.

Further, be sure to consult with a financial advisor before making any decisions about investing. The world of trading is risky and complex, and even the most sophisticated AI systems can't always predict what will happen next.


If you want to invest like the pros, you need to make sure you’re getting the most accurate, up-to-date information possible. Zapier automation makes this effortless.

You could replicate these steps to follow every Fortune 500 CEO, and get notified about the sentiment of their tweets. You could also replicate these steps on a Google News RSS feed, or on Wall Street Journal headlines, or any other source of text. If you’re not interested in stock trading, the same principles apply to analyzing customer sentiment, or even posts about your competitors.

At Akkio, we’re focused on democratizing AI for everyone. By using Akkio, we’ve shown how you can trade on tweets and other news before it goes viral. Instead of manually monitoring countless sources of text, you can use this guide to analyze text in real-time.

By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.