Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix/ /stocks/fa/pt show all price targets on hover #5305

Merged
merged 4 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def print_rich_table(
print_to_console: bool = False,
limit: Optional[int] = 1000,
source: Optional[str] = None,
columns_keep_types: Optional[List[str]] = None,
):
"""Prepare a table from df in rich.

Expand Down Expand Up @@ -313,6 +314,8 @@ def print_rich_table(
console.
source: Optional[str]
Source of the table. If provided, it will be displayed in the header of the table.
columns_keep_types: Optional[List[str]]
Columns to keep their types, i.e. not convert to numeric
"""
if export:
return
Expand All @@ -329,6 +332,8 @@ def print_rich_table(
# convert non-str that are not timestamp or int into str
# eg) praw.models.reddit.subreddit.Subreddit
for col in df.columns:
if columns_keep_types is not None and col in columns_keep_types:
continue
try:
if not any(
isinstance(df[col].iloc[x], pd.Timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,17 @@ def adjust_splits(row, splits: pd.DataFrame):
name="Price Target",
mode="markers",
customdata=df_analyst_plot.apply(
lambda row: f"{row['Company']} ({row['Rating']})", axis=1
).values,
hovertemplate="%{customdata}<br><br>Price Target: %{y:.2f}",
lambda row: "<br>".join(
[
f"<b>${x['Price Target']}</b> - <b>{x['Company']} ({x['Rating']})</b>"
for _, x in df_analyst_plot[df_analyst_plot.index == row.name]
.sort_values(by="Price Target", ascending=False)
.iterrows()
]
),
axis=1,
),
hovertemplate="<br>%{customdata}",
marker=dict(
color=colors,
line=dict(width=1, color="DarkSlateGrey"),
Expand All @@ -183,6 +191,8 @@ def adjust_splits(row, splits: pd.DataFrame):
line=dict(color=theme.get_colors()[1]),
)

fig.update_layout(hovermode="x unified")

export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
Expand Down