From d8b4fc0026179630d4759af9986ad5c4bf792b79 Mon Sep 17 00:00:00 2001 From: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com> Date: Fri, 28 Jan 2022 22:05:44 +0000 Subject: [PATCH] Add check_supported and trending endpoint from Sentiment Investor (#1262) * Add supported and trending endpoint * Allow valid hour to be 0 * Update Hugo server * Update Hugo optional arguemnts * Update documents for start data type * Adding terminal images * Update _index.md * Fix header error * Update tests for api token sentiment investor * Add test for Sentiment Investor View & Model * Mock the token * Changed color for trend command * Mock test view and add document for Test README Co-authored-by: Minh Hoang Co-authored-by: jmaslek --- .../sentimentinvestor_model.py | 89 +++++++++- .../sentimentinvestor_view.py | 164 +++++++++++++----- gamestonk_terminal/config_terminal.py | 1 - .../overview/pycoingecko_model.py | 2 +- gamestonk_terminal/helper_funcs.py | 10 ++ .../behavioural_analysis/ba_controller.py | 55 +++++- gamestonk_terminal/terminal_helper.py | 6 +- tests/README.md | 19 +- .../test_check_api_keys.yaml | 32 ++++ .../test_check_supported_ticker[BTC-USD].yaml | 34 ++++ .../test_check_supported_ticker[BTC].yaml | 34 ++++ ...torical[AAPL-2020-12-1-2020-12-7-100].yaml | 34 ++++ .../test_get_trending[start0-9-10].yaml | 34 ++++ .../test_display_historical.yaml | 66 +++++++ .../test_display_trending.yaml | 34 ++++ ...storical[AAPL-2020-12-1-2020-12-7-100].csv | 1 + .../test_get_trending[start0-9-10].csv | 11 ++ .../test_check_supported_ticker[BTC-USD].json | 1 + .../test_check_supported_ticker[BTC].json | 1 + .../test_sentimentinvestor_model.py | 47 +++++ .../test_sentimentinvestor_view.py | 42 +++++ .../test_display_historical.txt | 12 ++ .../test_display_trending.txt | 12 ++ .../test_ba_controller.py | 18 ++ .../test_ba_controller/test_print_help.txt | 1 + .../behavioural_analysis/emerging/_index.md | 40 ----- .../behavioural_analysis/hist/_index.md | 38 ++++ .../behavioural_analysis/historical/_index.md | 42 ----- .../behavioural_analysis/metrics/_index.md | 41 ----- .../behavioural_analysis/popularsi/_index.md | 35 ---- .../behavioural_analysis/social/_index.md | 14 -- .../behavioural_analysis/trend/_index.md | 22 +++ website/data/menu/main.yml | 16 +- 33 files changed, 774 insertions(+), 234 deletions(-) create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC].yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_historical.yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_trending.yaml create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].csv create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[start0-9-10].csv create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].json create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC].json create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_historical.txt create mode 100644 tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_trending.txt delete mode 100755 website/content/common/behavioural_analysis/emerging/_index.md create mode 100755 website/content/common/behavioural_analysis/hist/_index.md delete mode 100755 website/content/common/behavioural_analysis/historical/_index.md delete mode 100755 website/content/common/behavioural_analysis/metrics/_index.md delete mode 100755 website/content/common/behavioural_analysis/popularsi/_index.md delete mode 100755 website/content/common/behavioural_analysis/social/_index.md create mode 100755 website/content/common/behavioural_analysis/trend/_index.md diff --git a/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_model.py b/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_model.py index ae1c03aed7f..5c660797aa5 100644 --- a/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_model.py +++ b/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_model.py @@ -2,6 +2,7 @@ __docformat__ = "numpy" from typing import Union, Dict +from datetime import datetime, timedelta import requests import pandas as pd @@ -48,10 +49,96 @@ def get_historical(ticker: str, start: str, end: str, number: int) -> pd.DataFra # check if result is not empty if result: - df = pd.DataFrame(response.json()["results"]) + df = pd.DataFrame(result) df = df.set_index("timestamp_date") df.index = pd.to_datetime(df.index) return df return pd.DataFrame() + + +def check_supported_ticker(ticker: str) -> bool: + """Check if the ticker is supported + + Source: [Sentiment Investor] + + Parameters + ---------- + ticker: str + Ticker to view sentiment data + + Returns + ------- + result: Boolean + + """ + + payload: Dict[str, str] = { + "token": cfg.API_SENTIMENTINVESTOR_TOKEN, + "symbol": ticker, + } + + response = requests.get( + "https://api.sentimentinvestor.com/v1/supported", params=payload + ) + + if response.status_code == 200: + + try: + # if ticker is valid, payload has result key + return response.json()["result"] + + # if ticker is not valid, payload doesn't have result key + except KeyError: + pass + + return False + + +def get_trending(start: datetime, hour: int, number: int) -> pd.DataFrame: + """Get sentiment data on the most talked about tickers + within the last hour + + Source: [Sentiment Investor] + + Parameters + ---------- + start: datetime + Datetime object (e.g. datetime(2021, 12, 21) + hour: int + Hour of the day in 24-hour notation (e.g. 14) + number : int + Number of results returned by API call + Maximum 250 per api call + + Returns + ------- + pd.DataFrame + Dataframe of trending data + """ + + # type is datetime + start_timestamp = start + timedelta(hours=hour) + + payload: Dict[str, Union[int, str]] = { + "token": cfg.API_SENTIMENTINVESTOR_TOKEN, + "start": str(start_timestamp), + "end": str(start_timestamp), + "limit": number, + } + + response = requests.get( + "https://api.sentimentinvestor.com/v1/trending", params=payload + ) + + if response.status_code == 200: + result = response.json()["results"] + + # check if result is not empty + if result: + df = pd.DataFrame(result) + + return df + + return pd.DataFrame() diff --git a/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_view.py b/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_view.py index c4262070396..5add59eb9e6 100644 --- a/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_view.py +++ b/gamestonk_terminal/common/behavioural_analysis/sentimentinvestor_view.py @@ -2,8 +2,10 @@ __docformat__ = "numpy" import os +from datetime import datetime import matplotlib.dates as mdates from matplotlib import pyplot as plt +import pandas as pd from gamestonk_terminal.common.behavioural_analysis import sentimentinvestor_model from gamestonk_terminal.helper_funcs import export_data, print_rich_table @@ -44,56 +46,136 @@ def display_historical( ------- """ - df = sentimentinvestor_model.get_historical(ticker, start, end, number) + supported_ticker = sentimentinvestor_model.check_supported_ticker(ticker) + + # Check to see if the ticker is supported + if not supported_ticker: + print(f"Ticker {ticker} not supported. Please try another one!\n") + + else: + df = sentimentinvestor_model.get_historical(ticker, start, end, number) + + if df.empty: + print("Error in Sentiment Investor request") + else: + _, ax1 = plt.subplots(figsize=(25, 7)) + ax1.plot(df.index, df["RHI"], c="k") + ax2 = ax1.twinx() + + ax1.grid() + ax2.plot(df.index, df["AHI"], c="orange") + + ax1.set_ylabel("RHI") + ax1.set_xlabel("Time") + ax1.set_title("Hourly-level data of RHI and AHI") + ax1.set_xlim(df.index[0], df.index[-1]) + ax2.set_ylabel("AHI") + + plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d %H:%M")) + plt.gcf().autofmt_xdate() + + if gtff.USE_ION: + plt.ion() + + plt.show() + + export_data( + export, + os.path.dirname(os.path.abspath(__file__)).replace("common", "stocks"), + "hist", + df, + ) + + RAW_COLS = ["twitter", "stocktwits", "yahoo", "likes", "RHI", "AHI"] + + if raw: + df.index = df.index.strftime("%Y-%m-%d %H:%M") + df.index.name = "Time" + + print_rich_table( + df[RAW_COLS].head(limit), + headers=[ + "Twitter", + "Stocktwits", + "Yahoo", + "Likes", + "RHI", + "AHI", + ], + show_index=True, + index_name="Time", + title="Historical Sentiment Data", + ) + + +def display_trending( + start: datetime, + hour: int, + export: str, + number: int = 10, + limit: int = 10, +): + """Display most talked about tickers within + the last hour together with their sentiment data. + + Parameters + ---------- + start: datetime + Datetime object (e.g. datetime(2021, 12, 21) + hour: int + Hour of the day in 24-hour notation (e.g. 14) + number : int + Number of results returned by API call + Maximum 250 per api call + limit: int + Number of results display on the terminal + Default: 10 + ------- + Returns + None + """ + + df = sentimentinvestor_model.get_trending(start, hour, number) if df.empty: print("Error in Sentiment Investor request") + else: - _, ax1 = plt.subplots(figsize=(25, 7)) - ax1.plot(df.index, df["RHI"], c="k") - ax2 = ax1.twinx() - - ax1.grid() - ax2.plot(df.index, df["AHI"], c="orange") - - ax1.set_ylabel("RHI") - ax1.set_xlabel("Time") - ax1.set_title("Hourly-level data of RHI and AHI") - ax1.set_xlim(df.index[0], df.index[-1]) - ax2.set_ylabel("AHI") - - plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d %H:%M")) - plt.gcf().autofmt_xdate() - - if gtff.USE_ION: - plt.ion() - - plt.show() - export_data( export, os.path.dirname(os.path.abspath(__file__)).replace("common", "stocks"), - "hist", + "trend", df, ) - RAW_COLS = ["twitter", "stocktwits", "yahoo", "likes", "RHI", "AHI"] + RAW_COLS = [ + "total", + "twitter", + "stocktwits", + "yahoo", + "likes", + "RHI", + "AHI", + ] - if raw: - df.index = df.index.strftime("%Y-%m-%d %H:%M") - df.index.name = "Time" + df.ticker = df.ticker.str.upper() + df = df.set_index("ticker") - print_rich_table( - df[RAW_COLS].head(limit), - headers=[ - "Time", - "Twitter", - "Stocktwits", - "Yahoo", - "Likes", - "RHI", - "AHI", - ], - show_index=True, - title="Historical Sentiment Data", - ) + df.timestamp_date = pd.to_datetime(df.timestamp_date) + timestamp = df.timestamp_date[0].strftime("%Y-%m-%d %H:%M") + + print_rich_table( + df[RAW_COLS].head(limit), + headers=[ + "Total", + "Twitter", + "Stocktwits", + "Yahoo", + "Likes", + "RHI", + "AHI", + ], + show_index=True, + index_name="Ticker", + title=f"Most trending stocks at {timestamp}", + ) diff --git a/gamestonk_terminal/config_terminal.py b/gamestonk_terminal/config_terminal.py index f3ceced7f9f..8503941eef2 100644 --- a/gamestonk_terminal/config_terminal.py +++ b/gamestonk_terminal/config_terminal.py @@ -101,7 +101,6 @@ API_FINNHUB_KEY = os.getenv("GT_API_FINNHUB_KEY") or "REPLACE_ME" API_IEX_TOKEN = os.getenv("GT_API_IEX_KEY") or "REPLACE_ME" # https://www.sentimentinvestor.com -API_SENTIMENTINVESTOR_KEY = os.getenv("GT_API_SENTIMENTINVESTOR_KEY") or "REPLACE_ME" API_SENTIMENTINVESTOR_TOKEN = ( os.getenv("GT_API_SENTIMENTINVESTOR_TOKEN") or "REPLACE_ME" ) diff --git a/gamestonk_terminal/cryptocurrency/overview/pycoingecko_model.py b/gamestonk_terminal/cryptocurrency/overview/pycoingecko_model.py index 2b84c25e33c..dc464df17a2 100644 --- a/gamestonk_terminal/cryptocurrency/overview/pycoingecko_model.py +++ b/gamestonk_terminal/cryptocurrency/overview/pycoingecko_model.py @@ -1,7 +1,7 @@ """CoinGecko model""" __docformat__ = "numpy" -# pylint: disable=C0301 +# pylint: disable=C0301, E1101 from typing import Any, List import re diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index d7591066529..73e35c89401 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -264,6 +264,16 @@ def valid_date(s: str) -> datetime: raise argparse.ArgumentTypeError(f"Not a valid date: {s}") from value_error +def valid_hour(hr: str) -> int: + """Argparse type to check hour is valid with 24-hour notation""" + + new_hr = int(hr) + + if (new_hr < 0) or (new_hr > 24): + raise argparse.ArgumentTypeError(f"{hr} doesn't follow 24-hour notion.") + return new_hr + + def plot_view_stock(df: pd.DataFrame, symbol: str, interval: str): """ Plot the loaded stock dataframe diff --git a/gamestonk_terminal/stocks/behavioural_analysis/ba_controller.py b/gamestonk_terminal/stocks/behavioural_analysis/ba_controller.py index cdf9eb2077a..a77f8f887ae 100644 --- a/gamestonk_terminal/stocks/behavioural_analysis/ba_controller.py +++ b/gamestonk_terminal/stocks/behavioural_analysis/ba_controller.py @@ -15,6 +15,7 @@ from gamestonk_terminal.helper_funcs import ( parse_known_args_and_warn, check_int_range, valid_date, + valid_hour, check_positive, ) from gamestonk_terminal.menu import session @@ -56,6 +57,7 @@ class BehaviouralAnalysisController(StockController): "popular", "getdd", "hist", + "trend", ] historical_sort = ["date", "value"] @@ -106,7 +108,8 @@ class BehaviouralAnalysisController(StockController): regions regions that show highest interest in stock queries top related queries with this stock rise top rising related queries with stock{has_ticker_end} -[src][SentimentInvestor][/src]{has_ticker_start} +[src][SentimentInvestor][/src] + trend most talked about tickers within the last hour{has_ticker_start} hist plot historical RHI and AHI data by hour{has_ticker_end}[/cmds] """ @@ -714,6 +717,52 @@ class BehaviouralAnalysisController(StockController): raw=ns_parser.raw, limit=ns_parser.limit, ) - else: - print("No ticker loaded. Please load using 'load '\n") + console.print("No ticker loaded. Please load using 'load '\n") + + def call_trend(self, other_args: List[str]): + """Process trend command""" + parser = argparse.ArgumentParser( + add_help=False, + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + prog="trend", + description="Show most talked about tickers within the last one hour", + ) + parser.add_argument( + "-s", + "--start", + type=valid_date, + default=datetime.utcnow().strftime("%Y-%m-%d"), + dest="start", + help="The starting date (format YYYY-MM-DD). Default: Today", + ) + + parser.add_argument( + "-hr", + "--hour", + type=valid_hour, + default=0, + dest="hour", + help="Hour of the day in the 24-hour notation. Example: 14", + ) + + parser.add_argument( + "-n", + "--number", + default=10, + type=check_positive, + dest="number", + help="Number of results returned from Sentiment Investor. Default: 10", + ) + + ns_parser = parse_known_args_and_warn( + parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED, limit=10 + ) + + if ns_parser: + sentimentinvestor_view.display_trending( + start=ns_parser.start, + hour=ns_parser.hour, + export=ns_parser.export, + number=ns_parser.number, + ) diff --git a/gamestonk_terminal/terminal_helper.py b/gamestonk_terminal/terminal_helper.py index c8d563c2777..848408138c2 100644 --- a/gamestonk_terminal/terminal_helper.py +++ b/gamestonk_terminal/terminal_helper.py @@ -261,13 +261,13 @@ def check_api_keys(): else: key_dict["BITQUERY"] = "defined, test failed" # SentimentInvestor keys - si_keys = [cfg.API_SENTIMENTINVESTOR_KEY, cfg.API_SENTIMENTINVESTOR_TOKEN] + si_keys = [cfg.API_SENTIMENTINVESTOR_TOKEN] if "REPLACE_ME" in si_keys: key_dict["SENTIMENT_INVESTOR"] = "Not defined" else: account = requests.get( - f"https://api.sentimentinvestor.com/v4/account" - f"?token={cfg.API_SENTIMENTINVESTOR_TOKEN}&key={cfg.API_SENTIMENTINVESTOR_KEY}" + f"https://api.sentimentinvestor.com/v1/trending" + f"?token={cfg.API_SENTIMENTINVESTOR_TOKEN}" ) if account.ok and account.json().get("success", False): key_dict["SENTIMENT_INVESTOR"] = "Defined, test passed" diff --git a/tests/README.md b/tests/README.md index 148d549c754..80ea3682ee3 100644 --- a/tests/README.md +++ b/tests/README.md @@ -249,6 +249,23 @@ More information on markers location are available in pytest documentation : ## 3.8. Known `issue` / `solution` +**ION Usage** + +If you are testing for a `_view.py` module that uses `ION`, you would need to mock it. With Windows, the charts / graphs are unable to close the graph applications. This would make the tests failed when running with Windows. + +You can use the following example below. Once you have mocked the graphs / charts, simply call the display function, which is now a mocked object. + +``` +@pytest.mark.vcr +@pytest.mark.record_stdout +def test_display_defi_tvl(mocker): + # MOCK CHARTS + mocker.patch.object(target=llama_view.gtff, attribute="USE_ION", new=True) + mocker.patch(target="gamestonk_terminal.stocks.options.yfinance_view.plt.ion") + mocker.patch(target="gamestonk_terminal.stocks.options.yfinance_view.plt.show") + llama_view.display_defi_tvl(20) +``` + **YFINANCE** If a method is using the `yfinance` library but do not let you pick the `start/end` dates it will pick the current date each time. @@ -324,7 +341,7 @@ def test_ark_orders_view(kwargs_dict, mocker, use_color): The library `requests` doesn't support : `brotli` comnpression. -Unless `brotli` library is installed in the enviroment. +Unless `brotli` library is installed in the environment. Plus `brotli` is not in `GamestonkTerminal` requirements. diff --git a/tests/gamestonk_terminal/cassettes/test_terminal_helper/test_check_api_keys.yaml b/tests/gamestonk_terminal/cassettes/test_terminal_helper/test_check_api_keys.yaml index 48a0844afe2..00b6318e693 100644 --- a/tests/gamestonk_terminal/cassettes/test_terminal_helper/test_check_api_keys.yaml +++ b/tests/gamestonk_terminal/cassettes/test_terminal_helper/test_check_api_keys.yaml @@ -1772,4 +1772,36 @@ interactions: status: code: 200 message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/trending?token=MJYQW23-5TMMDD8-KEMTCN9-GEHX08G + response: + body: + string: '{"success":true,"results":[{"id":"hist_27_11_tsla","sentiment_count":38,"timestamp_date":"2022-01-27T11:00:00.000Z","total":94,"twitter":0,"stocktwits":73,"reddit_comment":0,"reddit_post":0,"yahoo":21,"ticker":"tsla","likes":39,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.4586,"AHI":1.4576,"SGP":0,"total_tweet_volume":203},{"id":"hist_27_11_msft","sentiment_count":8,"timestamp_date":"2022-01-27T11:00:00.000Z","total":16,"twitter":0,"stocktwits":10,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"msft","likes":6,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.6668,"AHI":0.9962,"SGP":0,"total_tweet_volume":21},{"id":"hist_27_11_aapl","sentiment_count":22,"timestamp_date":"2022-01-27T11:00:00.000Z","total":39,"twitter":0,"stocktwits":32,"reddit_comment":0,"reddit_post":0,"yahoo":7,"ticker":"aapl","likes":11,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.3089,"AHI":1.4339,"SGP":0,"total_tweet_volume":15},{"id":"hist_27_12_amzn","sentiment_count":3,"timestamp_date":"2022-01-27T12:00:00.000Z","total":6,"twitter":0,"stocktwits":6,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"amzn","likes":2,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.6556,"AHI":0.7887,"SGP":0,"total_tweet_volume":6},{"id":"hist_27_11_t","sentiment_count":7,"timestamp_date":"2022-01-27T11:00:00.000Z","total":18,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":10,"ticker":"t","likes":1,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.2419,"AHI":1.5161,"SGP":0,"total_tweet_volume":3},{"id":"hist_27_11_amd","sentiment_count":68,"timestamp_date":"2022-01-27T11:00:00.000Z","total":131,"twitter":0,"stocktwits":75,"reddit_comment":0,"reddit_post":0,"yahoo":56,"ticker":"amd","likes":60,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.1039,"AHI":1.1116,"SGP":0,"total_tweet_volume":2}],"start":"2022-01-27T11:00:00.000Z","end":"2022-01-27T12:59:59.999Z","limit":10}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '1964' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 12:44:37 GMT + Etag: + - W/"7ac-qd5HBUoH8qXqlwMmTJslqPErT/Q" + X-Powered-By: + - Express + status: + code: 200 + message: OK version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].yaml new file mode 100644 index 00000000000..ebdd264016c --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/supported?symbol=BTC-USD&token=MOCK_TOKEN + response: + body: + string: '{"error":"symbol \"btc-usd\" is not currently active."}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '55' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 16:22:36 GMT + Etag: + - W/"37-H7l44r2kph8E+3x5mpaNoV/50F8" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC].yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC].yaml new file mode 100644 index 00000000000..b921f228384 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_check_supported_ticker[BTC].yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/supported?symbol=BTC&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"result":true}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '30' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 16:22:36 GMT + Etag: + - W/"1e-67lGrrcaMC/51/8ZvvIFlxBZfJs" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].yaml new file mode 100644 index 00000000000..0bfa9d914f4 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/historical?end=2020-12-7&limit=100&start=2020-12-1&symbol=AAPL&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"start":"2020-12-01T00:00:00.000Z","end":"2020-12-07T00:00:00.000Z","limit":"100","symbol":"AAPL","results":[],"total":0}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '137' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 16:22:37 GMT + Etag: + - W/"89-ae4LkH5VoQJkOubQIH9O3cOMy+U" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml new file mode 100644 index 00000000000..e4adaca68fb --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_model/test_get_trending[start0-9-10].yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/trending?end=2021-12-21+09%3A00%3A00&limit=10&start=2021-12-21+09%3A00%3A00&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"results":[{"id":"hist_21_9_btc.x","sentiment_count":22,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"btc.x","likes":25,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":3.4728,"AHI":3.3006,"SGP":0},{"id":"hist_21_9_amc","sentiment_count":33,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"amc","likes":57,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4931,"AHI":0.5699,"SGP":0},{"id":"hist_21_9_tsla","sentiment_count":19,"timestamp_date":"2021-12-21T09:00:00.000Z","total":33,"twitter":0,"stocktwits":31,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"tsla","likes":30,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4169,"AHI":0.5384,"SGP":1,"sentiment":7.8684},{"id":"hist_21_9_mrna","sentiment_count":11,"timestamp_date":"2021-12-21T09:00:00.000Z","total":15,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":7,"ticker":"mrna","likes":4,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.7673,"AHI":0.6587,"SGP":0},{"id":"hist_21_9_btc","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":12,"twitter":0,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":12,"ticker":"btc","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4879,"AHI":0.4465,"SGP":1,"sentiment":16.9798},{"id":"hist_21_9_aapl","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":10,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.3676,"AHI":0.4111,"SGP":0},{"id":"hist_21_9_lcid","sentiment_count":8,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":9,"reddit_comment":0,"reddit_post":0,"yahoo":1,"ticker":"lcid","likes":23,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4674,"AHI":0.5561,"SGP":0},{"id":"hist_21_9_amd","sentiment_count":6,"timestamp_date":"2021-12-21T09:00:00.000Z","total":9,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"amd","likes":3,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4516,"AHI":0.5424,"SGP":0},{"id":"hist_21_9_nke","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":4,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"nke","likes":1,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.3136,"AHI":2.0879,"SGP":0},{"id":"hist_21_9_t","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":3,"ticker":"t","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4844,"AHI":0.6866,"SGP":0}],"start":"2021-12-21T09:00:00.000Z","end":"2021-12-21T09:00:00.000Z","limit":"10"}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '2986' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 16:22:37 GMT + Etag: + - W/"baa-MWXy163w4MAIoe1ZkpGOeHUUI0M" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_historical.yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_historical.yaml new file mode 100644 index 00000000000..09f9e44c7c6 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_historical.yaml @@ -0,0 +1,66 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/supported?symbol=AAPL&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"result":true}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '30' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 17:41:17 GMT + Etag: + - W/"1e-67lGrrcaMC/51/8ZvvIFlxBZfJs" + X-Powered-By: + - Express + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/historical?end=2021-12-15&limit=100&start=2021-12-12&symbol=AAPL&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"start":"2021-12-12T00:00:00.000Z","end":"2021-12-15T00:00:00.000Z","limit":"100","symbol":"AAPL","results":[{"sentiment_count":70,"timestamp_date":"2021-12-12T00:00:00.000Z","total":131,"twitter":65,"stocktwits":27,"reddit_comment":31,"reddit_post":0,"yahoo":8,"ticker":"aapl","likes":114,"retweets":4,"user_followers":416846,"user_tweet_count":1004982,"RHI":2.8149,"AHI":3.0529,"SGP":0,"id":"hist_12_0_aapl"},{"sentiment_count":27,"timestamp_date":"2021-12-12T01:00:00.000Z","total":112,"twitter":50,"stocktwits":8,"reddit_comment":52,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":4569,"retweets":8,"user_followers":271574,"user_tweet_count":2065248,"RHI":2.4082,"AHI":2.6144,"SGP":0,"id":"hist_12_1_aapl"},{"sentiment_count":29,"timestamp_date":"2021-12-12T02:00:00.000Z","total":70,"twitter":47,"stocktwits":20,"reddit_comment":1,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":115,"retweets":7,"user_followers":360424,"user_tweet_count":1526816,"RHI":2.2945,"AHI":2.496,"SGP":0,"id":"hist_12_2_aapl"},{"sentiment_count":35,"timestamp_date":"2021-12-12T03:00:00.000Z","total":87,"twitter":57,"stocktwits":15,"reddit_comment":11,"reddit_post":0,"yahoo":4,"ticker":"aapl","likes":180,"retweets":6,"user_followers":164075,"user_tweet_count":787884,"RHI":2.1122,"AHI":2.3058,"SGP":0,"id":"hist_12_3_aapl"},{"sentiment_count":24,"timestamp_date":"2021-12-12T04:00:00.000Z","total":64,"twitter":47,"stocktwits":10,"reddit_comment":4,"reddit_post":0,"yahoo":3,"ticker":"aapl","likes":46,"retweets":6,"user_followers":489997,"user_tweet_count":1774718,"RHI":2.0821,"AHI":2.2691,"SGP":0,"id":"hist_12_4_aapl"},{"sentiment_count":17,"timestamp_date":"2021-12-12T05:00:00.000Z","total":85,"twitter":24,"stocktwits":15,"reddit_comment":44,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":474,"retweets":7,"user_followers":395129,"user_tweet_count":1026301,"RHI":1.9097,"AHI":2.0761,"SGP":0,"id":"hist_12_5_aapl"},{"sentiment_count":11,"timestamp_date":"2021-12-12T06:00:00.000Z","total":38,"twitter":16,"stocktwits":8,"reddit_comment":12,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":31,"retweets":1,"user_followers":299276,"user_tweet_count":764484,"RHI":1.7674,"AHI":1.9161,"SGP":0,"id":"hist_12_6_aapl"},{"sentiment_count":19,"timestamp_date":"2021-12-12T07:00:00.000Z","total":33,"twitter":24,"stocktwits":4,"reddit_comment":4,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":7,"retweets":2,"user_followers":263965,"user_tweet_count":2323691,"RHI":1.6779,"AHI":1.8184,"SGP":0,"id":"hist_12_7_aapl"},{"sentiment_count":20,"timestamp_date":"2021-12-12T08:00:00.000Z","total":42,"twitter":34,"stocktwits":2,"reddit_comment":5,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":22,"retweets":3,"user_followers":337934,"user_tweet_count":1980769,"RHI":1.5859,"AHI":1.7262,"SGP":0,"id":"hist_12_8_aapl"},{"sentiment_count":17,"timestamp_date":"2021-12-12T09:00:00.000Z","total":38,"twitter":28,"stocktwits":4,"reddit_comment":5,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":10,"retweets":1,"user_followers":229866,"user_tweet_count":735261,"RHI":1.4951,"AHI":1.6218,"SGP":0,"id":"hist_12_9_aapl"},{"sentiment_count":11,"timestamp_date":"2021-12-12T10:00:00.000Z","total":24,"twitter":14,"stocktwits":4,"reddit_comment":2,"reddit_post":0,"yahoo":4,"ticker":"aapl","likes":2,"retweets":3,"user_followers":26933,"user_tweet_count":147743,"RHI":1.4708,"AHI":1.5965,"SGP":0,"id":"hist_12_10_aapl"},{"sentiment_count":20,"timestamp_date":"2021-12-12T11:00:00.000Z","total":54,"twitter":38,"stocktwits":5,"reddit_comment":0,"reddit_post":0,"yahoo":11,"ticker":"aapl","likes":14,"retweets":4,"user_followers":213002,"user_tweet_count":3460781,"RHI":1.512,"AHI":1.6478,"SGP":0,"id":"hist_12_11_aapl"},{"sentiment_count":26,"timestamp_date":"2021-12-12T12:00:00.000Z","total":94,"twitter":31,"stocktwits":4,"reddit_comment":41,"reddit_post":0,"yahoo":18,"ticker":"aapl","likes":163,"retweets":0,"user_followers":179079,"user_tweet_count":711866,"RHI":1.4849,"AHI":1.6163,"SGP":0,"id":"hist_12_12_aapl"},{"sentiment_count":25,"timestamp_date":"2021-12-12T13:00:00.000Z","total":51,"twitter":41,"stocktwits":2,"reddit_comment":0,"reddit_post":0,"yahoo":8,"ticker":"aapl","likes":23,"retweets":6,"user_followers":305558,"user_tweet_count":1202486,"RHI":1.4797,"AHI":1.6105,"SGP":0,"id":"hist_12_13_aapl"},{"sentiment_count":56,"timestamp_date":"2021-12-12T14:00:00.000Z","total":65,"twitter":28,"stocktwits":0,"reddit_comment":35,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":27,"retweets":1,"user_followers":520682,"user_tweet_count":2128868,"RHI":1.4024,"AHI":1.5214,"SGP":0,"id":"hist_12_14_aapl"},{"sentiment_count":0,"timestamp_date":"2021-12-12T15:00:00.000Z","total":6,"twitter":0,"stocktwits":0,"reddit_comment":6,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":12,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.3459,"AHI":1.4542,"SGP":0,"id":"hist_12_15_aapl"},{"sentiment_count":7,"timestamp_date":"2021-12-12T16:00:00.000Z","total":16,"twitter":16,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":189,"retweets":45,"user_followers":86213,"user_tweet_count":201831,"RHI":1.3276,"AHI":1.4343,"SGP":0,"id":"hist_12_16_aapl"},{"sentiment_count":7,"timestamp_date":"2021-12-12T17:00:00.000Z","total":45,"twitter":12,"stocktwits":0,"reddit_comment":33,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":127,"retweets":31,"user_followers":177097,"user_tweet_count":225463,"RHI":1.2958,"AHI":1.3957,"SGP":0,"id":"hist_12_17_aapl"},{"sentiment_count":13,"timestamp_date":"2021-12-12T18:00:00.000Z","total":30,"twitter":25,"stocktwits":0,"reddit_comment":5,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":240,"retweets":31,"user_followers":372892,"user_tweet_count":570898,"RHI":1.2594,"AHI":1.3519,"SGP":0,"id":"hist_12_18_aapl"},{"sentiment_count":9,"timestamp_date":"2021-12-12T19:00:00.000Z","total":22,"twitter":22,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":119,"retweets":19,"user_followers":587644,"user_tweet_count":2805545,"RHI":1.2265,"AHI":1.3142,"SGP":0,"id":"hist_12_19_aapl"},{"sentiment_count":14,"timestamp_date":"2021-12-12T20:00:00.000Z","total":22,"twitter":22,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":37,"retweets":3,"user_followers":355805,"user_tweet_count":4921581,"RHI":1.2385,"AHI":1.3277,"SGP":0,"id":"hist_12_20_aapl"},{"sentiment_count":57,"timestamp_date":"2021-12-12T21:00:00.000Z","total":69,"twitter":22,"stocktwits":0,"reddit_comment":42,"reddit_post":0,"yahoo":5,"ticker":"aapl","likes":115,"retweets":7,"user_followers":409315,"user_tweet_count":609629,"RHI":1.2768,"AHI":1.3718,"SGP":0,"id":"hist_12_21_aapl"},{"sentiment_count":11,"timestamp_date":"2021-12-12T22:00:00.000Z","total":98,"twitter":25,"stocktwits":0,"reddit_comment":72,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":119,"retweets":18,"user_followers":84843,"user_tweet_count":275099,"RHI":1.2935,"AHI":1.3909,"SGP":0,"id":"hist_12_22_aapl"},{"sentiment_count":16,"timestamp_date":"2021-12-12T23:00:00.000Z","total":80,"twitter":32,"stocktwits":0,"reddit_comment":46,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":388,"retweets":60,"user_followers":626798,"user_tweet_count":437146,"RHI":2.1496,"AHI":2.5603,"SGP":0,"id":"hist_12_23_aapl"},{"sentiment_count":17,"timestamp_date":"2021-12-13T00:00:00.000Z","total":106,"twitter":35,"stocktwits":0,"reddit_comment":70,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":324,"retweets":67,"user_followers":574246,"user_tweet_count":430599,"RHI":2.5097,"AHI":3.0098,"SGP":0,"id":"hist_13_0_aapl"},{"sentiment_count":89,"timestamp_date":"2021-12-13T01:00:00.000Z","total":145,"twitter":60,"stocktwits":39,"reddit_comment":42,"reddit_post":0,"yahoo":4,"ticker":"aapl","likes":490,"retweets":36,"user_followers":405290,"user_tweet_count":809088,"RHI":2.5861,"AHI":3.1161,"SGP":0,"id":"hist_13_1_aapl"},{"sentiment_count":52,"timestamp_date":"2021-12-13T02:00:00.000Z","total":141,"twitter":65,"stocktwits":14,"reddit_comment":53,"reddit_post":0,"yahoo":9,"ticker":"aapl","likes":135,"retweets":10,"user_followers":173672,"user_tweet_count":700879,"RHI":2.4668,"AHI":2.9791,"SGP":0,"id":"hist_13_2_aapl"},{"sentiment_count":62,"timestamp_date":"2021-12-13T03:00:00.000Z","total":110,"twitter":87,"stocktwits":17,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"aapl","likes":69,"retweets":11,"user_followers":168375,"user_tweet_count":1733924,"RHI":2.6701,"AHI":3.2496,"SGP":0,"id":"hist_13_3_aapl"},{"sentiment_count":100,"timestamp_date":"2021-12-13T04:00:00.000Z","total":178,"twitter":78,"stocktwits":36,"reddit_comment":48,"reddit_post":0,"yahoo":16,"ticker":"aapl","likes":214,"retweets":14,"user_followers":528907,"user_tweet_count":4064832,"RHI":3.0553,"AHI":3.7694,"SGP":0,"id":"hist_13_4_aapl"},{"sentiment_count":111,"timestamp_date":"2021-12-13T05:00:00.000Z","total":282,"twitter":67,"stocktwits":30,"reddit_comment":179,"reddit_post":0,"yahoo":6,"ticker":"aapl","likes":124,"retweets":5,"user_followers":1182954,"user_tweet_count":1633919,"RHI":2.7855,"AHI":3.4313,"SGP":0,"id":"hist_13_5_aapl"},{"sentiment_count":26,"timestamp_date":"2021-12-13T06:00:00.000Z","total":63,"twitter":39,"stocktwits":23,"reddit_comment":0,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":54,"retweets":5,"user_followers":58486,"user_tweet_count":2369608,"RHI":2.7106,"AHI":3.3534,"SGP":0,"id":"hist_13_6_aapl"},{"sentiment_count":34,"timestamp_date":"2021-12-13T07:00:00.000Z","total":125,"twitter":49,"stocktwits":19,"reddit_comment":56,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":199,"retweets":3,"user_followers":273344,"user_tweet_count":2690976,"RHI":2.5596,"AHI":3.1514,"SGP":0,"id":"hist_13_7_aapl"},{"sentiment_count":40,"timestamp_date":"2021-12-13T08:00:00.000Z","total":77,"twitter":52,"stocktwits":23,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":59,"retweets":4,"user_followers":199295,"user_tweet_count":1209403,"RHI":2.6284,"AHI":3.264,"SGP":0,"id":"hist_13_8_aapl"},{"sentiment_count":126,"timestamp_date":"2021-12-13T09:00:00.000Z","total":194,"twitter":104,"stocktwits":79,"reddit_comment":6,"reddit_post":0,"yahoo":5,"ticker":"aapl","likes":121,"retweets":3,"user_followers":126806,"user_tweet_count":1186219,"RHI":2.7179,"AHI":3.4034,"SGP":0,"id":"hist_13_9_aapl"},{"sentiment_count":136,"timestamp_date":"2021-12-13T10:00:00.000Z","total":224,"twitter":142,"stocktwits":65,"reddit_comment":0,"reddit_post":0,"yahoo":17,"ticker":"aapl","likes":232,"retweets":26,"user_followers":1024645,"user_tweet_count":10675272,"RHI":2.8008,"AHI":3.5445,"SGP":0,"id":"hist_13_10_aapl"},{"sentiment_count":138,"timestamp_date":"2021-12-13T11:00:00.000Z","total":239,"twitter":115,"stocktwits":67,"reddit_comment":31,"reddit_post":0,"yahoo":26,"ticker":"aapl","likes":216,"retweets":6,"user_followers":954488,"user_tweet_count":8173231,"RHI":3.0055,"AHI":3.8724,"SGP":0,"id":"hist_13_11_aapl"},{"sentiment_count":195,"timestamp_date":"2021-12-13T12:00:00.000Z","total":376,"twitter":189,"stocktwits":144,"reddit_comment":4,"reddit_post":0,"yahoo":39,"ticker":"aapl","likes":7166,"retweets":396,"user_followers":2495997,"user_tweet_count":10936357,"RHI":3.0976,"AHI":4.0375,"SGP":0,"id":"hist_13_12_aapl"},{"sentiment_count":123,"timestamp_date":"2021-12-13T13:00:00.000Z","total":309,"twitter":171,"stocktwits":84,"reddit_comment":19,"reddit_post":0,"yahoo":35,"ticker":"aapl","likes":301,"retweets":36,"user_followers":1473836,"user_tweet_count":4856644,"RHI":3.1959,"AHI":4.2196,"SGP":0,"id":"hist_13_13_aapl"},{"sentiment_count":148,"timestamp_date":"2021-12-13T14:00:00.000Z","total":347,"twitter":194,"stocktwits":87,"reddit_comment":34,"reddit_post":0,"yahoo":32,"ticker":"aapl","likes":267,"retweets":24,"user_followers":2418125,"user_tweet_count":10265186,"RHI":3.4802,"AHI":4.7207,"SGP":0,"id":"hist_13_14_aapl"},{"sentiment_count":291,"timestamp_date":"2021-12-13T15:00:00.000Z","total":652,"twitter":108,"stocktwits":529,"reddit_comment":1,"reddit_post":0,"yahoo":14,"ticker":"aapl","likes":623,"retweets":11,"user_followers":863522,"user_tweet_count":5713649,"RHI":3.425,"AHI":4.6744,"SGP":0,"id":"hist_13_15_aapl"},{"sentiment_count":82,"timestamp_date":"2021-12-13T16:00:00.000Z","total":209,"twitter":175,"stocktwits":6,"reddit_comment":2,"reddit_post":0,"yahoo":26,"ticker":"aapl","likes":303,"retweets":68,"user_followers":2571623,"user_tweet_count":5857019,"RHI":3.3668,"AHI":4.6121,"SGP":0,"id":"hist_13_16_aapl"},{"sentiment_count":98,"timestamp_date":"2021-12-13T17:00:00.000Z","total":198,"twitter":168,"stocktwits":0,"reddit_comment":4,"reddit_post":0,"yahoo":26,"ticker":"aapl","likes":143,"retweets":19,"user_followers":6098082,"user_tweet_count":9408039,"RHI":3.3102,"AHI":4.5518,"SGP":0,"id":"hist_13_17_aapl"},{"sentiment_count":89,"timestamp_date":"2021-12-13T18:00:00.000Z","total":197,"twitter":168,"stocktwits":0,"reddit_comment":6,"reddit_post":0,"yahoo":23,"ticker":"aapl","likes":443,"retweets":82,"user_followers":3492446,"user_tweet_count":7640314,"RHI":3.2703,"AHI":4.5172,"SGP":0,"id":"hist_13_18_aapl"},{"sentiment_count":58,"timestamp_date":"2021-12-13T19:00:00.000Z","total":168,"twitter":124,"stocktwits":0,"reddit_comment":15,"reddit_post":0,"yahoo":29,"ticker":"aapl","likes":117,"retweets":25,"user_followers":1307381,"user_tweet_count":4278075,"RHI":3.1768,"AHI":4.3835,"SGP":0,"id":"hist_13_19_aapl"},{"sentiment_count":52,"timestamp_date":"2021-12-13T20:00:00.000Z","total":99,"twitter":78,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":21,"ticker":"aapl","likes":73,"retweets":6,"user_followers":368329,"user_tweet_count":1365437,"RHI":3.1333,"AHI":4.3374,"SGP":0,"id":"hist_13_20_aapl"},{"sentiment_count":76,"timestamp_date":"2021-12-13T21:00:00.000Z","total":203,"twitter":154,"stocktwits":0,"reddit_comment":8,"reddit_post":0,"yahoo":41,"ticker":"aapl","likes":393,"retweets":51,"user_followers":2153261,"user_tweet_count":6274776,"RHI":3.0917,"AHI":4.2931,"SGP":0,"id":"hist_13_21_aapl"},{"sentiment_count":85,"timestamp_date":"2021-12-13T22:00:00.000Z","total":199,"twitter":147,"stocktwits":28,"reddit_comment":0,"reddit_post":0,"yahoo":24,"ticker":"aapl","likes":271,"retweets":29,"user_followers":1201582,"user_tweet_count":4380430,"RHI":3.0612,"AHI":4.2671,"SGP":0,"id":"hist_13_22_aapl"},{"sentiment_count":112,"timestamp_date":"2021-12-13T23:00:00.000Z","total":246,"twitter":176,"stocktwits":56,"reddit_comment":5,"reddit_post":0,"yahoo":9,"ticker":"aapl","likes":2132,"retweets":430,"user_followers":2676075,"user_tweet_count":7734989,"RHI":1.9726,"AHI":3.0906,"SGP":0,"id":"hist_13_23_aapl"},{"sentiment_count":82,"timestamp_date":"2021-12-14T00:00:00.000Z","total":155,"twitter":148,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":7,"ticker":"aapl","likes":93,"retweets":8,"user_followers":677877,"user_tweet_count":8972209,"RHI":1.7568,"AHI":2.7497,"SGP":0,"id":"hist_14_0_aapl"},{"sentiment_count":67,"timestamp_date":"2021-12-14T01:00:00.000Z","total":122,"twitter":104,"stocktwits":0,"reddit_comment":12,"reddit_post":0,"yahoo":6,"ticker":"aapl","likes":133,"retweets":12,"user_followers":647965,"user_tweet_count":5608914,"RHI":1.6162,"AHI":2.5295,"SGP":0,"id":"hist_14_1_aapl"},{"sentiment_count":52,"timestamp_date":"2021-12-14T02:00:00.000Z","total":106,"twitter":103,"stocktwits":0,"reddit_comment":3,"reddit_post":0,"yahoo":0,"ticker":"aapl","likes":94,"retweets":15,"user_followers":201064,"user_tweet_count":2250019,"RHI":1.5931,"AHI":2.4907,"SGP":0,"id":"hist_14_2_aapl"},{"sentiment_count":54,"timestamp_date":"2021-12-14T03:00:00.000Z","total":122,"twitter":115,"stocktwits":0,"reddit_comment":6,"reddit_post":0,"yahoo":1,"ticker":"aapl","likes":175,"retweets":16,"user_followers":962906,"user_tweet_count":11507427,"RHI":1.4998,"AHI":2.3439,"SGP":0,"id":"hist_14_3_aapl"},{"sentiment_count":41,"timestamp_date":"2021-12-14T04:00:00.000Z","total":90,"twitter":76,"stocktwits":0,"reddit_comment":7,"reddit_post":0,"yahoo":7,"ticker":"aapl","likes":345,"retweets":25,"user_followers":461555,"user_tweet_count":3155075,"RHI":1.4058,"AHI":2.1994,"SGP":0,"id":"hist_14_4_aapl"},{"sentiment_count":35,"timestamp_date":"2021-12-14T05:00:00.000Z","total":77,"twitter":72,"stocktwits":0,"reddit_comment":3,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":24,"retweets":4,"user_followers":167112,"user_tweet_count":3436441,"RHI":1.3468,"AHI":2.1011,"SGP":0,"id":"hist_14_5_aapl"},{"sentiment_count":35,"timestamp_date":"2021-12-14T06:00:00.000Z","total":79,"twitter":77,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":41,"retweets":11,"user_followers":94515,"user_tweet_count":1307835,"RHI":1.8077,"AHI":2.8532,"SGP":0,"id":"hist_14_6_aapl"},{"sentiment_count":411,"timestamp_date":"2021-12-14T07:00:00.000Z","total":430,"twitter":41,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":389,"ticker":"aapl","likes":13,"retweets":1,"user_followers":154801,"user_tweet_count":1001593,"RHI":1.6784,"AHI":2.6327,"SGP":0,"id":"hist_14_7_aapl"},{"sentiment_count":20,"timestamp_date":"2021-12-14T08:00:00.000Z","total":40,"twitter":37,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":3,"ticker":"aapl","likes":5,"retweets":3,"user_followers":252952,"user_tweet_count":4886615,"RHI":1.5961,"AHI":2.5,"SGP":0,"id":"hist_14_8_aapl"},{"sentiment_count":29,"timestamp_date":"2021-12-14T09:00:00.000Z","total":68,"twitter":59,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":9,"ticker":"aapl","likes":89,"retweets":23,"user_followers":497223,"user_tweet_count":1061406,"RHI":1.5374,"AHI":2.4007,"SGP":0,"id":"hist_14_9_aapl"},{"sentiment_count":26,"timestamp_date":"2021-12-14T10:00:00.000Z","total":76,"twitter":70,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"aapl","likes":40,"retweets":10,"user_followers":490011,"user_tweet_count":4711984,"RHI":1.4945,"AHI":2.3276,"SGP":0,"id":"hist_14_10_aapl"},{"sentiment_count":31,"timestamp_date":"2021-12-14T11:00:00.000Z","total":83,"twitter":70,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":13,"ticker":"aapl","likes":360,"retweets":71,"user_followers":1422889,"user_tweet_count":7884677,"RHI":1.4813,"AHI":2.3094,"SGP":0,"id":"hist_14_11_aapl"},{"sentiment_count":49,"timestamp_date":"2021-12-14T12:00:00.000Z","total":113,"twitter":81,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":32,"ticker":"aapl","likes":73,"retweets":15,"user_followers":606925,"user_tweet_count":7920131,"RHI":1.4996,"AHI":2.3432,"SGP":0,"id":"hist_14_12_aapl"},{"sentiment_count":73,"timestamp_date":"2021-12-14T13:00:00.000Z","total":152,"twitter":113,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":39,"ticker":"aapl","likes":111,"retweets":16,"user_followers":507730,"user_tweet_count":2628217,"RHI":1.5316,"AHI":2.398,"SGP":0,"id":"hist_14_13_aapl"},{"sentiment_count":79,"timestamp_date":"2021-12-14T14:00:00.000Z","total":173,"twitter":137,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":36,"ticker":"aapl","likes":118,"retweets":15,"user_followers":868473,"user_tweet_count":8713852,"RHI":1.5496,"AHI":2.4294,"SGP":0,"id":"hist_14_14_aapl"},{"sentiment_count":63,"timestamp_date":"2021-12-14T15:00:00.000Z","total":159,"twitter":123,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":36,"ticker":"aapl","likes":63,"retweets":19,"user_followers":910328,"user_tweet_count":9848060,"RHI":1.5655,"AHI":2.4578,"SGP":0,"id":"hist_14_15_aapl"},{"sentiment_count":80,"timestamp_date":"2021-12-14T16:00:00.000Z","total":161,"twitter":128,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":33,"ticker":"aapl","likes":97,"retweets":10,"user_followers":723817,"user_tweet_count":5534500,"RHI":1.577,"AHI":2.477,"SGP":0,"id":"hist_14_16_aapl"},{"sentiment_count":82,"timestamp_date":"2021-12-14T17:00:00.000Z","total":154,"twitter":120,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":34,"ticker":"aapl","likes":67,"retweets":11,"user_followers":1194756,"user_tweet_count":9863632,"RHI":1.5642,"AHI":2.4593,"SGP":0,"id":"hist_14_17_aapl"},{"sentiment_count":51,"timestamp_date":"2021-12-14T18:00:00.000Z","total":121,"twitter":108,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":13,"ticker":"aapl","likes":243,"retweets":60,"user_followers":2098531,"user_tweet_count":2694265,"RHI":1.5304,"AHI":2.4023,"SGP":0,"id":"hist_14_18_aapl"},{"sentiment_count":36,"timestamp_date":"2021-12-14T19:00:00.000Z","total":80,"twitter":57,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":23,"ticker":"aapl","likes":37,"retweets":4,"user_followers":144463,"user_tweet_count":2323126,"RHI":1.5129,"AHI":2.3701,"SGP":0,"id":"hist_14_19_aapl"},{"sentiment_count":35,"timestamp_date":"2021-12-14T20:00:00.000Z","total":92,"twitter":70,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":22,"ticker":"aapl","likes":101,"retweets":22,"user_followers":290204,"user_tweet_count":3285312,"RHI":1.4925,"AHI":2.3363,"SGP":0,"id":"hist_14_20_aapl"},{"sentiment_count":41,"timestamp_date":"2021-12-14T21:00:00.000Z","total":90,"twitter":84,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"aapl","likes":54,"retweets":12,"user_followers":556655,"user_tweet_count":1886247,"RHI":1.4925,"AHI":2.338,"SGP":0,"id":"hist_14_21_aapl"},{"sentiment_count":54,"timestamp_date":"2021-12-14T22:00:00.000Z","total":135,"twitter":105,"stocktwits":22,"reddit_comment":0,"reddit_post":0,"yahoo":8,"ticker":"aapl","likes":204,"retweets":29,"user_followers":1047154,"user_tweet_count":6719919,"RHI":1.4951,"AHI":2.3448,"SGP":0,"id":"hist_14_22_aapl"},{"sentiment_count":82,"timestamp_date":"2021-12-14T23:00:00.000Z","total":155,"twitter":97,"stocktwits":50,"reddit_comment":0,"reddit_post":0,"yahoo":8,"ticker":"aapl","likes":142,"retweets":6,"user_followers":326294,"user_tweet_count":883481,"RHI":0.685,"AHI":1.1686,"SGP":0,"id":"hist_14_23_aapl"},{"sentiment_count":26,"timestamp_date":"2021-12-15T00:00:00.000Z","total":63,"twitter":35,"stocktwits":4,"reddit_comment":0,"reddit_post":0,"yahoo":24,"ticker":"aapl","likes":29,"retweets":5,"user_followers":248578,"user_tweet_count":788968,"RHI":0.6106,"AHI":1.039,"SGP":0,"id":"hist_15_0_aapl"}],"total":73}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '22139' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 17:41:18 GMT + Etag: + - W/"567b-8kRQ+lYHEzAsFsveR2mbj7qRuho" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_trending.yaml b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_trending.yaml new file mode 100644 index 00000000000..e480bf87232 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/cassettes/test_sentimentinvestor_view/test_display_trending.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.sentimentinvestor.com/v1/trending?end=2021-12-21+09%3A00%3A00&limit=10&start=2021-12-21+09%3A00%3A00&token=MOCK_TOKEN + response: + body: + string: '{"success":true,"results":[{"id":"hist_21_9_btc.x","sentiment_count":22,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"btc.x","likes":25,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":3.4728,"AHI":3.3006,"SGP":0},{"id":"hist_21_9_amc","sentiment_count":33,"timestamp_date":"2021-12-21T09:00:00.000Z","total":40,"twitter":0,"stocktwits":40,"reddit_comment":0,"reddit_post":0,"yahoo":0,"ticker":"amc","likes":57,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4931,"AHI":0.5699,"SGP":0},{"id":"hist_21_9_tsla","sentiment_count":19,"timestamp_date":"2021-12-21T09:00:00.000Z","total":33,"twitter":0,"stocktwits":31,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"tsla","likes":30,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4169,"AHI":0.5384,"SGP":1,"sentiment":7.8684},{"id":"hist_21_9_mrna","sentiment_count":11,"timestamp_date":"2021-12-21T09:00:00.000Z","total":15,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":7,"ticker":"mrna","likes":4,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.7673,"AHI":0.6587,"SGP":0},{"id":"hist_21_9_btc","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":12,"twitter":0,"stocktwits":0,"reddit_comment":0,"reddit_post":0,"yahoo":12,"ticker":"btc","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4879,"AHI":0.4465,"SGP":1,"sentiment":16.9798},{"id":"hist_21_9_aapl","sentiment_count":9,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":8,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"aapl","likes":10,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.3676,"AHI":0.4111,"SGP":0},{"id":"hist_21_9_lcid","sentiment_count":8,"timestamp_date":"2021-12-21T09:00:00.000Z","total":10,"twitter":0,"stocktwits":9,"reddit_comment":0,"reddit_post":0,"yahoo":1,"ticker":"lcid","likes":23,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4674,"AHI":0.5561,"SGP":0},{"id":"hist_21_9_amd","sentiment_count":6,"timestamp_date":"2021-12-21T09:00:00.000Z","total":9,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":6,"ticker":"amd","likes":3,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4516,"AHI":0.5424,"SGP":0},{"id":"hist_21_9_nke","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":4,"reddit_comment":0,"reddit_post":0,"yahoo":2,"ticker":"nke","likes":1,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":1.3136,"AHI":2.0879,"SGP":0},{"id":"hist_21_9_t","sentiment_count":4,"timestamp_date":"2021-12-21T09:00:00.000Z","total":6,"twitter":0,"stocktwits":3,"reddit_comment":0,"reddit_post":0,"yahoo":3,"ticker":"t","likes":0,"retweets":0,"user_followers":0,"user_tweet_count":0,"RHI":0.4844,"AHI":0.6866,"SGP":0}],"start":"2021-12-21T09:00:00.000Z","end":"2021-12-21T09:00:00.000Z","limit":"10"}' + headers: + Access-Control-Allow-Origin: + - '*' + Content-Length: + - '2986' + Content-Type: + - application/json; charset=utf-8 + Date: + - Thu, 27 Jan 2022 17:41:19 GMT + Etag: + - W/"baa-MWXy163w4MAIoe1ZkpGOeHUUI0M" + X-Powered-By: + - Express + status: + code: 200 + message: OK +version: 1 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].csv b/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].csv new file mode 100644 index 00000000000..e16c76dff88 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_historical[AAPL-2020-12-1-2020-12-7-100].csv @@ -0,0 +1 @@ +"" diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[start0-9-10].csv b/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[start0-9-10].csv new file mode 100644 index 00000000000..c92dfb35c02 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/csv/test_sentimentinvestor_model/test_get_trending[start0-9-10].csv @@ -0,0 +1,11 @@ +,id,sentiment_count,timestamp_date,total,twitter,stocktwits,reddit_comment,reddit_post,yahoo,ticker,likes,retweets,user_followers,user_tweet_count,RHI,AHI,SGP,sentiment +0,hist_21_9_btc.x,22,2021-12-21T09:00:00.000Z,40,0,40,0,0,0,btc.x,25,0,0,0,3.4728,3.3006,0, +1,hist_21_9_amc,33,2021-12-21T09:00:00.000Z,40,0,40,0,0,0,amc,57,0,0,0,0.4931,0.5699,0, +2,hist_21_9_tsla,19,2021-12-21T09:00:00.000Z,33,0,31,0,0,2,tsla,30,0,0,0,0.4169,0.5384,1,7.8684 +3,hist_21_9_mrna,11,2021-12-21T09:00:00.000Z,15,0,8,0,0,7,mrna,4,0,0,0,0.7673,0.6587,0, +4,hist_21_9_btc,9,2021-12-21T09:00:00.000Z,12,0,0,0,0,12,btc,0,0,0,0,0.4879,0.4465,1,16.9798 +5,hist_21_9_aapl,9,2021-12-21T09:00:00.000Z,10,0,8,0,0,2,aapl,10,0,0,0,0.3676,0.4111,0, +6,hist_21_9_lcid,8,2021-12-21T09:00:00.000Z,10,0,9,0,0,1,lcid,23,0,0,0,0.4674,0.5561,0, +7,hist_21_9_amd,6,2021-12-21T09:00:00.000Z,9,0,3,0,0,6,amd,3,0,0,0,0.4516,0.5424,0, +8,hist_21_9_nke,4,2021-12-21T09:00:00.000Z,6,0,4,0,0,2,nke,1,0,0,0,1.3136,2.0879,0, +9,hist_21_9_t,4,2021-12-21T09:00:00.000Z,6,0,3,0,0,3,t,0,0,0,0,0.4844,0.6866,0, diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].json b/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].json new file mode 100644 index 00000000000..02e4a84d62c --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC-USD].json @@ -0,0 +1 @@ +false \ No newline at end of file diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC].json b/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC].json new file mode 100644 index 00000000000..f32a5804e29 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/json/test_sentimentinvestor_model/test_check_supported_ticker[BTC].json @@ -0,0 +1 @@ +true \ No newline at end of file diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py b/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py new file mode 100644 index 00000000000..b6ccf008c8b --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_model.py @@ -0,0 +1,47 @@ +from datetime import datetime + +import pytest + +from gamestonk_terminal.common.behavioural_analysis import sentimentinvestor_model + + +@pytest.fixture(scope="module") +def vcr_config(): + return { + "filter_query_parameters": [ + ("token", "MOCK_TOKEN"), + ], + } + + +@pytest.mark.vcr +@pytest.mark.parametrize( + "ticker", + [ + ("BTC"), + ("BTC-USD"), + ], +) +def test_check_supported_ticker(ticker, recorder): + df = sentimentinvestor_model.check_supported_ticker(ticker) + recorder.capture(df) + + +@pytest.mark.vcr +@pytest.mark.parametrize( + "ticker, start, end, number", + [("AAPL", "2020-12-1", "2020-12-7", 100)], +) +def test_get_historical(ticker, start, end, number, recorder): + df = sentimentinvestor_model.get_historical(ticker, start, end, number) + recorder.capture(df) + + +@pytest.mark.vcr +@pytest.mark.parametrize( + "start, hour, number", + [(datetime(2021, 12, 21), 9, 10)], +) +def test_get_trending(start, hour, number, recorder): + df = sentimentinvestor_model.get_trending(start, hour, number) + recorder.capture(df) diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py b/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py new file mode 100644 index 00000000000..3332f84ea29 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/test_sentimentinvestor_view.py @@ -0,0 +1,42 @@ +from datetime import datetime +import pytest + +from gamestonk_terminal.common.behavioural_analysis import sentimentinvestor_view + + +@pytest.fixture(scope="module") +def vcr_config(): + return { + "filter_query_parameters": [ + ("token", "MOCK_TOKEN"), + ], + } + + +@pytest.mark.vcr +@pytest.mark.record_stdout +def test_display_historical(mocker): + mocker.patch.object( + target=sentimentinvestor_view.gtff, attribute="USE_ION", new=True + ) + mocker.patch( + target="gamestonk_terminal.common.behavioural_analysis.sentimentinvestor_view.plt.ion" + ) + mocker.patch( + target="gamestonk_terminal.common.behavioural_analysis.sentimentinvestor_view.plt.show" + ) + sentimentinvestor_view.display_historical( + ticker="AAPL", start="2021-12-12", end="2021-12-15", export="", raw=True + ) + + +@pytest.mark.vcr +@pytest.mark.record_stdout +def test_display_trending(): + sentimentinvestor_view.display_trending( + start=datetime(2021, 12, 21), + hour=9, + number=10, + limit=10, + export="", + ) diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_historical.txt b/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_historical.txt new file mode 100644 index 00000000000..5c295e57622 --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_historical.txt @@ -0,0 +1,12 @@ + twitter stocktwits yahoo likes RHI AHI +Time +2021-12-12 00:00 65 27 8 114 2.8149 3.0529 +2021-12-12 01:00 50 8 2 4569 2.4082 2.6144 +2021-12-12 02:00 47 20 2 115 2.2945 2.4960 +2021-12-12 03:00 57 15 4 180 2.1122 2.3058 +2021-12-12 04:00 47 10 3 46 2.0821 2.2691 +2021-12-12 05:00 24 15 2 474 1.9097 2.0761 +2021-12-12 06:00 16 8 2 31 1.7674 1.9161 +2021-12-12 07:00 24 4 1 7 1.6779 1.8184 +2021-12-12 08:00 34 2 1 22 1.5859 1.7262 +2021-12-12 09:00 28 4 1 10 1.4951 1.6218 diff --git a/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_trending.txt b/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_trending.txt new file mode 100644 index 00000000000..a83baaa4d7a --- /dev/null +++ b/tests/gamestonk_terminal/common/behavioural_analysis/txt/test_sentimentinvestor_view/test_display_trending.txt @@ -0,0 +1,12 @@ + total twitter stocktwits yahoo likes RHI AHI +ticker +BTC.X 40 0 40 0 25 3.4728 3.3006 +AMC 40 0 40 0 57 0.4931 0.5699 +TSLA 33 0 31 2 30 0.4169 0.5384 +MRNA 15 0 8 7 4 0.7673 0.6587 +BTC 12 0 0 12 0 0.4879 0.4465 +AAPL 10 0 8 2 10 0.3676 0.4111 +LCID 10 0 9 1 23 0.4674 0.5561 +AMD 9 0 3 6 3 0.4516 0.5424 +NKE 6 0 4 2 1 1.3136 2.0879 +T 6 0 3 3 0 0.4844 0.6866 diff --git a/tests/gamestonk_terminal/stocks/behavioural_analysis/test_ba_controller.py b/tests/gamestonk_terminal/stocks/behavioural_analysis/test_ba_controller.py index ccc3b37e82b..b3d005f1d21 100644 --- a/tests/gamestonk_terminal/stocks/behavioural_analysis/test_ba_controller.py +++ b/tests/gamestonk_terminal/stocks/behavioural_analysis/test_ba_controller.py @@ -421,6 +421,23 @@ def test_call_func_expect_queue(expected_queue, queue, func): limit=10, ), ), + ( + "call_trend", + [ + "--start=2020-12-01", + "--hour=9", + "--export=csv", + "--number=20", + ], + "sentimentinvestor_view.display_trending", + [], + dict( + start=datetime(2020, 12, 1), + hour=9, + export="csv", + number=20, + ), + ), ( "call_popular", ["--num=1", "--limit=2", "--sub=MOCK_SUB"], @@ -500,6 +517,7 @@ def test_call_func( "call_headlines", "call_stats", "call_hist", + "call_trend", "call_popular", "call_getdd", ], diff --git a/tests/gamestonk_terminal/stocks/behavioural_analysis/txt/test_ba_controller/test_print_help.txt b/tests/gamestonk_terminal/stocks/behavioural_analysis/txt/test_ba_controller/test_print_help.txt index a9ae5a98bce..08017b4384e 100644 --- a/tests/gamestonk_terminal/stocks/behavioural_analysis/txt/test_ba_controller/test_print_help.txt +++ b/tests/gamestonk_terminal/stocks/behavioural_analysis/txt/test_ba_controller/test_print_help.txt @@ -28,4 +28,5 @@ Ticker: TSLA queries top related queries with this stock rise top rising related queries with stock [SentimentInvestor] + trend most talked about tickers within the last hour hist plot historical RHI and AHI data by hour diff --git a/website/content/common/behavioural_analysis/emerging/_index.md b/website/content/common/behavioural_analysis/emerging/_index.md deleted file mode 100755 index 242452f1bf3..00000000000 --- a/website/content/common/behavioural_analysis/emerging/_index.md +++ /dev/null @@ -1,40 +0,0 @@ -``` -usage: emerging [-l LIMIT] [-h] -``` - -The emerging command prints the stocks with highest Relative Hype Index right now. - -RHI (Relative Hype Index) ---- -RHI is a measure of whether people are talking about a stock more or less than -usual, calculated by dividing the mean AHI for the past day by the mean AHI for -for the past week for that stock. - -=== - -Sentiment Investor analyzes data from four major social media platforms to -generate hourly metrics on over 2,000 stocks. Sentiment provides volume and -sentiment metrics powered by proprietary NLP models. - -``` -optional arguments: - -l LIMIT, --limit LIMIT - the maximum number of stocks to retrieve - -h, --help show this help message - ``` - - ``` - (✨) (stocks)>(ba)> emerging - Rank Ticker RHI ------- -------- ----- - 1 FINV 6.432 - 2 GOVX 6.282 - 3 JZXN 5.368 - 4 GOGO 5.311 - 5 GWW 4.993 - 6 SHW 4.937 - 7 EYES 4.772 - 8 FSD 4.387 - 9 NUAN 4.019 - 10 JNUG 3.970 - ``` diff --git a/website/content/common/behavioural_analysis/hist/_index.md b/website/content/common/behavioural_analysis/hist/_index.md new file mode 100755 index 00000000000..860c0658f6a --- /dev/null +++ b/website/content/common/behavioural_analysis/hist/_index.md @@ -0,0 +1,38 @@ +``` +usage: hist [-s START] [-e END] [-n NUMBER] [-h] [--export {csv,json,xlsx,png,jpg,pdf,svg}] [--raw] [-l LIMIT] +``` + +Plot historical sentiment data of RHI and AHI by hour. Source: [Sentiment Investor] + +AHI (Absolute Hype Index) +--- +AHI is a measure of how much people are talking about a stock on social media. +It is calculated by dividing the total number of mentions for the chosen stock on a social network by the mean number of mentions any stock receives on that social medium. + +RHI (Relative Hype Index) +--- +RHI is a measure of whether people are talking about a stock more or less than usual, calculated by dividing the mean AHI for the past day by the mean AHI for for the past week for that stock. + + +``` +optional arguments: + -s START, --start START + The starting date (format YYYY-MM-DD) of the stock. Default: 7 days ago (default: 2022-01-19) + -e END, --end END The ending date (format YYYY-MM-DD) of the stock. Default: today (default: 2022-01-26) + -n NUMBER, --number NUMBER + Number of results returned from Sentiment Investor. Default: 100 (default: 100) + -h, --help show this help message (default: False) + --export {csv,json,xlsx,png,jpg,pdf,svg} + Export raw data into csv, json, xlsx and figure into png, jpg, pdf, svg (default: ) + --raw Flag to display raw data (default: False) + -l LIMIT, --limit LIMIT + Number of entries to show in data. (default: 10) +``` +**Plot** + +![image](https://user-images.githubusercontent.com/40023817/151354884-e62ddfa9-3eed-44a2-91cb-4219b2fca245.png) + +**Raw Data** + +![image](https://user-images.githubusercontent.com/40023817/151355175-0a11f78d-5e62-451b-9dc6-37e04f084a6f.png) + diff --git a/website/content/common/behavioural_analysis/historical/_index.md b/website/content/common/behavioural_analysis/historical/_index.md deleted file mode 100755 index 9390e43136a..00000000000 --- a/website/content/common/behavioural_analysis/historical/_index.md +++ /dev/null @@ -1,42 +0,0 @@ -``` -usage: historical [-s [{date,value}]] [-d [{asc,desc}]] [-h] [{sentiment,AHI,RHI,SGP}] -``` - -Sentiment Investor analyzes data from four major social media platforms to generate hourly metrics on over 2,000 stocks. Sentiment provides volume and sentiment metrics powered by proprietary NLP models. - -The historical command plots the past week of data for a selected metric, one of: - -AHI (Absolute Hype Index) ---- -AHI is a measure of how much people are talking about a stock on social media. -It is calculated by dividing the total number of mentions for the chosen stock on a social network by the mean number of mentions any stock receives on that social medium. - -RHI (Relative Hype Index) ---- -RHI is a measure of whether people are talking about a stock more or less than usual, calculated by dividing the mean AHI for the past day by the mean AHI for for the past week for that stock. - -Sentiment Score ---- -Sentiment score is the percentage of people talking positively about the stock. -For each social network the number of positive posts/comments is divided by the total number of both positive and negative posts/comments. - -SGP (Standard General Perception) ---- -SGP is a measure of whether people are more or less positive about a stock than usual. It is calculated by averaging the past day of sentiment values and then dividing it by the average of the past week of sentiment values. - -``` -positional arguments: - {sentiment,AHI,RHI,SGP} - the metric to plot - -optional arguments: - -s [{date,value}], --sort [{date,value}] - the parameter to sort output table by - -d [{asc,desc}], --direction [{asc,desc}] - the direction to sort the output table - -h, --help show this help message -``` - -Captura de ecrã 2021-08-06, às 22 00 22 - -![sentiment_score](https://user-images.githubusercontent.com/25267873/128570642-b40df4d1-e95e-4e7e-846c-9f38d34c75cd.png) diff --git a/website/content/common/behavioural_analysis/metrics/_index.md b/website/content/common/behavioural_analysis/metrics/_index.md deleted file mode 100755 index 383114c1e48..00000000000 --- a/website/content/common/behavioural_analysis/metrics/_index.md +++ /dev/null @@ -1,41 +0,0 @@ -``` -usage: metrics [-h] -``` - -Sentiment Investor analyzes data from four major social media platforms to -generate hourly metrics on over 2,000 stocks. Sentiment provides volume and -sentiment metrics powered by proprietary NLP models. - -The metrics command prints the following realtime metrics: - -AHI (Absolute Hype Index) ---- -AHI is a measure of how much people are talking about a stock on social media. -It is calculated by dividing the total number of mentions for the chosen stock -on a social network by the mean number of mentions any stock receives on that -social medium. - -RHI (Relative Hype Index) ---- -RHI is a measure of whether people are talking about a stock more or less than -usual, calculated by dividing the mean AHI for the past day by the mean AHI for -for the past week for that stock. - -Sentiment Score ---- -Sentiment score is the percentage of people talking positively about the stock. -For each social network the number of positive posts/comments is divided by the -total number of both positive and negative posts/comments. - -SGP (Standard General Perception) ---- -SGP is a measure of whether people are more or less positive about a stock than -usual. It is calculated by averaging the past day of sentiment values and then -dividing it by the average of the past week of sentiment values. - -``` -optional arguments: - -h, --help show this help message -``` - -Captura de ecrã 2021-08-06, às 22 00 05 diff --git a/website/content/common/behavioural_analysis/popularsi/_index.md b/website/content/common/behavioural_analysis/popularsi/_index.md deleted file mode 100755 index 9502a32245b..00000000000 --- a/website/content/common/behavioural_analysis/popularsi/_index.md +++ /dev/null @@ -1,35 +0,0 @@ -``` -usage: popularsi [-l LIMIT] [-h] -``` - -The stocks with highest Average Hype Index right now. - -AHI (Absolute Hype Index) ---- -AHI is a measure of how much people are talking about a stock on social media. -It is calculated by dividing the total number of mentions for the chosen stock on a social network by the mean number of mentions any stock receives on that social medium. - -Sentiment Investor analyzes data from four major social media platforms to generate hourly metrics on over 2,000 stocks. Sentiment provides volume and -sentiment metrics powered by proprietary NLP models. - -``` -optional arguments: - -l LIMIT, --limit LIMIT - the maximum number of stocks to retrieve - -h, --help show this help message -``` -Sample output: -``` -(✨) (stocks)>(ba)> popularsi - Rank Ticker AHI ------- -------- ----- - 1 AMC 4.514 - 2 TSLA 4.184 - 3 BTC 4.045 - 4 SPY 3.890 - 5 WISH 3.175 - 6 NAKD 2.220 - 7 SOFI 2.153 - 8 SAND 1.813 - 9 AMD 1.628 - 10 MMAT 1.617 diff --git a/website/content/common/behavioural_analysis/social/_index.md b/website/content/common/behavioural_analysis/social/_index.md deleted file mode 100755 index 25deb23d830..00000000000 --- a/website/content/common/behavioural_analysis/social/_index.md +++ /dev/null @@ -1,14 +0,0 @@ -``` -usage: social [-h] -``` - -Sentiment Investor analyzes data from four major social media platforms to generate hourly metrics on over 2,000 stocks. Sentiment provides volume and sentiment metrics powered by proprietary NLP models. - -The social command prints the raw data for a given stock, including the number of mentions it has received on social media in the last hour and the sentiment score of those comments. - -``` -optional arguments: - -h, --help show this help message -``` - -Captura de ecrã 2021-08-06, às 22 00 15 diff --git a/website/content/common/behavioural_analysis/trend/_index.md b/website/content/common/behavioural_analysis/trend/_index.md new file mode 100755 index 00000000000..528abf23b03 --- /dev/null +++ b/website/content/common/behavioural_analysis/trend/_index.md @@ -0,0 +1,22 @@ +``` +usage: trend [-s START] [-hr HOUR] [-n NUMBER] [-h] [--export {csv,json,xlsx}] [-l LIMIT] + +``` + +Show most talked about tickers within the last one hour. Source: [Sentiment Investor] + +``` +optional arguments: + -s START, --start START + The starting date (format YYYY-MM-DD). Default: Today (default: 2022-01-26) + -hr HOUR, --hour HOUR + Hour of the day in the 24-hour notation. Example: 14 (default: 0) + -n NUMBER, --number NUMBER + Number of results returned from Sentiment Investor. (default: 10) + -h, --help show this help message (default: False) + --export {csv,json,xlsx} + Export raw data into csv, json, xlsx (default: ) + -l LIMIT, --limit LIMIT + Number of entries to show in data. (default: 10) +``` +![image](https://user-images.githubusercontent.com/40023817/151354698-dc5eb7ab-46c4-4c98-882b-2c9607659b7d.png) diff --git a/website/data/menu/main.yml b/website/data/menu/main.yml index 6559a1e8ec3..0839bd45d73 100755 --- a/website/data/menu/main.yml +++ b/website/data/menu/main.yml @@ -544,16 +544,10 @@ main: ref: "/common/behavioural_analysis/queries" - name: rise ref: "/common/behavioural_analysis/rise" - - name: popularsi - ref: "/common/behavioural_analysis/popularsi" - - name: emerging - ref: "/common/behavioural_analysis/emerging" - - name: metrics - ref: "/common/behavioural_analysis/metrics" - - name: social - ref: "/common/behavioural_analysis/social" - - name: historical - ref: "/common/behavioural_analysis/historical" + - name: hist + ref: "/common/behavioural_analysis/hist" + - name: trend + ref: "/common/behavioural_analysis/trend" - name: quantitative analysis ref: "/common/quantitative_analysis" sub: @@ -1255,4 +1249,4 @@ main: - name: "shortdata" ref: "jupyter/dashboards/shortdata" - name: "reports" - ref: "/jupyter/reports" \ No newline at end of file + ref: "/jupyter/reports"