All Projects → maxbbraun → Trump2cash

maxbbraun / Trump2cash

Licence: mit
A stock trading bot powered by Trump tweets

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to Trump2cash

Tradingview Webhook Bot
⚙️ Send TradingView alerts to Telegram, Discord, Slack, Twitter and/or Email.
Stars: ✭ 135 (-97.77%)
Mutual labels:  bot, trading, twitter
Awesome Twitter Bots
🌟Resource repo for Twitter Bots 🐦
Stars: ✭ 170 (-97.19%)
Mutual labels:  bot, twitter
Bitprophet
Node crypto trading platform for Binance exchange.
Stars: ✭ 166 (-97.26%)
Mutual labels:  bot, trading
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (-96.53%)
Mutual labels:  bot, trading
T 1000
⚡️ ⚡️ 𝘋𝘦𝘦𝘱 𝘙𝘓 𝘈𝘭𝘨𝘰𝘵𝘳𝘢𝘥𝘪𝘯𝘨 𝘸𝘪𝘵𝘩 𝘙𝘢𝘺 𝘈𝘗𝘐
Stars: ✭ 143 (-97.64%)
Mutual labels:  bot, trading
Socktrader
🚀 Websocket based trading bot for 💰cryptocurrencies 📈
Stars: ✭ 152 (-97.49%)
Mutual labels:  bot, trading
Binance Trader
Experimental trading bot for crypto currency on Binance.com
Stars: ✭ 218 (-96.4%)
Mutual labels:  bot, trading
Cryptotrader
A responsive dynamic webapp to trade cryptopairs on the most prominent exchanges
Stars: ✭ 118 (-98.05%)
Mutual labels:  bot, trading
Algotrading
Algorithmic trading framework for cryptocurrencies.
Stars: ✭ 249 (-95.89%)
Mutual labels:  bot, trading
moon-doge
Buy DogeCoin automatically when Elon Musk tweet about it, and sell after profit
Stars: ✭ 20 (-99.67%)
Mutual labels:  twitter, trading
Socialmanagertools Gui
🤖 👻 Desktop application for Instagram Bot, Twitter Bot and Facebook Bot
Stars: ✭ 293 (-95.16%)
Mutual labels:  bot, twitter
Arbitragebot
Arbitrage bot that currently works on bittrex & poloniex
Stars: ✭ 141 (-97.67%)
Mutual labels:  bot, trading
Downloadthisvideo
Twitter bot for easily downloading videos/GIFs off tweets
Stars: ✭ 530 (-91.25%)
Mutual labels:  bot, twitter
Mastodon Bot
a bot for mirroring Twitter/Tumblr accounts and RSS feeds on Mastodon
Stars: ✭ 158 (-97.39%)
Mutual labels:  bot, twitter
Cassandre Trading Bot
Cassandre makes it easy to create your Java crypto trading bot. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions.
Stars: ✭ 120 (-98.02%)
Mutual labels:  bot, trading
Tradingview Webhooks Bot
a bot that can execute trades based on tradingview webhook alerts!
Stars: ✭ 184 (-96.96%)
Mutual labels:  bot, trading
Twitterbot
Golang smart Twitter bot
Stars: ✭ 111 (-98.17%)
Mutual labels:  bot, twitter
Dankenstein
Markov Chain Twitter Bot generator
Stars: ✭ 117 (-98.07%)
Mutual labels:  bot, twitter
Twitter Bot Bootstrap
Twitter bot bootstrap 👢 using node and twit 🐦
Stars: ✭ 220 (-96.37%)
Mutual labels:  bot, twitter
Ccxt
A JavaScript / Python / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
Stars: ✭ 22,501 (+271.67%)
Mutual labels:  bot, trading

Trump2Cash

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.

Trump2Cash

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.

docker build -t trump2cash .
docker tag trump2cash gcr.io/<YOUR_GCP_PROJECT_NAME>/trump2cash
docker push gcr.io/<YOUR_GCP_PROJECT_NAME>/trump2cash:latest

2. Set up auth

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:

export TWITTER_CONSUMER_KEY="<YOUR_CONSUMER_KEY>"
export TWITTER_CONSUMER_SECRET="<YOUR_CONSUMER_SECRET>"

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:

export TWITTER_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export TWITTER_ACCESS_TOKEN_SECRET="<YOUR_ACCESS_TOKEN_SECRET>"

Google

Follow the Google Application Default Credentials instructions to create, download, and export a service account key.

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials-file.json"

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:

export TRADEKING_CONSUMER_KEY="<YOUR_CONSUMER_KEY>"
export TRADEKING_CONSUMER_SECRET="<YOUR_CONSUMER_SECRET>"
export TRADEKING_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export TRADEKING_ACCESS_TOKEN_SECRET="<YOUR_ACCESS_TOKEN_SECRET>"

Also export your TradeKing account number, which you'll find under My Accounts:

export TRADEKING_ACCOUNT_NUMBER="<YOUR_ACCOUNT_NUMBER>"

3. Install dependencies

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:

export POLYGON_API_KEY="<YOUR_POLYGON_API_KEY>"
python benchmark.py > benchmark.md

6. Start the bot

Enable real orders that use your money:

export USE_REAL_MONEY=YES

Have the code start running in the background with this command:

nohup python main.py &
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].