Trading bot that uses Elon Musk`s tweets to know when to buy cryptocurrency.

Overview

Elonbot

Trading bot that uses Elon Musk`s tweets to know when to buy cryptocurrency. Here is how it works:

  1. Subscribes to someone's (elonmusk?) tweets
  2. Automatically detects mentions of DOGE or other crypto in the image(or text) Elon's tweet
  3. Buys crypto on Binance
  4. Sells it after --auto-sell-delay seconds

Installation

git clone http://github.com/vslaykovsky/elonbot
pip install python-binance google-cloud-vision unidecode

Running

  1. Set up Twitter access keys.
    • Go to developer.twitter.com to create your developer account
    • Generate a bearer token
    • Set up an environment variable with the bearer token.
      • Linux: export TWITTER_BEARER_TOKEN="<YOUR BEARER TOKEN>"
      • Windows: set TWITTER_BEARER_TOKEN="<YOUR BEARER TOKEN>"
  2. Set up Binance access keys.
    • Go to Binance and create a trader account if you don't have it yet
    • Go to API management page and copy your API key and secret
    • Export both keys:
      • Linux: export BINANCE_KEY="<your API key>"; export BINANCE_SECRET="<your secret key>"
      • Windows: set BINANCE_KEY="<your API key>" & export BINANCE_SECRET="<your secret key>"
  3. [Optional] Add image text recognition support with Google OCR
    • Use the following documentation to access Google Vision API
    • Export path to your google vision configuration.
      • Linux export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/google_vision_credentials.json"
      • Windows set GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\your\google_vision_credentials.json"
  4. Run elonbot.py

Here are some examples of how to run Elonbot. All examples are provided for Linux. For Windows make sure you use correct escaping

With image text recognition:

python elonbot.py --user=elonmusk --margin-type=cross_margin  --crypto-rules='{"doge": "DOGE", "btc|bitcoin": "BTC"}' --auto-sell-delay=600  --order-size=max  --use-image-signal

No image text recognition

python elonbot.py --user=elonmusk --margin-type=cross_margin  --crypto-rules='{"doge": "DOGE", "btc|bitcoin": "BTC"}' --auto-sell-delay=600 --order-size=max

Dry run (only prints debug output, no orders are executed)

python elonbot.py --user=elonmusk --margin-type=cross_margin  --crypto-rules='{"doge": "DOGE", "btc|bitcoin": "BTC"}'  --auto-sell-delay=60 --order-size=max --dry-run

Get help:

(base) C:\Users\vslay\Desktop\notebooks\elon>python elonbot.py --help
usage: elonbot.py [-h] --user USER --crypto-rules CRYPTO_RULES --margin-type MARGIN_TYPE [--auto-buy-delay AUTO_BUY_DELAY] [--auto-sell-delay AUTO_SELL_DELAY] [--asset ASSET] [--use-image-signal]
                  [--order-size ORDER_SIZE] [--dry-run] [--process-tweet PROCESS_TWEET]

Trade cryptocurrency at Binance using Twitter signal

optional arguments:
  -h, --help            show this help message and exit
  --user USER           Twitter user to follow. Example: elonmusk
  --crypto-rules CRYPTO_RULES
                        JSON dictionary, where keys are regular expression patterns, values are corresponding cryptocurrency tickers. elonbot.py uses regular expressions to find tweets that mention
                        cryptocurrency,then buys corresponding crypto ticker
  --margin-type MARGIN_TYPE
                        isolated_margin or cross_margin. These are two margin types supported by Binance. Read this article to understand the difference:
                        https://www.binance.com/en/blog/421499824684900602/Binance-Margin-Differences-Between-the-New-Isolated-Margin-Mode-and-Cross-Margin-Mode. You must transfer your assets to isolated
                        margin or cross-margin to use this script
  --auto-buy-delay AUTO_BUY_DELAY
                        Buy after auto-buy-delay seconds
  --auto-sell-delay AUTO_SELL_DELAY
                        Sell after auto-sell-delay seconds
  --asset ASSET         asset to use to buy cryptocurrency. This is your "base" cryptocurrency used to store your deposit. Reasonable options are: USDT, BUSD, USDC. You must convert your deposit to one
                        of these currencies in order to use the script
  --use-image-signal    Extract text from attached twitter images using Google OCR. Requires correct value of GOOGLE_APPLICATION_CREDENTIALS environment variable.Check
                        https://github.com/vslaykovsky/elonbot for more details
  --order-size ORDER_SIZE
                        Size of orders to execute. 1.0 means 100% of the deposit; 0.5 - 50% of the deposit; 2.0 - 200% of the deposit (marginal trade)"max" - maximum borrowable amount. max corresponds to
                        3x deposit for cross-margin account and up to 5x for isolated-margin account
  --dry-run             Don't execute orders, only show debug output
  --process-tweet PROCESS_TWEET
                        Don't subscribe to Twitter feed, only process a single tweet provided as a json string (useful for testing). Example value: '{"data": {"text": "Dodge coin is not what we need"},
                        "includes": {"media": [{"url": "..."}]}}'
Comments
  • "Use image signal" is always True

    I'm using these arguments and I'm not using the --use-image-signal argument

    python elonbot.py --user=elonmusk --margin-type=cross_margin --crypto-rules="{""doge"": ""DOGE""}" --auto-buy-delay 1 --auto-sell-delay=60 --order-size=max --dry-run --asset USDT --process-tweet "{""data"": {""text"": ""Dodge coin is not what we need""}}"
    

    But I still get Use image signal: True

    2021-05-21 05:07:51.516164   User: elonmusk
    2021-05-21 05:07:51.517163   Crypto rules: {'doge': 'DOGE'}
    2021-05-21 05:07:51.517163   self.asset: USDT
    2021-05-21 05:07:51.517163   Auto buy time: 1.0
    2021-05-21 05:07:51.518160   Auto sell time: 60.0
    2021-05-21 05:07:51.519158   Use image signal: True
    2021-05-21 05:07:51.519158   Margin type: MarginType.CROSS_MARGIN
    2021-05-21 05:07:51.519158   Order size: max
    2021-05-21 05:07:51.520155 Tweet received
     {
        "data": {
            "text": "Dodge coin is not what we need"
        }
    }
    

    When I keep "includes": {"media": [{"url": "..."}]} in the process-tweet I get an error because my GOOGLE_APPLICATION_CREDENTIALS is not set correctly, but I don't want to use it.

    opened by Tim-Be 1
  • Speed of the script & APIs

    Speed of the script & APIs

    Hi @vslaykovsky 
    first of all thanks a lot for your work.
    Yesterday Elon tweeted again and I successfully did an isolated margin trade!
    
    However it was not quick enough. A lot of other people do exactly the same.
    So I missed the entry just by a few seconds and could only make 4 dollars from a 5k trade :D
    
    Any thoughts on how to make it quicker? 
    I have already commented out the buy delay. 
    Is there maybe another api out there where you can receive push notifications when Elon tweets?
    I guess deploying the app to a server closer to twitter/binance could also be an idea.
    
    P.s. No financial advise :-)
    

    Originally posted by @hurich in https://github.com/vslaykovsky/elonbot/issues/1#issuecomment-848184092

    I was wondering if anyone has a comment on this? Has someone found a new way to optimize the delay?

    opened by NiklavsD 1
  • How can I hire you to make a modification to webhooks instead of binance

    How can I hire you to make a modification to webhooks instead of binance

    I would like to hire you to implement this code for me for personal but instead of trading on binance, i want to send a webhook for trades on a different platform with higher margin. Bybit allows 25X margin would make this much better. To signal a trade on bybit, I use "alertatron" which uses webhooks and in the textbody it contains the buy/sell/stop orders code. We also have to make sure this is as instantaneous as possible when elon tweets! [email protected]

    opened by craig9309 1
  • Meme detection

    Meme detection

    Hi there,

    An amazing project! But maybe we can add something extra. If we add image classification you will never miss a doge mentioned tweet. Let me know if you got time for it.

    opened by casaltenburg 0
  • Connection broken: InvalidChunkLength

    Connection broken: InvalidChunkLength

    Hi, I have exactly the same error. Did you manage to find a solution?

    2021-05-21 13:56:23.574745 Subscribing to twitter updates. HTTP status: 200
    2021-05-21 14:01:24.313016 ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read)) restarting socket
    2021-05-21 14:02:24.637563 Subscribing to twitter updates. HTTP status: 200
    2021-05-21 14:07:25.379304 ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read)) restarting socket
    2021-05-21 14:08:25.709596 Subscribing to twitter updates. HTTP status: 200
    2021-05-21 14:13:26.454248 ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read)) restarting socket
    2021-05-21 14:14:26.800770 Subscribing to twitter updates. HTTP status: 200
    

    Any Idea what might cause these errors? I get these every few minutes and it takes exactly one minute to be up and running again.

    Originally posted by @Tim-Be in https://github.com/vslaykovsky/elonbot/issues/1#issuecomment-845944993

    opened by dlisiakiewicz 1
Owner
null
Cryptocurrency Trading Bot - A trading bot to automate cryptocurrency trading strategies using Python, equipped with a basic GUI

Cryptocurrency Trading Bot - A trading bot to automate cryptocurrency trading strategies using Python, equipped with a basic GUI. Used REST and WebSocket API to connect to two of the most popular crypto exchanges in the world.

Francis 8 Sep 15, 2022
Utilizing the freqtrade high-frequency cryptocurrency trading framework to build and optimize trading strategies. The bot runs nonstop on a Rasberry Pi.

Freqtrade Strategy Repository Please test all scripts and dry run them before using them in live mode Contact me on discord if you have any questions!

Michael Fourie 90 Jan 1, 2023
Crypto-trading-simulator - Cryptocurrency trading simulator using Python, Streamlit

Crypto Trading Simulator Run streamlit run main.py Dependency Python 3 streamli

Brad 12 Jul 2, 2022
Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy. Sell buyed token with custom gas fee, slippage, amount. And more.

Pancakeswap Sniper bot Full version of Pancakeswap sniping bot used to snipe during fair coin launches. With advanced options and a graphical user int

Jesus Crypto 204 Apr 27, 2022
Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy

Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy. Sell buyed token with custom gas fee, slippage, amount. And more.

Jesus Crypto 206 May 1, 2022
This program is an automated trading bot that uses TDAmeritrades Thinkorswim trading platform's scanners and alerts system.

Python Trading Bot w/ Thinkorswim Description This program is an automated trading bot that uses TDAmeritrades Thinkorswim trading platform's scanners

Trey Thomas 201 Jan 3, 2023
Elon Muschioso is a Telegram bot that you can use to manage your computer from the phone.

elon Elon Muschioso is a Telegram bot that you can use to manage your computer from the phone. what does it do? Elon Muschio makes a connection from y

null 4 Feb 28, 2022
Andrei 1.4k Dec 24, 2022
This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. If you like this project please consider donating via brave. Thanks.

This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. The bot f

Andrei 157 Dec 15, 2022
Trading bot - A Trading bot With Python

Trading_bot Trading bot intended for 1) Tracking current prices of tokens 2) Set

Tymur Kotkov 29 Dec 1, 2022
A simple Discord Bot that uses the free CryptoCompare API to display cryptocurrency prices

What is this? This is a simple Discord Bot coded in Python that uses the free CryptoCompare API to display cryptocurrency prices Download Use git to c

Kevin 10 Apr 17, 2022
(@Tablada32BOT is my bot in twitter) This is a simple bot, its main and only function is to reply to tweets where they mention their bot with their @

Remember If you are going to host your twitter bot on a page where they can read your code, I recommend that you create an .env file and put your twit

null 3 Jun 4, 2021
Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering

Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering

Alexandr Savinov 326 Jan 3, 2023
Lumi-Bot - Discord bot that fetches cryptocurrency prices utilizing CoinGeko API

Lumi-Bot Discord bot that fetches and monitors cryptocurrency prices utilizing C

Diego Castro 2 Oct 8, 2022
Defi PancakeSwap bot is programmed in Python to buy and sell tokens in seconds once the target is hit.

Defi PancakeSwap BOT A BOT that will make easy your life in Trading. Watch tutorial on Youtube Table of Contents About The Project Built With Getting

Zain Ullah 208 Jan 5, 2023
Best Buy purchase bot

B3 Best-Buy-Bot. Written in Python NOTICE: Don't be a disgrace to society. Don't use this for any mass buying/reselling purposes. About B3 is a bot th

Dogey11 8 Aug 15, 2022
Best Buy Bot used to add products to cart for purchase.

To Install the Best Buy Bot These instructions are for Mac users only. Clone this Repo to your machine. BestBuyBot Open in VScode. Is Python installed

Robert Estrella 1 Dec 11, 2021
Pancakeswap Sniper Bot GUI Uniswap Matic 2022 (WINDOWS LINUX MAC) AUTO BUY TOKEN ON LAUNCH AFTER ADD LIQUIDITY

Pancakeswap Sniper Bot GUI Uniswap Matic 2022 (WINDOWS LINUX MAC) ⭐️ AUTO BUY TOKEN ON LAUNCH AFTER ADD LIQUIDITY ⭐️ ⭐️ First GUI SNIPER BOT for WINDO

Crypto Trader 1 Jan 5, 2022