Crypto Trading Bot — Sentiment Analysis Bot with TextBlob and Python

Introduction to Sentiment Analysis with Python

Sentiment Analysis is an application of Machine Learning where a piece of text is analyzed using a computer model to determine the ‘sentiment’ behind the tweet, such as Positive or Negative about a particular topic.

Python is a great language to perform this type of analysis given any source of writing due to the Natural Language Processing abilities and libraries and packages developed specifically for Sentiment Analysis.

Due to the immense amount of social media available, there is a tremendous opportunity to be able to understand sentiment about a given topic in real time.

The capabilities of sentiment analysis will be used to create buy and sell signals for a crypto trading bot, which will anticipate price movement by current sentiment of top ‘influencer’ twitter traders, compared with historic averages.

Crypto — Bitcoin Sentiment Analysis on Twitter with Python Introductory Video

In celebration of the new International Crypto Research Group discord chat, I will be creating a new Youtube series based upon a sentiment analysis bot, and in particular, attempt to emulate a certain trading strategy based upon sentiment analysis and price.

Twitter posts will be used as the source of content upon which sentimental analysis will be performed, with historic values tracked and compared to inform trading strategy.

The initial bot will be limited to Twitter, however, ultimately extended websites and news sources will be used such as Reddit, Discord channels, and telegram chats.

The ultimate goal is a development of a trading bot (written in Python) which is capable of real-world actions such as buying and selling cryptocurrency with algorithmicly on a crypto exchange and perform profitably over time, while constantly updating and analyzing with Sentiment Analysis.

Regarding the technical instructions for this installation of this bot, I will followed the tutorial available here: Sentiment Analysis with Python.

Sentiment Analysis Crypto Twitter Trading Strategy — “Barbie Bot”

Twitter is a great place for conversations around cryptocurrency due to the large amount of “crypto twitter” accounts, news and opinion generated by ‘thought-leaders’ and influencers of this genre. One of the best sources of information and insight into cryptocurrency is a trader with the handle twitter.com/BARBIEBUYSDIPS.

In June 2018, Barbie Buys Dips described a trading strategy that I feel would be excellent to mimic and codify through a python program. With that end in mind, the Sentiment Analysis toolset will be applied to the strategy described by Barbie Buys Dips to determine trading buy/sell signals.

The ‘Bitcoin Barbie Bot’ Crypto Trading Bot is an attempt to codify the crypto trading strategy described by @BarbieBuysDips ✨in this tweet:

Essentially, the strategy described by @BarbieBuysDips ✨ describes how to stay away from Pump & Dump schemes, while profiting from their predictable behavior. Additionally, the pump & dump schemes don’t necessarily require an organized ‘insider cabal’ to organize such behavior, as the market will generally experience these rational exuberance entirely without an organizing central party.

By analyzing the sentiment and coordinating with price action, a new strategy will be explored.

I thought this strategy would be great to implement using Sentiment Analysis because it will give an algorithmic methodology for profiting off of a predictable behavior discovered by a highly experienced cryptocurrency trader.

We will code a python script which will monitor tweets mentioning a certain crypto currency (such as bitcoin, or ethereum), perform sentiment analysis to determine perspective of recent tweets on the coin, and perform trade actions if certain price targets are reached based on 1 day or 1 hour time schedules and historical values. Link to Python Code on Github.

Further research will be limiting posts from Influencer & High-follower count accounts to determine changes in sentiment, as well as determining the sentiment of the source much of cryptotwitter has begun to follow carefully.

The Description, Strategy & Functionality Sentiment Analysis/BBB bot

The bot will perform a number of ‘basic’ actions, and will be implemented on a python script.

  • Monitor, collect and save tweets mentioning Cryptocurrency in file format. Potential uses of this
  • Perform Sentiment Analysis on a historic data set, and recent tweets during a specified time period (1 hour, 5 minutes, 1 day). Track and record historical values in file format. Visualize data through python script.
  • Trade structure attempting to mimic this strategy:
  1. If Sentiment positive (‘buy’) and green candle (‘higher price’), wait to purchase coins.
  2. If candle decreases 2% (or more) in specified time period (5 minutes, 1 hour, 1 day), Purchase quantity of coin.
  3. Sell when price increases 5% (adjustable).

To Reiterate, the functionality of of a bot to implement this strategy is based on a python script that will:

  • Monitor all tweets mentioning X-Coin, perform sentiment analysis to determine buy/sell signalling from crypto-accounts
  • Track Historical Values in CSV spreadsheet format
  • Compare current/recent values to historic values
  • Tweet out ‘Alerts’ based on strategy, and perform successful trades on Binance

Results of Sentiment Analysis

Sentiment Values for Bitcoin
Number of Tweets Analyzed: 200
Positive tweets percentage: 35.44 %
Negative tweets percentage: 16.45 %
Neutral tweets percentage: 48.10 %

Sentiment Analysis over 12 hours June 30, 2018

The above graphs demonstrate the sentiment analysis bot over varying time periods, from 10 minutes to 12 hours. A ‘baseline’ value will have to be established in order to determine if sentiment is particularly positive, negative or neutral.

Max, Average, Min for Sentiment Analysis on Crypto Twitter

Average Sentiment Values During the Above Time Period:

  • Positive: 37.30%
  • Negative: 12.10%
  • Neutral: 50.50%

These values were surprising to me because I expected a higher value for both Positive and Negative, but the twitter chat is mostly Neutral around the subject of Bitcoin. Also there are times when Neutral reaches 75% of all tweets being sent.

Maximum Sentiment Values During Above Time Period

  • Positive: 60.27%
  • Negative: 27.91%
  • Neutral: 74.50%

Minimum Sentiment Values During Above Time Period

  • Positive: 14.63%
  • Negative: 2.25%
  • Neutral: 32.46%

Future Research on Sentiment Analysis/BBB Strategy Bot

Future Research is to live-code the development of the strategy in Python, improve documentation and strategic thinking behind project, and implement bot functionality on Binance Exchange to determine results of Sentiment Analysis and BBB strategy.

--

--

Blockchain Engineer - Crypto Trading Bots

@BlockchainEng on Twitter. Crypto Trading Bots Programmer. Blockchain Engineer. Crypto Investor - Trader. ICO Advisor. realestateblockchain1@gmail.com