Added web dashboard.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
yfinance
|
yfinance
|
||||||
praw
|
praw
|
||||||
python-dotenv
|
python-dotenv
|
||||||
nltk
|
nltk
|
||||||
|
Flask
|
54
rstat_tool/dashboard.py
Normal file
54
rstat_tool/dashboard.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# rstat_tool/dashboard.py
|
||||||
|
|
||||||
|
from flask import Flask, render_template
|
||||||
|
from .database import (
|
||||||
|
get_overall_summary,
|
||||||
|
get_subreddit_summary,
|
||||||
|
get_all_scanned_subreddits
|
||||||
|
)
|
||||||
|
|
||||||
|
app = Flask(__name__, template_folder='../templates')
|
||||||
|
|
||||||
|
@app.template_filter('format_mc')
|
||||||
|
def format_market_cap(mc):
|
||||||
|
"""Formats a large number into a readable market cap string."""
|
||||||
|
if mc is None or mc == 0:
|
||||||
|
return "N/A"
|
||||||
|
if mc >= 1e12:
|
||||||
|
return f"${mc/1e12:.2f}T"
|
||||||
|
elif mc >= 1e9:
|
||||||
|
return f"${mc/1e9:.2f}B"
|
||||||
|
elif mc >= 1e6:
|
||||||
|
return f"${mc/1e6:.2f}M"
|
||||||
|
else:
|
||||||
|
return f"${mc:,}"
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
def inject_subreddits():
|
||||||
|
"""Makes the list of all scanned subreddits available to every template."""
|
||||||
|
subreddits = get_all_scanned_subreddits()
|
||||||
|
return dict(subreddits=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)
|
||||||
|
|
||||||
|
def start_dashboard():
|
||||||
|
"""The main function called by the 'rstat-dashboard' command."""
|
||||||
|
print("Starting Flask server...")
|
||||||
|
print("Open http://127.0.0.1:5000 in your browser.")
|
||||||
|
print("Press CTRL+C to stop the server.")
|
||||||
|
app.run(debug=True)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
start_dashboard()
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import time
|
import time
|
||||||
# --- IMPORT ADDED BACK IN ---
|
|
||||||
from .ticker_extractor import COMMON_WORDS_BLACKLIST
|
from .ticker_extractor import COMMON_WORDS_BLACKLIST
|
||||||
|
|
||||||
DB_FILE = "reddit_stocks.db"
|
DB_FILE = "reddit_stocks.db"
|
||||||
@@ -14,9 +13,13 @@ def get_db_connection():
|
|||||||
return conn
|
return conn
|
||||||
|
|
||||||
def initialize_db():
|
def initialize_db():
|
||||||
# ... (This function is unchanged)
|
"""
|
||||||
|
Initializes the database and creates the necessary tables if they don't exist.
|
||||||
|
"""
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# --- Create tickers table ---
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS tickers (
|
CREATE TABLE IF NOT EXISTS tickers (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -25,12 +28,16 @@ def initialize_db():
|
|||||||
last_updated INTEGER
|
last_updated INTEGER
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# --- Create subreddits table ---
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS subreddits (
|
CREATE TABLE IF NOT EXISTS subreddits (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
name TEXT NOT NULL UNIQUE
|
name TEXT NOT NULL UNIQUE
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# --- Create mentions table ---
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS mentions (
|
CREATE TABLE IF NOT EXISTS mentions (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -44,11 +51,11 @@ def initialize_db():
|
|||||||
UNIQUE(ticker_id, post_id, sentiment_score)
|
UNIQUE(ticker_id, post_id, sentiment_score)
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
print("Database initialized successfully.")
|
print("Database initialized successfully.")
|
||||||
|
|
||||||
# --- CLEANUP FUNCTION ADDED BACK IN ---
|
|
||||||
def clean_stale_tickers():
|
def clean_stale_tickers():
|
||||||
"""
|
"""
|
||||||
Removes tickers and their associated mentions from the database
|
Removes tickers and their associated mentions from the database
|
||||||
@@ -58,7 +65,6 @@ def clean_stale_tickers():
|
|||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
# Find ticker IDs that match the blacklist
|
|
||||||
placeholders = ','.join('?' for _ in COMMON_WORDS_BLACKLIST)
|
placeholders = ','.join('?' for _ in COMMON_WORDS_BLACKLIST)
|
||||||
query = f"SELECT id, symbol FROM tickers WHERE symbol IN ({placeholders})"
|
query = f"SELECT id, symbol FROM tickers WHERE symbol IN ({placeholders})"
|
||||||
|
|
||||||
@@ -74,11 +80,7 @@ def clean_stale_tickers():
|
|||||||
ticker_id = ticker['id']
|
ticker_id = ticker['id']
|
||||||
ticker_symbol = ticker['symbol']
|
ticker_symbol = ticker['symbol']
|
||||||
print(f"Removing stale ticker '{ticker_symbol}' (ID: {ticker_id})...")
|
print(f"Removing stale ticker '{ticker_symbol}' (ID: {ticker_id})...")
|
||||||
|
|
||||||
# 1. Delete all mentions associated with this ticker ID
|
|
||||||
cursor.execute("DELETE FROM mentions WHERE ticker_id = ?", (ticker_id,))
|
cursor.execute("DELETE FROM mentions WHERE ticker_id = ?", (ticker_id,))
|
||||||
|
|
||||||
# 2. Delete the ticker itself
|
|
||||||
cursor.execute("DELETE FROM tickers WHERE id = ?", (ticker_id,))
|
cursor.execute("DELETE FROM tickers WHERE id = ?", (ticker_id,))
|
||||||
|
|
||||||
deleted_count = conn.total_changes
|
deleted_count = conn.total_changes
|
||||||
@@ -88,7 +90,7 @@ def clean_stale_tickers():
|
|||||||
|
|
||||||
|
|
||||||
def add_mention(conn, ticker_id, subreddit_id, post_id, timestamp, sentiment):
|
def add_mention(conn, ticker_id, subreddit_id, post_id, timestamp, sentiment):
|
||||||
# ... (This function is unchanged)
|
"""Adds a new mention with its sentiment score to the database."""
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
@@ -99,49 +101,44 @@ def add_mention(conn, ticker_id, subreddit_id, post_id, timestamp, sentiment):
|
|||||||
except sqlite3.IntegrityError:
|
except sqlite3.IntegrityError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# ... (get_or_create_entity, update_ticker_market_cap, get_ticker_info are unchanged)
|
|
||||||
def get_or_create_entity(conn, table_name, column_name, value):
|
def get_or_create_entity(conn, table_name, column_name, value):
|
||||||
# ...
|
"""Generic function to get or create an entity and return its ID."""
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute(f"SELECT id FROM {table_name} WHERE {column_name} = ?", (value,))
|
cursor.execute(f"SELECT id FROM {table_name} WHERE {column_name} = ?", (value,))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result: return result['id']
|
if result:
|
||||||
|
return result['id']
|
||||||
else:
|
else:
|
||||||
cursor.execute(f"INSERT INTO {table_name} ({column_name}) VALUES (?)", (value,))
|
cursor.execute(f"INSERT INTO {table_name} ({column_name}) VALUES (?)", (value,))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return cursor.lastrowid
|
return cursor.lastrowid
|
||||||
|
|
||||||
def update_ticker_market_cap(conn, ticker_id, market_cap):
|
def update_ticker_market_cap(conn, ticker_id, market_cap):
|
||||||
# ...
|
"""Updates the market cap and timestamp for a specific ticker."""
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
current_timestamp = int(time.time())
|
current_timestamp = int(time.time())
|
||||||
cursor.execute("UPDATE tickers SET market_cap = ?, last_updated = ? WHERE id = ?", (market_cap, current_timestamp, ticker_id))
|
cursor.execute("UPDATE tickers SET market_cap = ?, last_updated = ? WHERE id = ?", (market_cap, current_timestamp, ticker_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def get_ticker_info(conn, ticker_id):
|
def get_ticker_info(conn, ticker_id):
|
||||||
# ...
|
"""Retrieves all info for a specific ticker by its ID."""
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("SELECT * FROM tickers WHERE id = ?", (ticker_id,))
|
cursor.execute("SELECT * FROM tickers WHERE id = ?", (ticker_id,))
|
||||||
return cursor.fetchone()
|
return cursor.fetchone()
|
||||||
|
|
||||||
def generate_summary_report(limit=20):
|
def generate_summary_report(limit=20):
|
||||||
# ... (This function is unchanged)
|
"""Queries the DB to generate a summary for the command-line tool."""
|
||||||
print(f"\n--- Top {limit} Tickers by Mention Count ---")
|
print(f"\n--- Top {limit} Tickers by Mention Count ---")
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
query = """
|
query = """
|
||||||
SELECT
|
SELECT
|
||||||
t.symbol,
|
t.symbol, t.market_cap, COUNT(m.id) as mention_count,
|
||||||
t.market_cap,
|
|
||||||
COUNT(m.id) as mention_count,
|
|
||||||
SUM(CASE WHEN m.sentiment_score > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
|
SUM(CASE WHEN m.sentiment_score > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
|
||||||
SUM(CASE WHEN m.sentiment_score < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
SUM(CASE WHEN m.sentiment_score < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
||||||
SUM(CASE WHEN m.sentiment_score BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
SUM(CASE WHEN m.sentiment_score BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
||||||
FROM mentions m
|
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||||
JOIN tickers t ON m.ticker_id = t.id
|
GROUP BY t.symbol, t.market_cap ORDER BY mention_count DESC LIMIT ?;
|
||||||
GROUP BY t.symbol, t.market_cap
|
|
||||||
ORDER BY mention_count DESC
|
|
||||||
LIMIT ?;
|
|
||||||
"""
|
"""
|
||||||
results = cursor.execute(query, (limit,)).fetchall()
|
results = cursor.execute(query, (limit,)).fetchall()
|
||||||
header = f"{'Ticker':<8} | {'Mentions':<8} | {'Bullish':<8} | {'Bearish':<8} | {'Neutral':<8} | {'Market Cap':<15}"
|
header = f"{'Ticker':<8} | {'Mentions':<8} | {'Bullish':<8} | {'Bearish':<8} | {'Neutral':<8} | {'Market Cap':<15}"
|
||||||
@@ -155,4 +152,47 @@ def generate_summary_report(limit=20):
|
|||||||
elif mc >= 1e9: market_cap_str = f"${mc/1e9:.2f}B"
|
elif mc >= 1e9: market_cap_str = f"${mc/1e9:.2f}B"
|
||||||
else: market_cap_str = f"${mc/1e6:.2f}M"
|
else: market_cap_str = f"${mc/1e6:.2f}M"
|
||||||
print(f"{row['symbol']:<8} | {row['mention_count']:<8} | {row['bullish_mentions']:<8} | {row['bearish_mentions']:<8} | {row['neutral_mentions']:<8} | {market_cap_str:<15}")
|
print(f"{row['symbol']:<8} | {row['mention_count']:<8} | {row['bullish_mentions']:<8} | {row['bearish_mentions']:<8} | {row['neutral_mentions']:<8} | {market_cap_str:<15}")
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
def get_overall_summary(limit=50):
|
||||||
|
"""Gets the top tickers across all subreddits for the dashboard."""
|
||||||
|
conn = get_db_connection()
|
||||||
|
query = """
|
||||||
|
SELECT
|
||||||
|
t.symbol, t.market_cap, COUNT(m.id) as mention_count,
|
||||||
|
SUM(CASE WHEN m.sentiment_score > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
|
||||||
|
SUM(CASE WHEN m.sentiment_score < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
||||||
|
SUM(CASE WHEN m.sentiment_score BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
||||||
|
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||||
|
GROUP BY t.symbol, t.market_cap ORDER BY mention_count DESC LIMIT ?;
|
||||||
|
"""
|
||||||
|
results = conn.execute(query, (limit,)).fetchall()
|
||||||
|
conn.close()
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_subreddit_summary(subreddit_name, limit=50):
|
||||||
|
"""Gets the top tickers for a specific subreddit for the dashboard."""
|
||||||
|
conn = get_db_connection()
|
||||||
|
query = """
|
||||||
|
SELECT
|
||||||
|
t.symbol, t.market_cap, COUNT(m.id) as mention_count,
|
||||||
|
SUM(CASE WHEN m.sentiment_score > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
|
||||||
|
SUM(CASE WHEN m.sentiment_score < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
||||||
|
SUM(CASE WHEN m.sentiment_score BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
||||||
|
FROM mentions m
|
||||||
|
JOIN tickers t ON m.ticker_id = t.id
|
||||||
|
JOIN subreddits s ON m.subreddit_id = s.id
|
||||||
|
WHERE s.name = ?
|
||||||
|
GROUP BY t.symbol, t.market_cap ORDER BY mention_count DESC LIMIT ?;
|
||||||
|
"""
|
||||||
|
results = conn.execute(query, (subreddit_name, limit)).fetchall()
|
||||||
|
conn.close()
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_all_scanned_subreddits():
|
||||||
|
"""Gets a unique list of all subreddits we have data for."""
|
||||||
|
# --- THIS IS THE CORRECTED LINE ---
|
||||||
|
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]
|
@@ -5,44 +5,50 @@ import re
|
|||||||
# A set of common English words and acronyms that look like stock tickers.
|
# A set of common English words and acronyms that look like stock tickers.
|
||||||
# This helps reduce false positives.
|
# This helps reduce false positives.
|
||||||
COMMON_WORDS_BLACKLIST = {
|
COMMON_WORDS_BLACKLIST = {
|
||||||
"401K", "403B", "457B", "ABOVE", "AI", "ALL", "ALPHA", "AMA", "AMEX",
|
"401K", "403B", "457B", "ABOUT", "ABOVE", "ADAM", "AEDT", "AEST", "AH",
|
||||||
"AND", "ANY", "AR", "ARE", "AROUND", "ASSET", "AT", "ATH", "ATL", "AUD",
|
"AI", "ALL", "ALPHA", "ALSO", "AM", "AMA", "AMEX", "AND", "ANY", "AR",
|
||||||
"BE", "BEAR", "BELOW", "BETA", "BIG", "BIS", "BLEND", "BOE", "BOJ",
|
"ARE", "AROUND", "ASAP", "ASS", "ASSET", "AT", "ATH", "ATL", "ATM",
|
||||||
"BOND", "BRB", "BRL", "BTC", "BTW", "BULL", "BUT", "BUY", "BUZZ", "CAD",
|
"AUD", "BE", "BEAR", "BELOW", "BETA", "BIG", "BIS", "BLEND", "BOE",
|
||||||
"CAN", "CEO", "CFO", "CHF", "CIA", "CNY", "COME", "COST", "COULD", "CPI",
|
"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",
|
"CTB", "CTO", "CYCLE", "CZK", "DAO", "DATE", "DAX", "DAY", "DCA", "DD",
|
||||||
"DEBT", "DIA", "DIV", "DJIA", "DKK", "DM", "DO", "DOGE", "DR", "EACH",
|
"DEBT", "DIA", "DIV", "DJIA", "DKK", "DM", "DO", "DOGE", "DONT", "DR",
|
||||||
"EARLY", "EARN", "ECB", "EDGAR", "EDIT", "EPS", "ESG", "ETF", "ETH",
|
"EACH", "EARLY", "EARN", "ECB", "EDGAR", "EDIT", "EDT", "END", "EPS",
|
||||||
"EU", "EUR", "EV", "EVERY", "FAQ", "FAR", "FAST", "FBI", "FDA", "FIHTX",
|
"ER", "ESG", "EST", "ETF", "ETH", "EU", "EUR", "EV", "EVERY", "FAQ",
|
||||||
"FINRA", "FINT", "FINTX", "FINTY", "FOMC", "FOMO", "FOR", "FRAUD",
|
"FAR", "FAST", "FBI", "FDA", "FIHTX", "FINRA", "FINT", "FINTX", "FINTY",
|
||||||
"FRG", "FSPSX", "FTSE", "FUD", "FULL", "FUND", "FXAIX", "FXIAX", "FY",
|
"FOMC", "FOMO", "FOR", "FRAUD", "FRG", "FSPSX", "FTSE", "FUCK", "FUD",
|
||||||
"FYI", "FZROX", "GAIN", "GDP", "GET", "GBP", "GO", "GOAL", "GPU", "GRAB",
|
"FULL", "FUND", "FXAIX", "FXIAX", "FY", "FYI", "FZROX", "GAIN", "GBP",
|
||||||
"GTG", "HAS", "HAVE", "HATE", "HEAR", "HEDGE", "HINT", "HKD", "HODL",
|
"GDP", "GET", "GMT", "GO", "GOAL", "GPU", "GRAB", "GTG", "HAS", "HAVE",
|
||||||
"HOLD", "HOUR", "HSA", "HUF", "IMHO", "IMO", "IN", "INR", "IPO", "IRA",
|
"HATE", "HEAR", "HEDGE", "HIGH", "HINT", "HKD", "HODL", "HOLD", "HOUR",
|
||||||
"IRS", "IS", "ISM", "IT", "IV", "IVV", "IWM", "JPY", "JUST", "KNOW",
|
"HSA", "HUF", "IF", "IMHO", "IMO", "IN", "INR", "IP", "IPO", "IRA",
|
||||||
"KRW", "LARGE", "LAST", "LATE", "LATER", "LBO", "LIKE", "LMAO", "LOL",
|
"IRS", "IS", "ISM", "IST", "IT", "ITM", "IV", "IVV", "IWM", "JPOW",
|
||||||
"LONG", "LOOK", "LOSS", "LOVE", "M&A", "MAKE", "MAX", "MC", "MID", "MIGHT",
|
"JPY", "JST", "JUST", "KARMA", "KNOW", "KO", "KRW", "LARGE", "LAST",
|
||||||
"MIN", "ML", "MOASS", "MONTH", "MUST", "MXN", "MY", "NATO", "NEAR",
|
"LATE", "LATER", "LBO", "LEAP", "LEAPS", "LETS", "LFG", "LIKE", "LIMIT",
|
||||||
"NEED", "NEW", "NEXT", "NFA", "NFT", "NGMI", "NIGHT", "NO", "NOK", "NONE",
|
"LMAO", "LOL", "LONG", "LOOK", "LOSS", "LOVE", "LOW", "M&A", "MAKE",
|
||||||
"NOT", "NOW", "NSA", "NULL", "NZD", "NYSE", "OF", "OK", "OLD", "ON",
|
"MAX", "MC", "ME", "MID", "MIGHT", "MIN", "ML", "MOASS", "MONTH", "MSK",
|
||||||
"OP", "OR", "OTC", "OUGHT", "OUT", "OVER", "PE", "PEAK", "PEG",
|
"MUST", "MXN", "MY", "NATO", "NEAR", "NEED", "NEVER", "NEW", "NEXT",
|
||||||
"PLAN", "PLN", "PMI", "PPI", "PRICE", "PROFIT", "PSA", "Q1", "Q2", "Q3",
|
"NFA", "NFT", "NGMI", "NIGHT", "NO", "NOK", "NONE", "NOT", "NOW", "NSA",
|
||||||
"Q4", "QQQ", "RBA", "RBNZ", "REIT", "REKT", "RH", "RISK", "ROE", "ROFL",
|
"NULL", "NZD", "NYSE", "OF", "OK", "OLD", "ON", "OP", "OPEN", "OR",
|
||||||
"ROI", "ROTH", "RSD", "RUB", "SAVE", "SCALP", "SCAM", "SCHB", "SEC",
|
"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",
|
"SEE", "SEK", "SELL", "SEP", "SGD", "SHALL", "SHARE", "SHORT", "SO",
|
||||||
"SOME", "SOON", "SPAC", "SPEND", "SPLG", "SPX", "SPY", "STILL", "STOCK",
|
"SOME", "SOON", "SP", "SPAC", "SPEND", "SPLG", "SPX", "SPY", "START",
|
||||||
"SWING", "TAKE", "TERM", "THE", "THINK", "THIS", "TIME", "TL", "TL;DR",
|
"STILL", "STOCK", "STOP", "SWING", "TAKE", "TERM", "THAT", "THE", "THINK",
|
||||||
"TLDR", "TODAY", "TO", "TOTAL", "TRADE", "TREND", "TRUE", "TRY", "TTYL",
|
"THIS", "TIME", "TITS", "TL", "TL;DR", "TLDR", "TO", "TODAY", "TOTAL",
|
||||||
"TWO", "UK", "UNDER", "UP", "US", "USA", "USD", "VTI", "VALUE", "VOO",
|
"TRADE", "TREND", "TRUE", "TRY", "TTYL", "TWO", "UI", "UK", "UNDER",
|
||||||
"VR", "WAGMI", "WANT", "WATCH", "WAY", "WE", "WEB3", "WEEK", "WHO",
|
"UP", "US", "USA", "USD", "UTC", "VTI", "VALUE", "VOO", "VR", "WAGMI",
|
||||||
"WHY", "WILL", "WORTH", "WOULD", "WSB", "YET", "YIELD", "YOLO", "YOU",
|
"WANT", "WATCH", "WAY", "WE", "WEB3", "WEEK", "WHO", "WHY", "WILL",
|
||||||
|
"WORTH", "WOULD", "WSB", "WTF", "YET", "YIELD", "YES", "YOLO", "YOU",
|
||||||
"ZAR",
|
"ZAR",
|
||||||
"KARMA", "OTM", "ITM", "ATM", "JPOW", "OPEN", "CLOSE", "HIGH", "LOW",
|
"YOUR", "BABY", "BAG", "BAGS", "GL", "GLHF", "EOD", "EOW", "EOY", "GOING", "KEEP",
|
||||||
"RE", "BS", "ASAP", "RULE", "REAL", "LIMIT", "STOP", "END", "START", "BOTS",
|
"MORE", "PUT", "CALL", "YTD", "BOTH", "BUST", "EVEN", "FROM", "GOAT", "HALF",
|
||||||
"UTC", "AH", "PM", "PR", "GMT", "EST", "CST", "PST", "BST", "AEDT", "AEST",
|
"SL", "OS", "SOLIS", "OEM", "MA", "DOE", "II", "CHIPS"
|
||||||
"CET", "CEST", "EDT", "IST", "JST", "MSK", "PDT", "PST", "YES", "NO", "OWN",
|
|
||||||
"BOMB",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def extract_tickers(text):
|
def extract_tickers(text):
|
||||||
"""
|
"""
|
||||||
Extracts potential stock tickers from a given piece of text.
|
Extracts potential stock tickers from a given piece of text.
|
||||||
|
1
setup.py
1
setup.py
@@ -18,6 +18,7 @@ setup(
|
|||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
# The path is now 'package_name.module_name:function_name'
|
# The path is now 'package_name.module_name:function_name'
|
||||||
'rstat=rstat_tool.main:main',
|
'rstat=rstat_tool.main:main',
|
||||||
|
'rstat-dashboard=rstat_tool.dashboard:start_dashboard',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
@@ -2,6 +2,8 @@
|
|||||||
"subreddits": [
|
"subreddits": [
|
||||||
"pennystocks",
|
"pennystocks",
|
||||||
"Shortsqueeze",
|
"Shortsqueeze",
|
||||||
"smallstreetbets"
|
"smallstreetbets",
|
||||||
|
"wallstreetbets",
|
||||||
|
"Wallstreetbetsnew"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
87
templates/base.html
Normal file
87
templates/base.html
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}Reddit Stock Dashboard{% endblock %}</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
background-color: #f4f7f6;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
.navbar {
|
||||||
|
background-color: #ffffff;
|
||||||
|
padding: 1rem 2rem;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
.navbar a {
|
||||||
|
color: #555;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
.navbar a:hover {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 1000px;
|
||||||
|
margin: 2rem auto;
|
||||||
|
padding: 2rem;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 1.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-top: 0;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 2rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
padding: 1rem;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.sentiment-bullish { color: #28a745; font-weight: 600; }
|
||||||
|
.sentiment-bearish { color: #dc3545; font-weight: 600; }
|
||||||
|
.sentiment-neutral { color: #6c757d; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="navbar">
|
||||||
|
<a href="/">Overall</a>
|
||||||
|
{% for sub in subreddits %}
|
||||||
|
<a href="/subreddit/{{ sub }}">r/{{ sub }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</header>
|
||||||
|
<main class="container">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
35
templates/index.html
Normal file
35
templates/index.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Overall Dashboard{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Top 10 Tickers (All Subreddits)</h1>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Ticker</th>
|
||||||
|
<th>Mentions</th>
|
||||||
|
<th>Market Cap</th>
|
||||||
|
<th>Sentiment</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for ticker in tickers %}
|
||||||
|
<tr>
|
||||||
|
<td><strong>{{ ticker.symbol }}</strong></td>
|
||||||
|
<td>{{ ticker.mention_count }}</td>
|
||||||
|
<td>{{ ticker.market_cap | format_mc }}</td>
|
||||||
|
<td>
|
||||||
|
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
|
||||||
|
<span class="sentiment-bullish">Bullish</span>
|
||||||
|
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
|
||||||
|
<span class="sentiment-bearish">Bearish</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="sentiment-neutral">Neutral</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
35
templates/subreddit.html
Normal file
35
templates/subreddit.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}r/{{ subreddit_name }} Dashboard{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Top 10 Tickers in r/{{ subreddit_name }}</h1>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Ticker</th>
|
||||||
|
<th>Mentions</th>
|
||||||
|
<th>Market Cap</th>
|
||||||
|
<th>Sentiment</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for ticker in tickers %}
|
||||||
|
<tr>
|
||||||
|
<td><strong>{{ ticker.symbol }}</strong></td>
|
||||||
|
<td>{{ ticker.mention_count }}</td>
|
||||||
|
<td>{{ ticker.market_cap | format_mc }}</td>
|
||||||
|
<td>
|
||||||
|
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
|
||||||
|
<span class="sentiment-bullish">Bullish</span>
|
||||||
|
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
|
||||||
|
<span class="sentiment-bearish">Bearish</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="sentiment-neutral">Neutral</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
Reference in New Issue
Block a user