Skip to content
/ sentock Public

πŸ’‡β€β™€οΈ Sentimental Stocks or "Stocks vs. Twitter Sentiments"

License

Notifications You must be signed in to change notification settings

thecsw/sentock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sentocks

Sentocks is a sentiments rating analysis tool! We know if traders are confident in a stock, then the said stock value goes up. What if we try to analyze people's feelings and emotions about something and see where we can go from there?

Sentocks or Sentimental Stocks grabs twitter feed by searching on pre-determined keywords and applies some quick sentiment analysis to get a rough estimate on one's sentiment about a topic.

Below is an example of how it looks for some companies on 2020-04-25 from 15:30 -> 00:30 UTC

Sentocks Example

The question is, is there a correlation between sentiments and the stock market?

Initial results

Picture below is an example of comparing sentiment ratings and stock market values on 2020-04-28 (Click to zoom in)

Market result

Testing your or our data

We have a collaboratory google jupyter notebook where you can add any endpoints and test the data for its correctness, etc. Python code there does all the plotting and figuring out the incoming format.

Microservice architecture

This is the layout of basic services we have running

Architecture

  • server: handles all interactions with the database, non-GET have to be authorized
  • twippy: actual twitter feed listener and raw sentiment submitter. Sends raw data to server
  • josh: takes raw data from server and performs a window averaging algorithm to get processed sentiment data
  • bobby: A small goroutine in server.go that deletes raw sentiment database entries that are more than 24 hours old
  • trump: same as twippy but only listens for POTUS related keywords
  • caddy: the webserver that proxies incoming requests to server and vuejs
  • postgres: the database stores the companies, raw sentiments and processed average sentiment values.
  • vuejs: the frontend that connects to alphavantage api and server's processed sentiments

How to start

Everything is handled with a dockerfile and environmental variables. Run

cp .env.example .env

and fill out .env to your liking, with your twitter keys and some unique WEB_KEY

If you're running a local caddy, leave CADDY_WEB_ADDRESS as localhost where you can later access the website through localhost:2015 and api (server) through localhost:2015/api/

Scripts

You can test your twitter token by running ./scripts/tokentest.sh

You can test the python code by running ./scripts/pytest.sh

You can get Go dependencies for go testing by running ./scripts/deps.sh

You can test Go code by running ./scripts/test.sh

You can deploy a full environment by running ./scripts/prod.sh

Authors

References

This project wouldn't be what it is without building upon the works of many other people:

  • tweepy - a Python library for accessing the twitter API
  • Alpha Vantage - an API for accessing realtime and historical stock data
  • vaderSentiment - a sentiment analysis tool
  • Gorm - an ORM library for Golang
  • gorilla/mux - http router and URl matcher for Golang
  • logrus - a Golang logging tool
  • testify - a Golang testing tool
  • Vue.js - a Javascript framework
  • Chart.js - A Javascript chart making library
  • Materialize - A front-end design framework (Javascript/css)
  • Go - A programming language
  • Python - Also a programming language
  • Javascript - Yet another programming language
  • Docker - A way of containerizing applications
  • Caddy - An open source Golang webserver
  • PostgreSQL - A database system

License

For all your licensing questions, please refer to our license