Add deep dive function to get more into each single stock.

This commit is contained in:
2025-07-21 21:33:49 +02:00
parent b82ba39aab
commit 0c90fed0eb
9 changed files with 270 additions and 99 deletions

View File

@@ -1,10 +1,12 @@
# rstat_tool/dashboard.py
from flask import Flask, render_template
# --- FIX #1: Import the new function we need ---
from .database import (
get_overall_summary,
get_subreddit_summary,
get_all_scanned_subreddits
get_all_scanned_subreddits,
get_deep_dive_details
)
app = Flask(__name__, template_folder='../templates')
@@ -32,17 +34,22 @@ def inject_subreddits():
@app.route("/")
def index():
"""The handler for the main dashboard page."""
# --- CHANGE HERE: Limit the data to the top 10 ---
tickers = get_overall_summary(limit=10)
return render_template("index.html", tickers=tickers)
@app.route("/subreddit/<name>")
def subreddit_dashboard(name):
"""A dynamic route for per-subreddit dashboards."""
# --- CHANGE HERE: Limit the data to the top 10 ---
tickers = get_subreddit_summary(name, limit=10)
return render_template("subreddit.html", tickers=tickers, subreddit_name=name)
@app.route("/deep-dive/<symbol>")
def deep_dive(symbol):
"""The handler for the deep-dive page for a specific ticker."""
# --- FIX #2: Call the function directly, without the 'database.' prefix ---
posts = get_deep_dive_details(symbol)
return render_template("deep_dive.html", posts=posts, symbol=symbol)
def start_dashboard():
"""The main function called by the 'rstat-dashboard' command."""
print("Starting Flask server...")

View File

@@ -52,6 +52,20 @@ def initialize_db():
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
post_id TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
post_url TEXT,
subreddit_id INTEGER,
post_timestamp INTEGER,
comment_count INTEGER,
avg_comment_sentiment REAL,
FOREIGN KEY (subreddit_id) REFERENCES subreddits (id)
)
""")
conn.commit()
conn.close()
print("Database initialized successfully.")
@@ -195,4 +209,40 @@ def get_all_scanned_subreddits():
conn = get_db_connection()
results = conn.execute("SELECT DISTINCT name FROM subreddits ORDER BY name ASC;").fetchall()
conn.close()
return [row['name'] for row in results]
return [row['name'] for row in results]
def add_or_update_post_analysis(conn, post_data):
"""
Inserts a new post analysis record or updates an existing one.
This prevents duplicate entries for the same post.
"""
cursor = conn.cursor()
# Use the UNIQUE post_id to replace old data with new on conflict
cursor.execute(
"""
INSERT INTO posts (post_id, title, post_url, subreddit_id, post_timestamp, comment_count, avg_comment_sentiment)
VALUES (:post_id, :title, :post_url, :subreddit_id, :post_timestamp, :comment_count, :avg_comment_sentiment)
ON CONFLICT(post_id) DO UPDATE SET
comment_count = excluded.comment_count,
avg_comment_sentiment = excluded.avg_comment_sentiment;
""",
post_data
)
conn.commit()
def get_deep_dive_details(ticker_symbol):
"""
Gets all analyzed posts that mention a specific ticker.
"""
conn = get_db_connection()
query = """
SELECT DISTINCT p.*, s.name as subreddit_name FROM posts p
JOIN mentions m ON p.post_id = m.post_id
JOIN tickers t ON m.ticker_id = t.id
JOIN subreddits s ON p.subreddit_id = s.id
WHERE t.symbol = ?
ORDER BY p.post_timestamp DESC;
"""
results = conn.execute(query, (ticker_symbol,)).fetchall()
conn.close()
return results

View File

@@ -0,0 +1,85 @@
# The initial unsorted set of words.
# Note: In Python, a 'set' is inherently unordered, but we define it here for clarity.
COMMON_WORDS_BLACKLIST = {
"401K", "403B", "457B", "ABOUT", "ABOVE", "ADAM", "AEDT", "AEST", "AH", "AI",
"ALL", "ALPHA", "ALSO", "AM", "AMA", "AMEX", "AND", "ANY", "AR", "ARE",
"AROUND", "ASAP", "ASS", "ASSET", "AT", "ATH", "ATL", "ATM", "AUD", "BABY",
"BAG", "BAGS", "BE", "BEAR", "BELOW", "BETA", "BIG", "BIS", "BLEND", "BOE",
"BOJ", "BOMB", "BOND", "BOTH", "BOTS", "BRB", "BRL", "BS", "BST", "BTC",
"BTW", "BULL", "BUST", "BUT", "BUY", "BUZZ", "CAD", "CALL", "CAN", "CAP",
"CEO", "CEST", "CET", "CFO", "CHF", "CHIPS", "CIA", "CLOSE", "CNY", "COME",
"COST", "COULD", "CPAP", "CPI", "CST", "CTB", "CTO", "CYCLE", "CZK", "DAO",
"DATE", "DAX", "DAY", "DCA", "DD", "DEBT", "DIA", "DIV", "DJIA", "DKK",
"DM", "DO", "DOE", "DOGE", "DONT", "DR", "EACH", "EARLY", "EARN", "ECB",
"EDGAR", "EDIT", "EDT", "END", "EOD", "EOW", "EOY", "EPS", "ER", "ESG",
"EST", "ETF", "ETH", "EU", "EUR", "EV", "EVEN", "EVERY", "FAQ", "FAR",
"FAST", "FBI", "FDA", "FIHTX", "FINRA", "FINT", "FINTX", "FINTY", "FOMC", "FOMO",
"FOR", "FRAUD", "FRG", "FROM", "FSPSX", "FTSE", "FUCK", "FUD", "FULL", "FUND",
"FXAIX", "FXIAX", "FY", "FYI", "FZROX", "GAIN", "GBP", "GDP", "GET", "GL",
"GLHF", "GMT", "GO", "GOAL", "GOAT", "GOING", "GPT", "GPU", "GRAB", "GTG",
"HALF", "HAS", "HATE", "HAVE", "HEAR", "HEDGE", "HIGH", "HINT", "HKD", "HODL",
"HOLD", "HOUR", "HSA", "HUF", "IF", "II", "IMHO", "IMO", "IN", "INR",
"IP", "IPO", "IRA", "IRS", "IS", "ISM", "IST", "IT", "ITM", "IV",
"IVV", "IWM", "JPOW", "JPY", "JST", "JUST", "KARMA", "KEEP", "KNOW", "KO",
"KRW", "LARGE", "LAST", "LATE", "LATER", "LBO", "LEAP", "LEAPS", "LETS", "LFG",
"LIKE", "LIMIT", "LMAO", "LOL", "LONG", "LOOK", "LOSS", "LOVE", "LOW", "M&A",
"MA", "MAKE", "MAX", "MC", "ME", "MID", "MIGHT", "MIN", "ML", "MOASS",
"MONTH", "MORE", "MSK", "MUST", "MXN", "MY", "NATO", "NEAR", "NEED", "NEVER",
"NEW", "NEXT", "NFA", "NFT", "NGMI", "NIGHT", "NO", "NOK", "NONE", "NOT",
"NOW", "NSA", "NULL", "NYSE", "NZD", "OEM", "OF", "OK", "OLD", "ON",
"OP", "OR", "OS", "OTC", "OTM", "OUGHT", "OUT", "OVER", "OWN", "PC",
"PDT", "PE", "PEAK", "PEG", "PEW", "PLAN", "PLN", "PM", "PMI", "POS",
"PPI", "PR", "PRICE", "PROFIT", "PSA", "PST", "PT", "PUT", "Q1", "Q2",
"Q3", "Q4", "QQQ", "RBA", "RBNZ", "RE", "REAL", "REIT", "REKT", "RH",
"RIP", "RISK", "ROE", "ROFL", "ROI", "ROTH", "RSD", "RUB", "RULE", "SAVE",
"SCALP", "SCAM", "SCHB", "SEC", "SEE", "SEK", "SELL", "SEP", "SGD", "SHALL",
"SHARE", "SHORT", "SL", "SMALL", "SO", "SOLIS", "SOME", "SOON", "SP", "SPAC",
"SPEND", "SPLG", "SPX", "SPY", "START", "STILL", "STOCK", "STOP", "SWING", "TAKE",
"TERM", "THAT", "THE", "THINK", "THIS", "TIME", "TITS", "TL", "TL;DR", "TLDR",
"TO", "TODAY", "TOTAL", "TRADE", "TREND", "TRUE", "TRY", "TTYL", "TWO", "UI",
"UK", "UNDER", "UP", "US", "USA", "USD", "UTC", "VALUE", "VOO", "VR",
"VTI", "WAGMI", "WANT", "WATCH", "WAY", "WE", "WEB3", "WEEK", "WHO", "WHY",
"WILL", "WORTH", "WOULD", "WSB", "WTF", "YES", "YET", "YIELD", "YOLO", "YOU",
"YOUR", "YTD", "ZAR"
}
def format_and_print_list(word_set, words_per_line=10):
"""
Sorts a set of words and prints it in a specific format.
Args:
word_set (set): The set of words to process.
words_per_line (int): The number of words to print on each line.
"""
# 1. Convert the set to a list to ensure order, and sort it alphabetically.
# The set is also used to remove any duplicates from the initial list.
sorted_words = sorted(list(word_set))
# 2. Start printing the output
print("COMMON_WORDS_BLACKLIST = {")
# 3. Iterate through the sorted list and print words, respecting the line limit
for i in range(0, len(sorted_words), words_per_line):
# Get a chunk of words for the current line
line_chunk = sorted_words[i:i + words_per_line]
# Format each word with double quotes
formatted_words = [f'"{word}"' for word in line_chunk]
# Join the words with a comma and a space
line_content = ", ".join(formatted_words)
# Add a trailing comma if it's not the last line
is_last_line = (i + words_per_line) >= len(sorted_words)
if not is_last_line:
line_content += ","
# Print the indented line
print(f" {line_content}")
# 4. Print the closing brace
print("}")
# --- Main execution ---
if __name__ == "__main__":
format_and_print_list(COMMON_WORDS_BLACKLIST)

View File

@@ -1,4 +1,4 @@
# main.py
# rstat_tool/main.py
import argparse
import json
@@ -9,7 +9,6 @@ import praw
import yfinance as yf
from dotenv import load_dotenv
# Import local modules
from . import database
from .ticker_extractor import extract_tickers
from .sentiment_analyzer import get_sentiment_score
@@ -17,7 +16,6 @@ from .sentiment_analyzer import get_sentiment_score
load_dotenv()
MARKET_CAP_REFRESH_INTERVAL = 86400
# (load_subreddits, get_market_cap, get_reddit_instance functions are unchanged)
def load_subreddits(filepath):
try:
with open(filepath, 'r') as f:
@@ -38,11 +36,13 @@ def get_reddit_instance():
client_secret = os.getenv("REDDIT_CLIENT_SECRET")
user_agent = os.getenv("REDDIT_USER_AGENT")
if not all([client_id, client_secret, user_agent]):
print("Error: Reddit API credentials not found.")
print("Error: Reddit API credentials not found in .env file.")
return None
# --- THIS IS THE CORRECTED LINE ---
# The argument is 'client_secret', not 'secret_client'.
return praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent=user_agent)
# --- UPDATED: Function now accepts post_limit and comment_limit ---
def scan_subreddits(reddit, subreddits_list, post_limit=25, comment_limit=100):
"""Scans subreddits, analyzes posts and comments, and stores results in the database."""
conn = database.get_db_connection()
@@ -54,8 +54,10 @@ def scan_subreddits(reddit, subreddits_list, post_limit=25, comment_limit=100):
subreddit = reddit.subreddit(subreddit_name)
print(f"Scanning r/{subreddit_name}...")
for submission in subreddit.new(limit=post_limit):
# --- 1. Process the Post Title and Body ---
for submission in subreddit.hot(limit=post_limit):
# --- LOGIC PART 1: PROCESS INDIVIDUAL MENTIONS ---
# 1a. Process the Post Title and Body for mentions
post_text = submission.title + " " + submission.selftext
tickers_in_post = extract_tickers(post_text)
post_sentiment = get_sentiment_score(submission.title)
@@ -63,7 +65,7 @@ def scan_subreddits(reddit, subreddits_list, post_limit=25, comment_limit=100):
for ticker_symbol in set(tickers_in_post):
ticker_id = database.get_or_create_entity(conn, 'tickers', 'symbol', ticker_symbol)
database.add_mention(conn, ticker_id, subreddit_id, submission.id, int(submission.created_utc), post_sentiment)
# (Market cap logic remains the same)
ticker_info = database.get_ticker_info(conn, ticker_id)
current_time = int(time.time())
if not ticker_info['last_updated'] or (current_time - ticker_info['last_updated'] > MARKET_CAP_REFRESH_INTERVAL):
@@ -71,28 +73,32 @@ def scan_subreddits(reddit, subreddits_list, post_limit=25, comment_limit=100):
market_cap = get_market_cap(ticker_symbol)
database.update_ticker_market_cap(conn, ticker_id, market_cap or ticker_info['market_cap'])
# --- 2. Process the Comments ---
# Expand "MoreComments" objects. limit=None means we try to get all, but PRAW is protective.
# A limit of 32 is the max PRAW will do in a single call. We'll iterate to be safe.
submission.comments.replace_more(limit=10)
comment_count = 0
for comment in submission.comments.list():
if comment_count >= comment_limit:
break # Stop processing comments for this post if we hit our limit
# 1b. Process Comments for mentions
submission.comments.replace_more(limit=0)
for comment in submission.comments.list()[:comment_limit]:
tickers_in_comment = extract_tickers(comment.body)
if not tickers_in_comment:
continue # Skip comments that don't mention any tickers
continue
comment_sentiment = get_sentiment_score(comment.body)
for ticker_symbol in set(tickers_in_comment):
ticker_id = database.get_or_create_entity(conn, 'tickers', 'symbol', ticker_symbol)
# We use the submission.id as the post_id to group mentions correctly
database.add_mention(conn, ticker_id, subreddit_id, submission.id, int(comment.created_utc), comment_sentiment)
comment_count += 1
# --- LOGIC PART 2: DEEP DIVE ANALYSIS ---
all_comment_sentiments = []
for comment in submission.comments.list()[:comment_limit]:
all_comment_sentiments.append(get_sentiment_score(comment.body))
avg_sentiment = sum(all_comment_sentiments) / len(all_comment_sentiments) if all_comment_sentiments else 0
post_analysis_data = {
"post_id": submission.id, "title": submission.title,
"post_url": f"https://reddit.com{submission.permalink}",
"subreddit_id": subreddit_id, "post_timestamp": int(submission.created_utc),
"comment_count": len(all_comment_sentiments), "avg_comment_sentiment": avg_sentiment
}
database.add_or_update_post_analysis(conn, post_analysis_data)
except Exception as e:
print(f"Could not scan r/{subreddit_name}. Error: {e}")
@@ -100,50 +106,24 @@ def scan_subreddits(reddit, subreddits_list, post_limit=25, comment_limit=100):
print("\n--- Scan Complete ---")
def main():
"""Main function to run the Reddit stock analysis tool."""
parser = argparse.ArgumentParser(
description="Analyze stock ticker mentions on Reddit.",
formatter_class=argparse.RawTextHelpFormatter # For better help text formatting
)
# --- Existing Argument ---
parser = argparse.ArgumentParser(description="Analyze stock ticker mentions on Reddit.", formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("config_file", help="Path to the JSON file containing subreddits.")
# --- NEW Arguments ---
parser.add_argument(
"-p", "--posts",
type=int,
default=25,
help="Number of posts to scan per subreddit.\n(Default: 25)"
)
parser.add_argument(
"-c", "--comments",
type=int,
default=100,
help="Number of comments to scan per post.\n(Default: 100)"
)
parser.add_argument(
"-l", "--limit",
type=int,
default=20,
help="Number of tickers to show in the final report.\n(Default: 20)"
)
parser.add_argument("-p", "--posts", type=int, default=25, help="Number of posts to scan per subreddit.\n(Default: 25)")
parser.add_argument("-c", "--comments", type=int, default=100, help="Number of comments to scan per post.\n(Default: 100)")
parser.add_argument("-l", "--limit", type=int, default=20, help="Number of tickers to show in the final report.\n(Default: 20)")
args = parser.parse_args()
# --- Initialize and Run ---
database.initialize_db()
database.clean_stale_tickers()
subreddits = load_subreddits(args.config_file)
if not subreddits: return
reddit = get_reddit_instance()
if not reddit: return
# Pass the command-line arguments to the functions
scan_subreddits(reddit, subreddits, post_limit=args.posts, comment_limit=args.comments)
database.generate_summary_report(limit=args.limit)
if __name__ == "__main__":
main()

View File

@@ -5,50 +5,48 @@ import re
# A set of common English words and acronyms that look like stock tickers.
# This helps reduce false positives.
COMMON_WORDS_BLACKLIST = {
"401K", "403B", "457B", "ABOUT", "ABOVE", "ADAM", "AEDT", "AEST", "AH",
"AI", "ALL", "ALPHA", "ALSO", "AM", "AMA", "AMEX", "AND", "ANY", "AR",
"ARE", "AROUND", "ASAP", "ASS", "ASSET", "AT", "ATH", "ATL", "ATM",
"AUD", "BE", "BEAR", "BELOW", "BETA", "BIG", "BIS", "BLEND", "BOE",
"BOJ", "BOMB", "BOND", "BOTS", "BRB", "BRL", "BS", "BST", "BTC", "BTW",
"BULL", "BUT", "BUY", "BUZZ", "CAD", "CAN", "CEO", "CEST", "CET", "CFO",
"CHF", "CIA", "CLOSE", "CNY", "COME", "COST", "COULD", "CPI", "CST",
"CTB", "CTO", "CYCLE", "CZK", "DAO", "DATE", "DAX", "DAY", "DCA", "DD",
"DEBT", "DIA", "DIV", "DJIA", "DKK", "DM", "DO", "DOGE", "DONT", "DR",
"EACH", "EARLY", "EARN", "ECB", "EDGAR", "EDIT", "EDT", "END", "EPS",
"ER", "ESG", "EST", "ETF", "ETH", "EU", "EUR", "EV", "EVERY", "FAQ",
"FAR", "FAST", "FBI", "FDA", "FIHTX", "FINRA", "FINT", "FINTX", "FINTY",
"FOMC", "FOMO", "FOR", "FRAUD", "FRG", "FSPSX", "FTSE", "FUCK", "FUD",
"FULL", "FUND", "FXAIX", "FXIAX", "FY", "FYI", "FZROX", "GAIN", "GBP",
"GDP", "GET", "GMT", "GO", "GOAL", "GPU", "GRAB", "GTG", "HAS", "HAVE",
"HATE", "HEAR", "HEDGE", "HIGH", "HINT", "HKD", "HODL", "HOLD", "HOUR",
"HSA", "HUF", "IF", "IMHO", "IMO", "IN", "INR", "IP", "IPO", "IRA",
"401K", "403B", "457B", "ABOUT", "ABOVE", "ADAM", "AEDT", "AEST", "AH", "AI",
"ALL", "ALPHA", "ALSO", "AM", "AMA", "AMEX", "AND", "ANY", "AR", "ARE",
"AROUND", "ASAP", "ASS", "ASSET", "AT", "ATH", "ATL", "ATM", "AUD", "BABY",
"BAG", "BAGS", "BE", "BEAR", "BELOW", "BETA", "BIG", "BIS", "BLEND", "BOE",
"BOJ", "BOMB", "BOND", "BOTH", "BOTS", "BRB", "BRL", "BS", "BST", "BTC",
"BTW", "BULL", "BUST", "BUT", "BUY", "BUZZ", "CAD", "CALL", "CAN", "CEO",
"CEST", "CET", "CFO", "CHF", "CHIPS", "CIA", "CLOSE", "CNY", "COME", "COST",
"COULD", "CPI", "CST", "CTB", "CTO", "CYCLE", "CZK", "DAO", "DATE", "DAX",
"DAY", "DCA", "DD", "DEBT", "DIA", "DIV", "DJIA", "DKK", "DM", "DO",
"DOE", "DOGE", "DONT", "DR", "EACH", "EARLY", "EARN", "ECB", "EDGAR", "EDIT",
"EDT", "END", "EOD", "EOW", "EOY", "EPS", "ER", "ESG", "EST", "ETF",
"ETH", "EU", "EUR", "EV", "EVEN", "EVERY", "FAQ", "FAR", "FAST", "FBI",
"FDA", "FIHTX", "FINRA", "FINT", "FINTX", "FINTY", "FOMC", "FOMO", "FOR", "FRAUD",
"FRG", "FROM", "FSPSX", "FTSE", "FUCK", "FUD", "FULL", "FUND", "FXAIX", "FXIAX",
"FY", "FYI", "FZROX", "GAIN", "GBP", "GDP", "GET", "GL", "GLHF", "GMT",
"GO", "GOAL", "GOAT", "GOING", "GPU", "GRAB", "GTG", "HALF", "HAS", "HATE",
"HAVE", "HEAR", "HEDGE", "HIGH", "HINT", "HKD", "HODL", "HOLD", "HOUR", "HSA",
"HUF", "IF", "II", "IMHO", "IMO", "IN", "INR", "IP", "IPO", "IRA",
"IRS", "IS", "ISM", "IST", "IT", "ITM", "IV", "IVV", "IWM", "JPOW",
"JPY", "JST", "JUST", "KARMA", "KNOW", "KO", "KRW", "LARGE", "LAST",
"LATE", "LATER", "LBO", "LEAP", "LEAPS", "LETS", "LFG", "LIKE", "LIMIT",
"LMAO", "LOL", "LONG", "LOOK", "LOSS", "LOVE", "LOW", "M&A", "MAKE",
"MAX", "MC", "ME", "MID", "MIGHT", "MIN", "ML", "MOASS", "MONTH", "MSK",
"MUST", "MXN", "MY", "NATO", "NEAR", "NEED", "NEVER", "NEW", "NEXT",
"NFA", "NFT", "NGMI", "NIGHT", "NO", "NOK", "NONE", "NOT", "NOW", "NSA",
"NULL", "NZD", "NYSE", "OF", "OK", "OLD", "ON", "OP", "OPEN", "OR",
"JPY", "JST", "JUST", "KARMA", "KEEP", "KNOW", "KO", "KRW", "LARGE", "LAST",
"LATE", "LATER", "LBO", "LEAP", "LEAPS", "LETS", "LFG", "LIKE", "LIMIT", "LMAO",
"LOL", "LONG", "LOOK", "LOSS", "LOVE", "LOW", "M&A", "MA", "MAKE", "MAX",
"MC", "ME", "MID", "MIGHT", "MIN", "ML", "MOASS", "MONTH", "MORE", "MSK",
"MUST", "MXN", "MY", "NATO", "NEAR", "NEED", "NEVER", "NEW", "NEXT", "NFA",
"NFT", "NGMI", "NIGHT", "NO", "NOK", "NONE", "NOT", "NOW", "NSA", "NULL",
"NYSE", "NZD", "OEM", "OF", "OK", "OLD", "ON", "OP", "OR", "OS",
"OTC", "OTM", "OUGHT", "OUT", "OVER", "OWN", "PC", "PDT", "PE", "PEAK",
"PEG", "PEW", "PLAN", "PLN", "PM", "PMI", "POS", "PPI", "PR", "PRICE",
"PROFIT", "PSA", "PST", "Q1", "Q2", "Q3", "Q4", "QQQ", "RBA", "RBNZ",
"RE", "REAL", "REIT", "REKT", "RH", "RIP", "RISK", "ROE", "ROFL", "ROI",
"ROTH", "RSD", "RUB", "RULE", "SAVE", "SCALP", "SCAM", "SCHB", "SEC",
"SEE", "SEK", "SELL", "SEP", "SGD", "SHALL", "SHARE", "SHORT", "SO",
"SOME", "SOON", "SP", "SPAC", "SPEND", "SPLG", "SPX", "SPY", "START",
"STILL", "STOCK", "STOP", "SWING", "TAKE", "TERM", "THAT", "THE", "THINK",
"THIS", "TIME", "TITS", "TL", "TL;DR", "TLDR", "TO", "TODAY", "TOTAL",
"TRADE", "TREND", "TRUE", "TRY", "TTYL", "TWO", "UI", "UK", "UNDER",
"UP", "US", "USA", "USD", "UTC", "VTI", "VALUE", "VOO", "VR", "WAGMI",
"WANT", "WATCH", "WAY", "WE", "WEB3", "WEEK", "WHO", "WHY", "WILL",
"WORTH", "WOULD", "WSB", "WTF", "YET", "YIELD", "YES", "YOLO", "YOU",
"ZAR",
"YOUR", "BABY", "BAG", "BAGS", "GL", "GLHF", "EOD", "EOW", "EOY", "GOING", "KEEP",
"MORE", "PUT", "CALL", "YTD", "BOTH", "BUST", "EVEN", "FROM", "GOAT", "HALF",
"SL", "OS", "SOLIS", "OEM", "MA", "DOE", "II", "CHIPS"
"PROFIT", "PSA", "PST", "PUT", "Q1", "Q2", "Q3", "Q4", "QQQ", "RBA",
"RBNZ", "RE", "REAL", "REIT", "REKT", "RH", "RIP", "RISK", "ROE", "ROFL",
"ROI", "ROTH", "RSD", "RUB", "RULE", "SAVE", "SCALP", "SCAM", "SCHB", "SEC",
"SEE", "SEK", "SELL", "SEP", "SGD", "SHALL", "SHARE", "SHORT", "SL", "SO",
"SOLIS", "SOME", "SOON", "SP", "SPAC", "SPEND", "SPLG", "SPX", "SPY", "START",
"STILL", "STOCK", "STOP", "SWING", "TAKE", "TERM", "THAT", "THE", "THINK", "THIS",
"TIME", "TITS", "TL", "TL;DR", "TLDR", "TO", "TODAY", "TOTAL", "TRADE", "TREND",
"TRUE", "TRY", "TTYL", "TWO", "UI", "UK", "UNDER", "UP", "US", "USA",
"USD", "UTC", "VALUE", "VOO", "VR", "VTI", "WAGMI", "WANT", "WATCH", "WAY",
"WE", "WEB3", "WEEK", "WHO", "WHY", "WILL", "WORTH", "WOULD", "WSB", "WTF",
"YES", "YET", "YIELD", "YOLO", "YOU", "YOUR", "YTD", "ZAR"
}
def extract_tickers(text):
"""
Extracts potential stock tickers from a given piece of text.

View File

@@ -71,6 +71,28 @@
.sentiment-bullish { color: #28a745; font-weight: 600; }
.sentiment-bearish { color: #dc3545; font-weight: 600; }
.sentiment-neutral { color: #6c757d; }
.post-card {
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.post-card h3 {
margin-top: 0;
font-size: 1.2rem;
}
.post-card h3 a {
color: #0056b3;
text-decoration: none;
}
.post-card h3 a:hover {
text-decoration: underline;
}
.post-meta {
font-size: 0.9rem;
color: #666;
}
</style>
</head>
<body>

29
templates/deep_dive.html Normal file
View File

@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block title %}Deep Dive: {{ symbol }}{% endblock %}
{% block content %}
<h1>Deep Dive Analysis for: <strong>{{ symbol }}</strong></h1>
<p>Showing posts that mention {{ symbol }}, sorted by most recent.</p>
{% for post in posts %}
<div class="post-card">
<h3><a href="{{ post.post_url }}" target="_blank">{{ post.title }}</a></h3>
<div class="post-meta">
<span>r/{{ post.subreddit_name }}</span> |
<span>{{ post.comment_count }} comments analyzed</span> |
<span>Avg. Sentiment:
{% if post.avg_comment_sentiment > 0.1 %}
<span class="sentiment-bullish">{{ "%.2f"|format(post.avg_comment_sentiment) }}</span>
{% elif post.avg_comment_sentiment < -0.1 %}
<span class="sentiment-bearish">{{ "%.2f"|format(post.avg_comment_sentiment) }}</span>
{% else %}
<span class="sentiment-neutral">{{ "%.2f"|format(post.avg_comment_sentiment) }}</span>
{% endif %}
</span>
</div>
</div>
{% else %}
<p>No analyzed posts found for this ticker. Run the 'rstat' scraper to gather data.</p>
{% endfor %}
{% endblock %}

View File

@@ -16,7 +16,7 @@
<tbody>
{% for ticker in tickers %}
<tr>
<td><strong>{{ ticker.symbol }}</strong></td>
<td><strong><a href="/deep-dive/{{ ticker.symbol }}">{{ ticker.symbol }}</a></strong></td>
<td>{{ ticker.mention_count }}</td>
<td>{{ ticker.market_cap | format_mc }}</td>
<td>

View File

@@ -16,7 +16,7 @@
<tbody>
{% for ticker in tickers %}
<tr>
<td><strong>{{ ticker.symbol }}</strong></td>
<td><strong><a href="/deep-dive/{{ ticker.symbol }}">{{ ticker.symbol }}</a></strong></td>
<td>{{ ticker.mention_count }}</td>
<td>{{ ticker.market_cap | format_mc }}</td>
<td>