This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds.

Overview
Fully functioning Binance Trading bot that Buys cryptocurrency based on Daily news sentiment from the top 100 crypto feeds.

Main Features:
Pull and analyse the last headline from the top 100 crypto news sites

Provide an overview on the most mentioned coin across all the headlines

Analyse the sentiment of each headline and categorise the output by coin

Place a Buy order if the compound sentiment is positive

The bot sells %99.5 of the coins it bought in order to avoid exceptions

"coins_in_hand" dictionary stores the amount of coins the bot bought and currently holding.

Configurable options

Works with any number of cryptocurrencies

For a complete step-by-step setup guide please see: https://www.cryptomaton.org/2021/04/17/how-to-code-a-binance-crypto-trading-bot-that-trades-based-on-daily-news-sentiment/
Comments
  • No module named 'binance.websockets'

    No module named 'binance.websockets'

    Hi, first of all thank you very much for your work! I have tried to set up the bot, I installed everything and modified the settings in the console but I get this error when I try to run the bot:

    root@vultr:~/Binance-News-Sentiment-Bot# python3 -m news-analysis Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/root/Binance-News-Sentiment-Bot/news-analysis.py", line 34, in from binance.websockets import BinanceSocketManager ModuleNotFoundError: No module named 'binance.websockets'

    sWhat do you suggest I do? Thanks in advance

    opened by RSolterman88 7
  • 'NoneType' object has no attribute 'encode

    'NoneType' object has no attribute 'encode

    I know there is an error abt that but any solution? I'm using real keys, not test. preparing to buy 3.72 XRP with USDT at 1.34310000 'NoneType' object has no attribute 'encode' Sentiment not positive enough for BTC, or not enough headlines analysed or already bought: 0.0170875, 8 preparing to buy 0.00184 ETH with USDT at 2718.69000000 'NoneType' object has no attribute 'encode' Inserted the keys. have balance. Testnet set to false. python-binance library updated.

    opened by VadimS42 5
  • Error while placing order in Testnet

    Error while placing order in Testnet

    Press Ctrl-Q to stop the script
    Kraken Daily Market Report for April 25 2021
    OKEx Insights + Catallact : Bitcoin Market Witness the Growth of Retail Participation as Institutional Investors Continue to Lead
    Bitcoin Banned in Turkey | This Week in Crypto – Apr 26, 2021
    Mercurial on crypto: Will India’s latest stance lead to positive regulation?
    OneLedger Announces “Gem Hunt” Mining and Validator Competition
    AMA with Harsh Rajat and Richa Joshi (EPNS): Summary
    Blockchain Object Storage Company Filebase Raises $2M, Aims to Incorporate Filecoin and Arweave Networks
    Why Are Athletes Demanding To Be Paid In Bitcoin?
    Could not parse http://Bitcoinist.com/feed error is: unbound prefix: line 57, column 2
    Unmarshal's MARSH token lists on AscendEX
    A Glimpse Into The Future Of Bitcoin At $200,000
    Giant American Wine Seller Now Accepts Bitcoin, Dogecoin, and Ethereum
    Verifying your 2FA disable requests and other security tips from CEX.IO
    Embrace the Explosion of Colors in the Festive Hot Fiesta Slot
    Could not parse https://www.mycryptopedia.com/feed/ error is: mismatched tag: line 135, column 2
    Ampleforth.org Airdrop Review: The FORTH token has arrived
    Stellar Lumen (XLM) Price Primed For A Fresh Rally Above $0.45
    XRP Price Analysis: XRP Continues To Fall As Price is Stuck In Descending Channel
    Turkey’s Central Bank: Crypto Regulation Will Come In Two Weeks
    Dogecoin [DOGE] Struggles Near Support Despite An Uptick of 5%
    Solana Hits All-Time High Amid Market Calm
    Bit-flash.biz Review: PAYING or SCAM?
    Could not parse https://botsfolio.com/crypto_news/feed error is: 'NoneType' object has no attribute 'text'
    Nem szeretnek adót fizetni a multik – több milliárd dollár kötött ki adóparadicsomokban
    Satoshi Nakamoto Identity Case Takes a New Turn
    Could not parse http://bitcoinmxn.com/feed error is: 'NoneType' object has no attribute 'text'
    Crypto News Cast For April 25th 2021 ?
    XRP Ripple Returns – Long ETH and XRP
    OKEx Insights + Catallact : Bitcoin Market Witness the Growth of Retail Participation as Institutional Investors Continue to Lead
    Bitmain Teasing With the Upcoming AntMiner E9 Ethereum Miner
    Top 5 Peterborough United F.C. Forums, Discussions and Message Boards You Must Follow in 2021
    Neo Price Analysis: NEO Breaks Downtrend as Bulls Target $100
    Could not parse https://coinpress.io/feed/ error is: 'charmap' codec can't decode byte 0x9d in position 22517: character maps to <undefined>
    More Projects joining Polygon (MATIC) amidst rising Layer-2 adoption
    Apple, MicroStrategy and Microsoft Stock Tokens Are Coming To Binance
    Could not parse http://www.investorideas.com/rss/feeds/iimain.xml error is: time data 'Fri, 23 Apr 2021 14:10:00 EST' does not match format '%a, %d %b %Y %H:%M:%S %z'
    How to Buy Real Estate with Cryptocurrency?
    Traceback (most recent call last):
      File "D:/FinanceRepos/Binance-News-Sentiment-Bot/news-analysis.py", line 473, in <module>
        buy(compiled_sentiment, headlines_analysed)
      File "D:/FinanceRepos/Binance-News-Sentiment-Bot/news-analysis.py", line 368, in buy
        test_order = client.create_test_order(symbol=coin + PAIRING, side='BUY', type='MARKET',
      File "D:\Anaconda3\envs\pyt12\lib\site-packages\binance\client.py", line 1633, in create_test_order
    Time it took to parse feeds:  24.928550800000004
    
    BUY CHECKS:
    Sentiment not positive enough for XRP, or not enough headlines analysed or already bought: -0.125, 2
    preparing to buy 0.001876 BTC with USDT at 53294.93000000
        return self._post('order/test', True, data=params)
      File "D:\Anaconda3\envs\pyt12\lib\site-packages\binance\client.py", line 295, in _post
        return self._request_api('post', path, signed, version, **kwargs)
      File "D:\Anaconda3\envs\pyt12\lib\site-packages\binance\client.py", line 242, in _request_api
        return self._request(method, uri, signed, **kwargs)
      File "D:\Anaconda3\envs\pyt12\lib\site-packages\binance\client.py", line 220, in _request
        kwargs['data']['signature'] = self._generate_signature(kwargs['data'])
      File "D:\Anaconda3\envs\pyt12\lib\site-packages\binance\client.py", line 175, in _generate_signature
        m = hmac.new(self.API_SECRET.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)
    AttributeError: 'NoneType' object has no attribute 'encode'
    

    Got this error, i have the API keys as mentioned in the blog, can you tell me what might be the issue here?

    opened by AlphaNumeric99 4
  • vader_lexicon issue?

    vader_lexicon issue?


    Resource vader_lexicon not found. Please use the NLTK Downloader to obtain the resource:

    import nltk nltk.download('vader_lexicon')

    For more information see: https://www.nltk.org/data.html

    Attempted to load sentiment/vader_lexicon.zip/vader_lexicon/vader_lexicon.txt

    Searched in: - '/root/nltk_data' - '/usr/nltk_data' - '/usr/share/nltk_data' - '/usr/lib/nltk_data' - '/usr/share/nltk_data' - '/usr/local/share/nltk_data' - '/usr/lib/nltk_data' - '/usr/local/lib/nltk_data' - ''


    opened by Ozeitis 4
  • Saving and loading bought coins to file

    Saving and loading bought coins to file

    Saving them to file, so program doesn't 'forget' previous actions between restarts.

    I don't know if is it really needed feature, because my understandings of python code isn't that well, but maybe it might be helpful

    opened by Rybens92 4
  • Sell order

    Sell order

    • Sell function added.

    • The bot sells %99.5 of the coins it bought in order to avoid exceptions

    • "coins_in_hand" dictionary stores the amount of coins the bot bought and currently holding.

    • nltk.download('vader_lexicon') added

    • Selling on BCH/USDT pairing gives this exception for some reason (I can't tell why): BinanceAPIException: APIError(code=-1121): Invalid symbol.

    • When buying/selling this exception sometimes happens: BinanceAPIException: APIError(code=-1013): Filter failure: LOT_SIZE

    Feel free to change/copy anything you see fit.

    opened by koraycaglar 4
  • 'could not parse' error

    'could not parse' error

    an example would be: Could not parse https://www.coin.space/feed/ error is: this happened on google colab, and my own machine (ubuntu 18.04, python3.7.10). most of the news source it cannot parse at this moment, which is kinda worrying. thanks.

    opened by simin75simin 3
  • Exclude articles after defined time has past

    Exclude articles after defined time has past

    Here's how I implemented it: Add timezone to datetime import

    # define how old an article can be to be included
    # in hours
    HOURS_PAST = 24
    
    # convert pubDat to datetime
    published = datetime.strptime(pubDate.replace("GMT", "+0000"), '%a, %d %b %Y %H:%M:%S %z')
    # calculate timedelta
    time_between = datetime.now(timezone.utc) - published
    
    if (time_between.total_seconds() / (60 * 60) <= HOURS_PAST):
    

    Add ^ before the following... https://github.com/CyberPunkMetalHead/Binance-News-Sentiment-Bot/blob/56da3d171a77d2b6a574ba63cbae0887eaa3b2e8/news-analysis.py#L224-L230

    opened by adteague 3
  • Fixed many parsing errors that occurred due to small timeout, also some code beautifying

    Fixed many parsing errors that occurred due to small timeout, also some code beautifying

    In the commit:

    1. timeout was changed from 7 to 60. Problem was that many articles could not be fetched in this time (especially when you have mutlitasking, and I believe that the timeout is starting when the task is created and before the actual request is made // observation....I'm not a python ninja).
    2. find_lot_size method is redundant, so I actually removed it.
    3. some comment update.
    opened by idanpl 3
  • BCHUSDT Error for Binance API

    BCHUSDT Error for Binance API

    Looks like the Binance API is returning a Symbol error when trying to place a trade on BCHUSD via the testnet. If anyone has encountered this issue before and has a workaround, please let me know.

    opened by CyberPunkMetalHead 3
  • APIError(code=-2015): Invalid API-key, IP, or permissions for action.

    APIError(code=-2015): Invalid API-key, IP, or permissions for action.

    I know this one seems obvious but nothing I have done has worked... This is all on binance.us

    The bot works fine for testnet but when I switch to live I get this error (using small test values to see if it will execute at all):

    image

    I set 'testnet' to 'False and I have tried both setting the environment variables on windows to the api key/secret as well as copying and pasting it directly as a string like this:

    api_key_live = "randomapikeycharacters" api_secret_live = "randomapikeycharacters"

    I tried generating a new api key and switching some settings around but nothing seemed to work and don't know what else to try. Does anyone have live trades working on binance.us?

    opened by crus-glitch 2
  • No output

    No output

    Unlike other issues, I have run the script with nothing displayed so far in the Gitbash window. I tried including some print statements in-between functions just to know which functions are executed but nothing. Even the print statement below the if _name=='main' does not execute.

    Note: The only change I made to the original script are the environment variables plus importing the ThreadedWebSocketManager from binance i.e, from binance importThreadedWebsocketManager` Apart from that everything is the same

    The output is nothing image

    opened by ElectronicsDr 0
  • news export

    news export

    hello sir, thanks for share this excelent code, i may ask you how can i export the news from the scapper to a database for example or a csv, im trying to make it but i was not able to make it.

    opened by nipwd 0
  • RuntimeError('Event loop is closed') when starting article loop

    RuntimeError('Event loop is closed') when starting article loop

    It only happens on a few times then continues on normally

    Iteration 7
    Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001BC9655F9D0>
    Traceback (most recent call last):
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
        self.close()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
        self._loop.call_soon(self._call_connection_lost, None)
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
        self._check_closed()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
        raise RuntimeError('Event loop is closed')
    RuntimeError: Event loop is closed
    Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001BC9655F9D0>
    Traceback (most recent call last):
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
        self.close()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
        self._loop.call_soon(self._call_connection_lost, None)
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
        self._check_closed()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
        raise RuntimeError('Event loop is closed')
    RuntimeError: Event loop is closed
    Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001BC9655F9D0>
    Traceback (most recent call last):
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
        self.close()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
        self._loop.call_soon(self._call_connection_lost, None)
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
        self._check_closed()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
        raise RuntimeError('Event loop is closed')
    RuntimeError: Event loop is closed
    Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001BC9655F9D0>
    Traceback (most recent call last):
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
        self.close()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
        self._loop.call_soon(self._call_connection_lost, None)
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
        self._check_closed()
      File "C:\Users\Blake\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
        raise RuntimeError('Event loop is closed')
    RuntimeError: Event loop is closed
    

    image

    opened by crus-glitch 0
  • Could not parse ... messages

    Could not parse ... messages

    I am getting the following:

    Could not parse https://ethereumworldnews.com/feed/ error is: Server disconnected Could not parse http://infoonbitcoin.com/feed/ error is: Server disconnected Could not parse https://about.crunchbase.com/blog/feed/ error is: Cannot connect to host about.crunchbase.com:443 ssl:default [None] Could not parse https://vaultoro.com/feed/ error is: [Errno 32] Broken pipe Could not parse https://bitcoinspakistan.com/feed/ error is: [Errno 32] Broken pipe Could not parse https://blog.purse.io/feed error is: [Errno 32] Broken pipe Could not parse https://blog.feedspot.com/feed/ error is: Server disconnected Could not parse https://www.goldsilveranalyst.com/feed error is: Server disconnected Could not parse https://coinjournal.net/feed/ error is: [Errno 32] Broken pipe Could not parse https://www.crypnotic.com/blog/feed error is: [Errno 32] Broken pipe Could not parse https://coinpress.io/feed/ error is: [Errno 32] Broken pipe Could not parse https://www.crypto-news.net/feed/ error is: [Errno 32] Broken pipe Could not parse https://www.cryptostache.com/feed/ error is: [Errno 32] Broken pipe Could not parse https://decrypt.co/feed error is: [Errno 32] Broken pipe

    I can open the files using a browser, sounds like bad plumbing on their side.

    Also:

    Could not parse https://botsfolio.com/crypto_news/feed error is: 'NoneType' object has no attribute 'text'

    Could not parse http://www.investorideas.com/rss/feeds/iimain.xml error is: time data 'Fri, 23 Apr 2021 14:10:00 EST' does not match format '%a, %d %b %Y %H:%M:%S %z' Maybe support multiple date formats?

    opened by florisjan78 3
Owner
Andrei
Crypto enthusiast. Love nerding out on blockchain tech. I build and test crypto trading bots. Meme Savvy 69/10.
Andrei
Simple python crypto bot to trade crypto on Binance based on RSI. Utilizing web sockets to get real-time prices

Py Crypto Bot Using Binance WebSocket API to get real-time price data for cryptocurrencies. Using the TA-Lib library to calculate the RSI and execute

Kennedy Ngugi Mwaura 15 Jan 4, 2023
Freqtrade is a free and open source crypto trading bot written in Python

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning.

null 20.2k Jan 7, 2023
Bot to trade crypto trading ranges

crypto-trading-bot Crypto bot with DCA or GRID trading strategy Sends notifictions to telegram chat Crypto bot with webhook feature which can be used

null 3 Jun 18, 2021
A Trading strategy for the Freqtrade crypto bot.

Important Thing to notice 1) Do not use this strategy on live. It is still undergoing dry-run. 2) The Hyperopt is highly optimized towards "shitcoin"

null 160 Dec 26, 2022
Django-based Crypto Portfolio Tracker – keep an eye on Shiba Inu and other Crypto

Crypto Tracker ?? ?? – Central Portfolio Tracking Easy asset tracking – at a glance ?? Dashboard to centrally monitor current crypto portfolio develop

null 65 Jan 8, 2023
Technical_indicators_cryptos - Using technical indicators to find optimal trading strategies to deploy onto trading bot.

technical_indicators_cryptos Using technical indicators to find optimal trading strategies to deploy onto trading bot. In the Jup Notebook you wil

Van 4 Jul 3, 2022
Deribit_Algo_Project_Python - Deribit algo project written in python trading crypto futures

This is a Algo/script trading for Deribit. You need an account with deribit, to

null 24 Jan 9, 2023
A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided

A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided. If you’ve found this bot useful and have profited from it please consider donating any token to my BSC wallet address: 0xE75470B9a7c93038195ca116E342c42F6B3F758b

null 473 Dec 25, 2022
A bot that escrows crypto transactions on Reddit

EscrowBot I NEED BCH TESTNET FOR TESTING. Please send me some BCH testnet if you have some: bchtest:qz5eur3prqyvd8u77m6fzf9z6cruz9q7vq4qvgdnuk Depende

Nathan Lim 10 Nov 10, 2022
A crypto bot that checks the price movement in the markets and creates buy and sell signals

Booter bot Purpose The purpose of this bot is to check the price fluctuations in a given market in binance and create the idealistic signals based on

null 2 Oct 9, 2022
DCAStack: an Automated Dollar Cost Averaging Bot for Your Crypto

Welcome to DCA Stack! An Automated Dollar Cost Averaging Bot For Your Crypto Web

null 0 Sep 3, 2022
Signarly is a cryptocurrency trading bot.

Signarly is a cryptocurrency trading bot.

Zakaria EL Mesaoudi 5 Oct 6, 2022
Cryptocurrency trading bot with a graphical user interface with support for simulations, backtests, optimizations, and running live bots.

Cryptocurrency trading bot with a graphical user interface with support for simulations, backtests, optimizations, and running live bots.

Mihir Shrestha 834 Dec 30, 2022
Crypto-curriences analysis

Crypto_analysis Discription: simple streamlit(screener) app to make MMA and OSC analysis for cyrpto-currenices, and gives resaults for which coins are

null 13 Nov 1, 2021
📊Python implementation of the Colin Talks Crypto Bitcoin Bull Run Index (CBBI).

Colin Talks Crypto Bitcoin Bull Run Index (CBBI) This is a Python implementation of the Colin Talks Crypto Bitcoin Bull Run Index (CBBI). It makes use

Kamil Monicz 86 Jan 2, 2023
Encrypt your code without a worry. Stark utilizes the base64, hashlib and Crypto lib to encrypt your code which cannot be decrypted with any online tools.

Stark Encrypt your code without a worry. Stark utilizes the base64, hashlib and Crypto lib to encrypt your code which cannot be decrypted with any onl

cliphd 3 Sep 10, 2021
A web app to scan crypto markets based on candlestick pattern recognition from

Crypto_Scanner A web app to scan crypto markets based on candlestick pattern recognition from "Japanese Candlestick Charting Techniques: A Contemporar

Chris Qi 27 Jan 1, 2023
Using with Jupyter making live crypto currency action

Make-Live-Crypto-Currency-With-Python Using with Jupyter making live crypto currency action 1.Note: ?? You must Create a Binance account and also clic

Mahmut Can Gönül 5 Dec 13, 2021
XMRiGUI is free and open-source crypto miner for Linux. It uses XMRig for mining and GTK3 for GUI.

XMRiGUI is free and open-source crypto miner for Linux. It uses XMRig for mining and GTK3 for GUI.

null 29 Jul 7, 2022