mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 22:11:55 +00:00
* Finnhub and finbrain fns * Twitter menu (forex/ba adjusted) * Google menu * Reddit menu pt1 * Reddit commands * Stocktwits commands * Sentimentinvestor commands * Update crypto-dd * Review pt 1 * Hugo server * Review comments - get rid of all prints/errors in model...
34 lines
820 B
Python
34 lines
820 B
Python
"""Reddit Helpers"""
|
|
__docformat__ = "numpy"
|
|
|
|
from typing import List
|
|
import re
|
|
|
|
import praw
|
|
|
|
|
|
def find_tickers(submission: praw.models.reddit.submission.Submission) -> List[str]:
|
|
"""Extracts potential tickers from reddit submission
|
|
|
|
Parameters
|
|
----------
|
|
submission : praw.models.reddit.submission.Submission
|
|
Reddit post to scan
|
|
|
|
Returns
|
|
-------
|
|
List[str]
|
|
List of potential tickers
|
|
"""
|
|
ls_text = [submission.selftext, submission.title]
|
|
submission.comments.replace_more(limit=0)
|
|
for comment in submission.comments.list():
|
|
ls_text.append(comment.body)
|
|
|
|
l_tickers_found = []
|
|
for s_text in ls_text:
|
|
for s_ticker in set(re.findall(r"([A-Z]{3,5} )", s_text)):
|
|
l_tickers_found.append(s_ticker.strip())
|
|
|
|
return l_tickers_found
|