Skip to content

rfoo1250/stock-socmed-sentiment-analyzer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Media Sentiment Analysis of Stock Market

Rui Heng Foo (rfoo1250) and Michael Liu (restics)

Description

This project is a comprehensive stock market analysis tool developed for CSE 472: Social Media Mining. The Python program mines social media platforms for posts related to a specific stock, performs sentiment analysis on the collected data, and generates a daily sentiment score ranging from -100 to 100.

This sentiment score is then used to generate trading signals—buy, sell, or hold—based on user-defined thresholds. The system includes a robust backtesting feature that simulates the trading strategy against the last 10 years of historical stock data, allowing for evaluation of the strategy's effectiveness through key performance metrics and visualizations.

OS environment 💻

OS env for Michael

  • Windows 11
  • Python 3.12
  • pip 24.3.1

OS env for Foo

  • Windows 10 / Powershell Major 5 Minor 1 Build 19041 Revision 5129
  • Python 3.12.5
  • pip 24.3.1

Command lines 📑

Prerequisites: current path of the directory is ...\472proj2

  1. Enter pip install -r requirements.txt to the command line of your terminal to install necessary python packages via pip.
  2. Run both python Alpha_Vantage_stocks_crawler.py and python prawscraper.py in part1\
  3. Run python sentiment_analysis.py in part2\
  4. Run only python processdatasets.py in part3\
  5. Run python backtesting_program.py in part4\

Further instructions and details are listed in the report.

Directory Structure 🌳

|   README.md
|   requirements.txt
|   
+---.idea
|   |   .gitignore
|   |   472proj2.iml
|   |   csv-editor.xml
|   |   discord.xml
|   |   misc.xml
|   |   modules.xml
|   |   vcs.xml
|   |   
|   \---inspectionProfiles
|           profiles_settings.xml
|           
+---part1
|   |   .env
|   |   Alpha_Vantage_stocks_crawler.py
|   |   Alpha_Vantage_stocks_crawler.py.bak
|   |   decade_daily_NVDA_prices.csv
|   |   prawscraper.py
|   |   year_daily_NVDA_prices.csv
|   |   
|   \---out
|           rdaytrading_nvda.csv
|           rinvesting_NVDA.csv
|           rstocks_NVDA.csv
|           rwallstreetbets_NVDA.csv
|           
+---part2
|   |   sentiment_analysis.py
|   |   sentiment_analysis.py.bak
|   |   
|   \---out
|           combined_sentiment_results.csv
|           daily_sentiment_score.csv
|           
+---part3
|   |   .env
|   |   brokerbot.py
|   |   brokerbot.py.bak
|   |   processdatasets.py
|   |   processdatasets.py.bak
|   |   
|   +---out
|   |       combined_sentiment_results.csv
|   |       
|   \---__pycache__
|           brokerbot.cpython-312.pyc
|           
+---part4
|       backtesting_program.py
|       backtesting_program.py.bak
|       brokerbot.py
            

About

A Python tool developed for CSE 472: Social Media Mining that analyzes social media sentiment to generate stock trading signals. The system backtests the strategy's effectiveness against 10 years of historical data using customizable thresholds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%