Track live sentiment for stocks from Reddit and Twitter and identify growing stocks

Overview

Market Sentiment

About

This repository can mainly be used for two things.

a. Tracking the live sentiment of stocks from Reddit and Twitter

b. Tracking the number of mentions for particular tickers in Reddit and Twitter

config.py

Add the tickers and stock information about the companies that you want to track. This is for live sentiment and not for tracking the number of mentions

dev_server.py

If you want to run the program (live tracker for sentiment) in your local machine, run via this

live_sentiment.py

This is program that creates the live sentiment charts. I had envisioned creating a realtime sentiment tracker so as to help me in trading. The hypothesis was by the time news is news, its already too late to sell/buy a stock. Wanted to gain an edge using this. Its still WIP. Please run the twitter and reddit stream atleast for half a day before triggering this code to get meaningful results. The dash part of the code is modified version of Sendex code from here. I have kept some parts that is not needed for the code since removing it causes the graph to crash. Not an expert in dash. You can improve upon this code the most.

Graph created from the program

reddit_stream.py

This is used to stream posts and comments from reddit in real-time. If your only aim is to identify growing stocks, you dont need to stream the data. You have lots of other ways around this. Streaming comments from reddit is not required as both pushshift and praw api gives historical data but since I am already streaming data from tweepy in my VM and using it for my live graph, I thought this was the best way to go. feel free to change this. Also WSB overpowers the rest of the subreddit in terms of comment volume. Feel free to play around with different subreddits which gives you the best results.

twitter_stream.py

Tweepy (Twitter API) does not allow free access to tweets more than 7 days old. Even if the tweets are within 7 days, there is a cap of 500K tweets per month for historical analysis. The program easily pulls around 100-150K tweets per day. So it's better to stream the tweets unless you have the premium version of the API. Read up on the rate limits and its impact before trying to stream the data. Also please note Tweepy will time you out for years if you keep hitting their server after you get a error. Its exponential and you can read up about experiences of other developers facing this same issue.

Ticker_count

This is my quick and dirty version of counting the number of mentions of a ticker from the data that we stored. You have to run this code by specifying the time frame in which you want the analysis to be done. I have separated both the twitter and reddit counts have been separated as lots of people wanted the information to be separated in my subreddit. Feel free to combine them into one program. Do this for two-three months and you will have a good dataset to see how the mentions rise and fall based on the hype. Currently, I am running the code everyday at a fixed time and adding it to my excel tracker. If you have a better method, please feel free to suggest!

QC and final thoughts

Obviously, just getting the number of mentions and their increase is just the first step. Two things that I am not sharing in the public repo is my own proprietary vadersentiment model (for finance related terms) and bot/spam detection. Please take a random sample and check whether the interest is genuine or whether the stocks are being pushed by bots (check for repeated mentions, very high comment/tweet volume from one user etc.) Also do your own extensive research before investing on any stocks.

Disclaimer: I am not a financial advisor. There are significant risks associated with investing in equities. Please do your own extensive research before investing in any stock.

You might also like...
Actively maintained, pure Python wrapper for the Twitter API. Supports both normal and streaming Twitter APIs.

Twython Twython is a Python library providing an easy way to access Twitter data. Supports Python 3. It's been battle tested by companies, educational

Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.
Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.

Twitter Nuke Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the puny and pointl

Twitter bot that finds new friends in Twitter.

PythonTwitterBot Twitter Bot Thats Find New Friends pip install textblob pip install tweepy pip install googletrans check requirements.txt file Env

A twitter multi-tool for OSINT on twitter accounts.

TwitterCheckr A twitter multi-tool for OSINT on twitter accounts. Infomation TwitterCheckr also known as TCheckr is multi-tool for OSINT on twitter a

twitter bot tha uses tweepy library class to connect to TWITTER API

TWITTER-BOT-tweepy- twitter bot that uses tweepy library class to connect to TWITTER API replies to mentions automatically and follows the tweet.autho

Twitter-bot - A Simple Twitter bot with python

twitterbot To use this bot, You will require API Key and Access Key. Signup at h

Twitter-redesign - Twitter Redesign With Django

Twitter Redesign A project that tests Django and React knowledge through a twitt

The algorithm performs a simple user registration (Name, CPF, E-mail and Telephone) in an Amazon RDS database and also performs the storage, training and facial recognition of the user's face to identify the users already registered in the system in a next time the user is seen.
This is a simple Python bot to identify sentiments in tweets

Twitter-Sentiment 👋 Hi There! 📱 This is a simple Python bot to identify sentiments in tweets 👨‍💻 This project was made for study, and pratice. You

Comments
  • can't get it work

    can't get it work

    hooked up twitter keys and ran twitter_stream.py it runs but won't output anything

    when I run dev_server.py and access it I get

    Select... Live Market Sentiment Long Term Market Sentiment 🛑 Errors (8) × ⛑️ Callback error updating live-graph.figure 10:32:17 AM ⛑️ Callback error updating live-graph.figure 10:32:16 AM ⛑️ Callback error updating live-graph.figure 10:32:15 AM ⛑️ Callback error updating live-graph.figure 10:32:14 AM ⛑️ Callback error updating live-graph.figure 10:32:13 AM

    opened by mojitocloud 2
  • new

    new

    My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.

    I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators). All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.

    The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction). For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation. And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.

    With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).

    I think it could be useful to you, to improve, I would like to share it with you, and if you are interested in improving and collaborating I am also willing, and if not file it in the box.

    If tou want, Please read the readme , and in case of any problem you can contact me , If you are convinced try to install it with the documentation. https://github.com/Leci37/LecTrade/tree/develop I appreciate the feedback

    opened by Leci37 0
  • code inserting only one character per row into mysql library

    code inserting only one character per row into mysql library

    I have this (somewhat) working script that takes comments from a Reddit subreddit and insert them into a MySQL database. The spaghetti code I ended up with, however, pastes one character from each comment to each row of the database instead of one comment per row.

    Screenshot: https://ibb.co/k0jNd59

    import praw
    import configReddit
    import mysql.connector
    import configMySQL
    
    # ---------------- REDDIT ---------------- #
    reddit = praw.Reddit(
        client_id=configReddit.client_id,
        client_secret=configReddit.client_secret,
        password=configReddit.password,
        user_agent=configReddit.user_agent,
        username=configReddit.username,
        charset='utf8mb4'
    )
    
    
    
    # ---------------- DATABASE ---------------- #
    
    mydb = mysql.connector.connect(
        host=configMySQL.host,
        user=configMySQL.user,
        password=configMySQL.password,
        database="db_blockchainstable",
    )
    
    mycursor = mydb.cursor()
    sql = "INSERT INTO test (rdtext) VALUES (%s)"
    
    
    # ---------------- EXE ---------------- #
    
    for comment in reddit.subreddit("CryptoCurrency+BitcoinMarkets+CryptoCurrencies+cryptomarkets+cryptocurrencytrading+cryptotrading+ethrader+Crypto_Currency_News").stream.comments():
        rdtext = str(comment.body)
        db = (rdtext)
        mycursor.executemany(sql, db)
        mydb.commit()
        print(comment.body)`
    opened by starp41 1
Owner
Market Sentiment
I analyze Twitter and Reddit real-time to accurately track the market sentiment for all the major companies.
Market Sentiment
Twitter automation tool for growing organic followers.

Tiwoto Tiwoto is a simple python program that automates some kind of behaviors and keep your account active. Create an .env file in this directory and

Mehmetcan Yildiz 6 Sep 22, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
A reddit bot that imitates the popular reddit bot "u/repostsleuthbot" to trick people into clicking on a rickroll

Reddit-Rickroll-Bot A reddit bot that imitates the popular reddit bot "u/repostsleuthbot" to trick people into clicking on a rickroll Made with The Py

null 0 Jul 16, 2022
Reddit bot that uses sentiment analysis

Reddit Bot Project 2: Neural Network Boogaloo Reddit bot that uses sentiment analysis from NLTK.VADER WIP_WIP_WIP_WIP_WIP_WIP Link to test subreddit:

TpK 1 Oct 24, 2021
Twitter bot that turns comment chains into ace attorney scenes. Inspired by and using https://github.com/micah5/ace-attorney-reddit-bot

Ace Attorney twitter Bot Twitter bot that turns comment chains into ace attorney scenes. Inspired by and using https://github.com/micah5/ace-attorney-

Luis Mayo Valbuena 542 Dec 17, 2022
BiliBili-live-barrage-transceiver - A simple python program for sending and receiving barrage in bilibili live room

BiliBili-live-barrage-transceiver - A simple python program for sending and receiving barrage in bilibili live room

zeroy 2 Jan 18, 2022
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
Tsar-Bot - Crypto auto trade bot that use sentiment analysis from twitter

Tsar Bot - Crypto Sentiment Bot Tsar Bot is a Twitter Crypto Sentiment Bot that

Hilmi Azizi 26 Dec 15, 2022
Python script to harvest tweets with the Twitter API V2 Academic Research Product Track

Tweet harvester Python script to scrape, collect, and/or harvest tweets with the Twitter API V2 Academic Research Product Track. Important note: In or

Thomas Frissen 2 Nov 11, 2021