maxbbraun/trump2cash — 6.5k★ on GitHub (Python). A stock trading bot powered by Trump tweets
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This bot watches Donald Trump's tweets
and waits for him to mention any publicly traded companies. When he does, it
uses sentiment analysis to determine whether his opinions are positive or
negative toward those companies. The bot then automatically executes trades on
the relevant stocks according to the expected market reaction. It also tweets
out a summary of its findings in real time at
@Trump2Cash.
You can read more about the background story here.
The code is written in Python and is meant to run on a
Google Compute Engine instance. It uses the
Twitter Streaming APIs to get
notified whenever Trump tweets. The entity detection and sentiment analysis is
done using Google's
Cloud Natural Language API and the
Wikidata Query Service provides the company data.
The TradeKing API does the stock trading.
The main module defines a callback where incoming tweets are
handled and starts streaming Trump's feed:
def twitter_callback(tweet):
companies = analysis.find_companies(tweet)
if companies:
trading.make_trades(companies)
twitter.tweet(companies, tweet)
if __name__ == '__main__':
twitter.start_streaming(twitter_callback)
The core algorithms are implemented in the analysis and
trading modules. The former finds mentions of companies in the
text of the tweet, figures out what their ticker symbol is, and assigns a
sentiment score to them. The latter chooses a trading strategy, which is either
buy now and sell at close or sell short now and buy to cover at close. The
twitter module deals with streaming and tweeting out the
summary.
Follow these steps to run the code yourself:
1. Create VM instance
Check out the quickstart
to create a Cloud Platform project and a Linux VM instance with Compute Engine,
then SSH into it for the steps below. Pick a predefined
machine type matching
your preferred price and performance.
Container
Alternatively, you can use the Dockerfile to build a
Docker container and
run it on Compute Engine
or other platforms.
The authentication keys for the different APIs are read from shell environment
variables. Each service has different steps to obtain them.
Twitter
Log in to your Twitter account and
create a new application. Under the Keys
and Access Tokens tab for your app you'll find
the Consumer Key and Consumer Secret. Export both to environment variables:
If you want the tweets to come from the same account that owns the application,
simply use the Access Token and Access Token Secret on the same page. If
you want to tweet from a different account, follow the
steps to obtain an access token. Then
export both to environment variables:
You also need to enable the Cloud Natural Language API
for your Google Cloud Platform project.
TradeKing
Log in to your TradeKing account and
create a new application.
Behind the Details button for
your application you'll find
the Consumer Key, Consumer Secret, OAuth (Access) Token, and Oauth (Access)
Token Secret. Export them all to environment variables:
There are a few library dependencies, which you can install using
pip:
pip install -r requirements.txt
4. Run the tests
Verify that everything is working as intended by running the tests with
pytest using this
command:
export USE_REAL_MONEY=NO && pytest *.py -vv
5. Run the benchmark
The benchmark report shows how the current implementation of the
analysis and trading algorithms would have performed against historical data.
You can run it again to benchmark any changes you may have made. You'll need a Polygon account:
How does maxbbraun/trump2cash compare to other Automation projects?
maxbbraun/trump2cash is tracked by TopGit in the Automation category, with 6.5k GitHub stars and written in Python. Browse the Automation topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does maxbbraun/trump2cash have?
maxbbraun/trump2cash has 6.5k GitHub stars — refresh the page for the live number, or check github.com/maxbbraun/trump2cash. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is maxbbraun/trump2cash open source?
Yes — maxbbraun/trump2cash ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/maxbbraun/trump2cash.
What else is in the Automation space?
maxbbraun/trump2cash is tracked by TopGit under the Automation category, alongside 4 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is maxbbraun/trump2cash?
maxbbraun/trump2cash (maxbbraun/trump2cash) is a Python project on GitHub. From the project's own README: A stock trading bot powered by Trump tweets
Where can I see maxbbraun/trump2cash in action?
The project maintains a homepage at https://trump2cash.biz. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about maxbbraun/trump2cash?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/maxbbraun/trump2cash is the definitive source.
Read full README in the tab above.
Is trump2cash worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of trump2cash.