From ed4162c057049f4e6254e68c7125bef52057db7e Mon Sep 17 00:00:00 2001 From: DJ Date: Sun, 25 Apr 2021 05:54:16 -0600 Subject: [PATCH] infer and sentiment from twitter --- .../due_diligence/reddit_view.py | 1 - gamestonk_terminal/forex/README.md | 21 +++++++++++++++++++ gamestonk_terminal/forex/fx_controller.py | 12 +++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gamestonk_terminal/due_diligence/reddit_view.py b/gamestonk_terminal/due_diligence/reddit_view.py index 7fcb1d8af67..3348e8638eb 100644 --- a/gamestonk_terminal/due_diligence/reddit_view.py +++ b/gamestonk_terminal/due_diligence/reddit_view.py @@ -99,7 +99,6 @@ def due_diligence(other_args: List[str], ticker: str): "investing", "wallstreetbets", "forex", - "Daytrading", "Forexstrategy", ] diff --git a/gamestonk_terminal/forex/README.md b/gamestonk_terminal/forex/README.md index 8ee6d44f6b9..05a9b9e8856 100644 --- a/gamestonk_terminal/forex/README.md +++ b/gamestonk_terminal/forex/README.md @@ -38,6 +38,10 @@ This menu utilizes oanda to enable support for trading forex. * Output up to the 30 last messages on the board * [reddit](#reddit) * Gets due diligence from another user's post [Reddit] +* [infer](#infer) + * Infer about stock's sentiment from latest tweets +* [sentiment](#sentiment) + * In-depth sentiment prediction from tweets over time * [edasummary](#edasummary) * Brief summary statistics using exploratory data analysis * [edarolling](#edarolling) @@ -206,6 +210,23 @@ Print top stock's due diligence from other users. [Source: Reddit] * -d : number of prior days to look for * -a : "search through all flairs (apart from Yolo and Meme). Default False (i.e. use flairs: DD, technical analysis, Catalyst, News, Advice, Chart, Charts and Setups, Fundamental Analysis, Forex, Trade Idea) +## infer +``` +usage: infer [-n N_NUM] +``` +Print quick sentiment inference from last tweets that contain the ticker. This model splits the text into character-level tokens and uses the DistilBERT model to make predictions. DistilBERT is a distilled version of the powerful BERT transformer model. Not only time period of these, but also frequency. Inspired by https://towardsdatascience.com/sentiment-analysis-for-stock-price-prediction-in-python-bed40c65d178. [Source: Twitter] + +* -n : num of latest tweets to infer from. Default 100. + +## sentiment +``` +usage: sentiment [-n N_NUM] [-d N_DAYS_PAST] +``` +Plot in-depth sentiment extracted from tweets from last days that contain pre-defined ticker. This model splits the text into character-level tokens and uses the DistilBERT model to make predictions. DistilBERT is a distilled version of the powerful BERT transformer model. Note that a big num of tweets extracted per hour in conjunction with a high number of days in the past, will make the algorithm take a long period of time to estimate sentiment. Inspired by https://towardsdatascience.com/sentiment-analysis-for-stock-price-prediction-in-python-bed40c65d178. [Source: Twitter] + +* -n : num of tweets to extract per hour. Default 100. +* -d : num of days in the past to extract tweets. Default 7. + ## edasummary ```text diff --git a/gamestonk_terminal/forex/fx_controller.py b/gamestonk_terminal/forex/fx_controller.py index b844f2042d0..8dcbee82cef 100644 --- a/gamestonk_terminal/forex/fx_controller.py +++ b/gamestonk_terminal/forex/fx_controller.py @@ -7,7 +7,7 @@ from gamestonk_terminal.menu import session from gamestonk_terminal.forex import fx_view from gamestonk_terminal import config_terminal as cfg from gamestonk_terminal.due_diligence import news_view, reddit_view -from gamestonk_terminal.behavioural_analysis import stocktwits_view +from gamestonk_terminal.behavioural_analysis import stocktwits_view, twitter_view from gamestonk_terminal.exploratory_data_analysis import eda_api account = cfg.OANDA_ACCOUNT @@ -37,12 +37,14 @@ class ForexController: "news", "bullbear", "messages", + "reddit", + "infer", + "sentiment", "edasummary", "edarolling", "edadecompose", "edacusum", "edahist", - "reddit", ] def __init__(self): @@ -222,6 +224,12 @@ class ForexController: instrument = fx_view.format_instrument(self.instrument, " ") reddit_view.due_diligence(other_args, instrument) + def call_infer(self, other_args: List[str]): + twitter_view.inference(other_args, self.instrument) + + def call_sentiment(self, other_args: List[str]): + twitter_view.sentiment(other_args, self.instrument) + def menu(): """Oanda Menu"""