Skip to content

Commit

Permalink
#2212 Removed hist and trend comamnds from /stocks/ba (#2284)
Browse files Browse the repository at this point in the history
* Removed hist and trend comamnds from /stocks/ba

* Removed trend and hist command from /stocks/ba help menu

* Fixed whitespace issue

* Fixed test_print_help for ba controller

* Fixed pylint issues

* fix test

Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com>
Co-authored-by: Ravioli Spy <raviolispy@users.noreply.github.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: colin99d <colin99delahunty@gmail.com>
  • Loading branch information
5 people authored Sep 17, 2022
1 parent 9ab533d commit 3964705
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 158 deletions.
18 changes: 9 additions & 9 deletions openbb_terminal/reports/equity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"\n",
"from IPython.display import HTML\n",
"\n",
"#import sys\n",
"#sys.path.append('../../')\n",
"# import sys\n",
"# sys.path.append('../../')\n",
"\n",
"from openbb_terminal import api as openbb\n",
"from openbb_terminal.helper_classes import TerminalStyle\n",
Expand Down Expand Up @@ -347,15 +347,15 @@
" while df_ratings.empty:\n",
" days += 30\n",
" df_ratings = df[datetime.datetime.now() - datetime.timedelta(days=days) :]\n",
" \n",
"\n",
" if days > 100:\n",
" break\n",
" \n",
"\n",
" if not df_ratings.empty:\n",
" avg_ratings = round(np.mean(df_ratings[\"Price Target\"].values), 2)\n",
" else:\n",
" avg_ratings = 0\n",
" \n",
"\n",
"last_price = round(ticker_data[\"Close\"][-1], 2)"
]
},
Expand Down Expand Up @@ -530,7 +530,9 @@
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(11, 3), dpi=150)\n",
"openbb.stocks.qa.bw(ticker_data_all, \"Returns\", symbol, yearly=False, external_axes=[ax])\n",
"openbb.stocks.qa.bw(\n",
" ticker_data_all, \"Returns\", symbol, yearly=False, external_axes=[ax]\n",
")\n",
"fig.tight_layout()\n",
"f = io.BytesIO()\n",
"fig.savefig(f, format=\"svg\")\n",
Expand Down Expand Up @@ -776,9 +778,7 @@
"body += openbb.widgets.tab_clickable_and_save_evt()\n",
"\n",
"report = openbb.widgets.html_report(\n",
" title=report_name, \n",
" stylesheet=openbb.widgets.html_report_stylesheet(), \n",
" body=body\n",
" title=report_name, stylesheet=openbb.widgets.html_report_stylesheet(), body=body\n",
")\n",
"\n",
"# to save the results\n",
Expand Down
107 changes: 0 additions & 107 deletions openbb_terminal/stocks/behavioural_analysis/ba_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
finbrain_view,
google_view,
reddit_view,
sentimentinvestor_view,
stocktwits_view,
twitter_view,
)
Expand All @@ -26,7 +25,6 @@
check_int_range,
check_positive,
valid_date,
valid_hour,
)
from openbb_terminal.menu import session
from openbb_terminal.parent_classes import StockBaseController
Expand Down Expand Up @@ -62,8 +60,6 @@ class BehaviouralAnalysisController(StockBaseController):
"headlines",
"popular",
"getdd",
"hist",
"trend",
"snews",
"jcdr",
"jctr",
Expand Down Expand Up @@ -858,109 +854,6 @@ def call_headlines(self, other_args: List[str]):
else:
console.print("No ticker loaded. Please load using 'load <ticker>'\n")

@log_start_end(log=logger)
def call_hist(self, other_args: List[str]):
"""Process hist command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="hist",
description="Plot historical sentiment data of RHI and AHI by hour",
)
parser.add_argument(
"-s",
"--start",
type=valid_date,
default=(datetime.utcnow() - timedelta(days=7)).strftime("%Y-%m-%d"),
dest="start",
required="--end" in other_args,
help="The starting date (format YYYY-MM-DD) of the stock. Default: 7 days ago",
)

parser.add_argument(
"-e",
"--end",
type=valid_date,
default=datetime.utcnow().strftime("%Y-%m-%d"),
dest="end",
required="--start" in other_args,
help="The ending date (format YYYY-MM-DD) of the stock. Default: today",
)
parser.add_argument(
"-n",
"--number",
default=100,
type=check_positive,
dest="number",
help="Number of results returned from Sentiment Investor. Default: 100",
)
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True, limit=10
)

if ns_parser:
if self.ticker:
sentimentinvestor_view.display_historical(
symbol=self.ticker,
start_date=ns_parser.start,
end_date=ns_parser.end,
number=ns_parser.number,
export=ns_parser.export,
raw=ns_parser.raw,
limit=ns_parser.limit,
)
else:
console.print("No ticker loaded. Please load using 'load <ticker>'\n")

@log_start_end(log=logger)
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 = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED, limit=10
)

if ns_parser:
sentimentinvestor_view.display_trending(
start_date=ns_parser.start,
hour=ns_parser.hour,
export=ns_parser.export,
number=ns_parser.number,
)

@log_start_end(log=logger)
def call_jcdr(self, other_args: List[str]):
"""Process jcdr command"""
parser = argparse.ArgumentParser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,45 +391,6 @@ def test_call_func_expect_queue(expected_queue, queue, func):
export="csv",
),
),
(
"call_hist",
[
"--start=2020-12-01",
"--end=2020-12-07",
"--export=csv",
"--number=100",
"--raw",
"--limit=10",
],
"sentimentinvestor_view.display_historical",
[],
dict(
symbol="MOCK_TICKER",
start_date=datetime(2020, 12, 1),
end_date=datetime(2020, 12, 7),
number=100,
export="csv",
raw=True,
limit=10,
),
),
(
"call_trend",
[
"--start=2020-12-01",
"--hour=9",
"--export=csv",
"--number=20",
],
"sentimentinvestor_view.display_trending",
[],
dict(
start_date=datetime(2020, 12, 1),
hour=9,
export="csv",
number=20,
),
),
(
"call_popular",
["--num=1", "--limit=2", "--sub=MOCK_SUB"],
Expand Down Expand Up @@ -508,8 +469,6 @@ def test_call_func(
"call_rise",
"call_headlines",
"call_snews",
"call_hist",
"call_trend",
"call_popular",
"call_getdd",
],
Expand All @@ -535,7 +494,6 @@ def test_call_func_no_parser(func, mocker):
@pytest.mark.parametrize(
"func",
[
"call_hist",
"call_headlines",
"call_sentiment",
"call_infer",
Expand Down

0 comments on commit 3964705

Please sign in to comment.