Allow Custom Flairs (#1249)

* Added ability for custom flair

* Refactored for easier use

* Renamed

* Renamed 2
This commit is contained in:
Colin Delahunty
2022-01-23 17:48:21 -05:00
committed by GitHub
parent b9f7b09dcd
commit 183e10b524
34 changed files with 128 additions and 129 deletions

4
CONTRIBUTING.md vendored
View File

@@ -196,7 +196,7 @@ __docformat__ = "numpy"
import os
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.dark_pool_shorts import yahoofinance_model
@@ -217,7 +217,7 @@ def display_most_shorted(num_stocks: int, export: str):
if df.empty:
console.print("No data found.")
else:
rich_table_from_df(
print_rich_table(
df.head(num_stocks),
headers=list(df.columns),
show_index=False,

View File

@@ -14,7 +14,7 @@ from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal.helper_funcs import (
plot_autoscale,
export_data,
rich_table_from_df,
print_rich_table,
)
@@ -68,7 +68,7 @@ def display_covid_ov(
if raw:
ov.index = [x.strftime("%Y-%m-%d") for x in ov.index]
rich_table_from_df(
print_rich_table(
ov.tail(limit),
headers=[x.title() for x in ov.columns],
show_index=True,
@@ -137,7 +137,7 @@ def display_covid_stat(
if raw:
data.index = [x.strftime("%Y-%m-%d") for x in data.index]
rich_table_from_df(
print_rich_table(
data.tail(limit),
headers=[stat.title()],
show_index=True,
@@ -175,7 +175,7 @@ def display_country_slopes(
hist_slope = covid_model.get_case_slopes(days_back, threshold).sort_values(
by="Slope", ascending=ascend
)
rich_table_from_df(
print_rich_table(
hist_slope.head(limit),
show_index=True,
index_name="Country",

View File

@@ -10,7 +10,7 @@ import numpy as np
from gamestonk_terminal.helper_funcs import (
plot_autoscale,
export_data,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.common.behavioural_analysis import finbrain_model
from gamestonk_terminal.config_plot import PLOT_DPI
@@ -111,7 +111,7 @@ def display_sentiment_analysis(ticker: str, export: str = ""):
data=color_df.values,
index=pd.to_datetime(df_sentiment.index).strftime("%Y-%m-%d"),
)
rich_table_from_df(
print_rich_table(
color_df,
headers=["Sentiment"],
title="FinBrain Ticker Sentiment",
@@ -121,7 +121,7 @@ def display_sentiment_analysis(ticker: str, export: str = ""):
console.print(color_df.to_string())
else:
if gtff.USE_TABULATE_DF:
rich_table_from_df(
print_rich_table(
pd.DataFrame(
data=df_sentiment.values,
index=pd.to_datetime(df_sentiment.index).strftime("%Y-%m-%d"),

View File

@@ -25,7 +25,7 @@ from gamestonk_terminal.helper_funcs import (
parse_known_args_and_warn,
valid_date,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal import config_neural_network_models as cfg
from gamestonk_terminal import feature_flags as gtff
@@ -564,7 +564,7 @@ def print_pretty_prediction(df_pred: pd.DataFrame, last_price: float):
lambda x: price_prediction_color(x, last_val=last_price)
)
console.print(
rich_table_from_df(
print_rich_table(
df_pred,
show_index=True,
title="Predictions",
@@ -585,7 +585,7 @@ def print_pretty_prediction(df_pred: pd.DataFrame, last_price: float):
df_pred = pd.DataFrame(df_pred)
df_pred.columns = ["pred"]
console.print(
rich_table_from_df(
print_rich_table(
df_pred,
show_index=True,
title="Predictions",
@@ -634,7 +634,7 @@ def print_prediction_kpis(real: np.ndarray, pred: np.ndarray):
df = pd.DataFrame.from_dict(kpis, orient="index")
if gtff.USE_TABULATE_DF:
console.print(
rich_table_from_df(
print_rich_table(
df,
show_index=True,
title="KPIs",

View File

@@ -27,7 +27,7 @@ from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.helper_classes import LineAnnotateDrawer
@@ -56,7 +56,7 @@ def display_summary(df: pd.DataFrame, export: str):
"""
summary = qa_model.get_summary(df)
rich_table_from_df(
print_rich_table(
summary,
headers=list(summary.columns),
floatfmt=".3f",
@@ -426,7 +426,7 @@ def display_normality(df: pd.DataFrame, target: str, export: str = ""):
stats1 = normal.copy().T
stats1.iloc[:, 1] = stats1.iloc[:, 1].apply(lambda x: color_red(x))
rich_table_from_df(
print_rich_table(
stats1,
show_index=True,
headers=["Statistic", "p-value"],
@@ -492,7 +492,7 @@ def display_unitroot(
"""
df = df[target]
data = qa_model.get_unitroot(df, fuller_reg, kpss_reg)
rich_table_from_df(
print_rich_table(
data,
show_index=True,
headers=list(data.columns),
@@ -540,7 +540,7 @@ def display_raw(
if sort:
df = df.sort_values(by=sort, ascending=des)
df.index = [x.strftime("%Y-%m-%d") for x in df.index]
rich_table_from_df(
print_rich_table(
df.tail(num),
headers=[x.title() if x != "" else "Date" for x in df.columns],
title="[bold]Raw Data[/bold]",

View File

@@ -13,7 +13,7 @@ from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
long_number_format,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.config_plot import PLOT_DPI
@@ -117,7 +117,7 @@ def display_defi_protocols(
inplace=True,
)
rich_table_from_df(df.head(top), headers=list(df.columns), show_index=False)
print_rich_table(df.head(top), headers=list(df.columns), show_index=False)
console.print("")
export_data(

View File

@@ -9,7 +9,7 @@ from gamestonk_terminal.helper_funcs import (
export_data,
long_number_format,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.cryptocurrency.dataframe_helpers import (
prettify_column_names,
@@ -37,7 +37,7 @@ def display_account_staking_info(
df, report = terramoney_fcd_model.get_staking_account_info(address)
if not df.empty:
rich_table_from_df(
print_rich_table(
df.head(top), headers=list(df.columns), show_index=False, title=report
)
console.print("")
@@ -78,7 +78,7 @@ def display_validators(
for x in prettify_column_names(df.columns)
]
rich_table_from_df(
print_rich_table(
df.head(top),
headers=list(df.columns),
floatfmt=".2f",
@@ -122,7 +122,7 @@ def display_gov_proposals(
df = df.sort_values(by=sortby, ascending=descend).head(top)
df.columns = prettify_column_names(df.columns)
rich_table_from_df(
print_rich_table(
df,
headers=list(df.columns),
floatfmt=".2f",

View File

@@ -5,7 +5,7 @@ from gamestonk_terminal.cryptocurrency.overview import rekt_model
from gamestonk_terminal.helper_funcs import (
export_data,
long_number_format,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.rich_config import console
@@ -53,7 +53,7 @@ def display_crypto_hacks(
df["Date"] = df["Date"].dt.date
if gtff.USE_TABULATE_DF:
rich_table_from_df(
print_rich_table(
df.head(top),
headers=list(df.columns),
floatfmt=".1f",

View File

@@ -16,7 +16,7 @@ from gamestonk_terminal.economy.fred import fred_model
from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
register_matplotlib_converters()
@@ -57,7 +57,7 @@ def notes(series_term: str, num: int):
df_search["title"] = df_search["title"].apply(
lambda x: "\n".join(textwrap.wrap(x, width=50)) if isinstance(x, str) else x
)
rich_table_from_df(
print_rich_table(
df_search[["id", "title", "notes"]].head(num),
title=f"[bold]Search results for {series_term}[/bold]",
show_index=False,
@@ -138,7 +138,7 @@ def display_fred_series(
plt.show()
data.index = [x.strftime("%Y-%m-%d") for x in data.index]
if raw:
rich_table_from_df(
print_rich_table(
data.tail(limit),
headers=list(data.columns),
show_index=True,

View File

@@ -17,7 +17,7 @@ USE_CLEAR_AFTER_CMD = strtobool(os.getenv("GTFF_USE_CLEAR_AFTER_CMD", "False"))
USE_COLOR = strtobool(os.getenv("GTFF_USE_COLOR", "True"))
# Select console flair (choose from config_terminal.py list)
USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars"
USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or ":stars"
# Add date and time to command line
USE_DATETIME = strtobool(os.getenv("GTFF_USE_DATETIME", "True"))

View File

@@ -6,7 +6,7 @@ import mplfinance as mpf
import matplotlib.pyplot as plt
from gamestonk_terminal.forex import av_model
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import plot_autoscale, rich_table_from_df
from gamestonk_terminal.helper_funcs import plot_autoscale, print_rich_table
from gamestonk_terminal.rich_config import console
@@ -29,7 +29,7 @@ def display_quote(to_symbol: str, from_symbol: str):
df = pd.DataFrame.from_dict(quote)
df.index = df.index.to_series().apply(lambda x: x[3:]).values
df = df.iloc[[0, 2, 5, 4, 7, 8]]
rich_table_from_df(
print_rich_table(
df,
show_index=True,
title=f"[bold]{from_symbol}/{to_symbol} Quote [/bold]",

View File

@@ -42,7 +42,7 @@ MENU_QUIT = 1
MENU_RESET = 2
def rich_table_from_df(
def print_rich_table(
df: pd.DataFrame,
show_index: bool = False,
title: str = "",
@@ -724,38 +724,37 @@ def lett_to_num(word: str) -> str:
def get_flair() -> str:
"""Get a flair icon"""
flair = {
"rocket": "(🚀🚀)",
"diamond": "(💎💎)",
"stars": "(✨)",
"baseball": "(⚾)",
"boat": "(⛵)",
"phone": "(☎)",
"mercury": "(☿)",
"sun": "(☼)",
"moon": "(☾)",
"nuke": "(☢)",
"hazard": "(☣)",
"tunder": "(☈)",
"king": "(♔)",
"queen": "(♕)",
"knight": "(♘)",
"recycle": "(♻)",
"scales": "(⚖)",
"ball": "(⚽)",
"golf": "(⛳)",
"piece": "(☮)",
"yy": "(☯)",
flairs = {
":rocket": "(🚀🚀)",
":diamond": "(💎💎)",
":stars": "(✨)",
":baseball": "(⚾)",
":boat": "(⛵)",
":phone": "(☎)",
":mercury": "(☿)",
":sun": "(☼)",
":moon": "(☾)",
":nuke": "(☢)",
":hazard": "(☣)",
":tunder": "(☈)",
":king": "(♔)",
":queen": "(♕)",
":knight": "(♘)",
":recycle": "(♻)",
":scales": "(⚖)",
":ball": "(⚽)",
":golf": "(⛳)",
":piece": "(☮)",
":yy": "(☯)",
}
if flair.get(gtff.USE_FLAIR):
if gtff.USE_DATETIME and get_user_timezone_or_invalid() != "INVALID":
dtime = datetime.now(pytz.timezone(get_user_timezone())).strftime(
"%Y %b %d, %H:%M"
)
return f"{dtime} {flair[gtff.USE_FLAIR]}"
return flair[gtff.USE_FLAIR]
return ""
flair = flairs[gtff.USE_FLAIR] if gtff.USE_FLAIR in flairs else gtff.USE_FLAIR
if gtff.USE_DATETIME and get_user_timezone_or_invalid() != "INVALID":
dtime = datetime.now(pytz.timezone(get_user_timezone())).strftime(
"%Y %b %d, %H:%M"
)
return f"{dtime} {flair}"
return flair
def is_timezone_valid(user_tz: str) -> bool:

View File

@@ -13,7 +13,7 @@ from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.mutual_funds import investpy_model
@@ -59,7 +59,7 @@ def display_search(
# If we want to move forward with rich -- should rename this gtff
# Additionally, I recreated the tabulate functions with the rich.Table class.
rich_table_from_df(
print_rich_table(
searches.head(limit),
show_index=False,
title=f"[bold]Mutual Funds with {by} matching {value}[/bold]",
@@ -82,7 +82,7 @@ def display_overview(country: str = "united states", limit: int = 10, export: st
overview = investpy_model.get_overview(country=country, limit=limit)
overview["Assets (1B)"] = overview.total_assets / 1_000_000_000
overview = overview.drop(columns=["country", "total_assets"])
rich_table_from_df(
print_rich_table(
overview, title=f"[bold]Fund overview for {country.title()}[/bold]"
)
export_data(
@@ -110,7 +110,7 @@ def display_fund_info(fund_name: str, country: str = "united states"):
.applymap(lambda x: np.nan if not x else x)
.dropna()
)
rich_table_from_df(
print_rich_table(
info,
title=f"[bold]{fund_name.title()} Information[/bold]",
show_index=False,

View File

@@ -8,7 +8,7 @@ import matplotlib.pyplot as plt
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.helper_funcs import (
rich_table_from_df,
print_rich_table,
export_data,
plot_autoscale,
)
@@ -50,7 +50,7 @@ def display_sector(fund: str, min_pct_to_display: float = 5, export: str = ""):
"Real Estate" if x == "realestate" else x.replace("_", " ").title()
for x in df_weight.index
]
rich_table_from_df(
print_rich_table(
df_weight,
show_index=True,
index_name="Sector",
@@ -110,7 +110,7 @@ def display_equity(fund: str):
df_weight = pd.DataFrame.from_dict(equity_hold, orient="index")
df_weight = df_weight.apply(lambda x: round(100 * x, 3))
df_weight.index = df_weight.index.map(title_map)
rich_table_from_df(
print_rich_table(
df_weight,
show_index=True,
index_name="Equity",

View File

@@ -3,7 +3,7 @@ __docformat__ = "numpy"
import os
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.discovery import ark_model
from gamestonk_terminal.rich_config import console
@@ -71,7 +71,7 @@ def ark_orders_view(
if gtff.USE_COLOR:
df_orders["direction"] = df_orders["direction"].apply(direction_color_red_green)
rich_table_from_df(
print_rich_table(
df_orders,
headers=[x.title() for x in df_orders.columns],
show_index=False,

View File

@@ -5,7 +5,7 @@ import os
import re
import pandas as pd
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.stocks.discovery import fidelity_model
@@ -84,7 +84,7 @@ def orders_view(num: int, export: str):
df_orders = df_orders.head(n=num).iloc[:, :-1]
rich_table_from_df(
print_rich_table(
df_orders,
headers=[x.title() for x in df_orders.columns],
show_index=False,

View File

@@ -3,7 +3,7 @@ __docformat__ = "numpy"
import os
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.discovery import nasdaq_model
from gamestonk_terminal.rich_config import console
@@ -24,7 +24,7 @@ def display_top_retail(n_days: int = 3, export: str = ""):
for date, df in retails.head(n_days * 10).groupby("Date"):
df = df.drop(columns=["Date"])
df = df.reset_index(drop=True)
rich_table_from_df(
print_rich_table(
df,
headers=[x.title() for x in df.columns],
show_index=False,
@@ -77,7 +77,7 @@ def display_dividend_calendar(
calendar = calendar.drop(columns=["announcement_Date"])
calendar.columns = calendar.columns.map(div_map)
calendar = calendar.sort_values(by=sort_col, ascending=ascending)
rich_table_from_df(
print_rich_table(
calendar.head(limit),
headers=[x.title() for x in calendar.columns],
title=f"[bold]Dividend Calendar for {date}[/bold]",

View File

@@ -13,7 +13,7 @@ from gamestonk_terminal.stocks.government import quiverquant_model
from gamestonk_terminal.helper_funcs import (
plot_autoscale,
export_data,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal import feature_flags as gtff
@@ -90,14 +90,14 @@ def display_last_government(
f"{', '.join(df_gov['Representative'].str.split().str[0].unique())}"
)
else:
rich_table_from_df(
print_rich_table(
df_gov_rep,
headers=list(df_gov_rep.columns),
show_index=False,
title="Representative Trading",
)
else:
rich_table_from_df(
print_rich_table(
df_gov,
headers=list(df_gov.columns),
show_index=False,
@@ -177,7 +177,7 @@ def display_government_buys(
.sort_values(ascending=False)
.head(n=num)
)
rich_table_from_df(
print_rich_table(
df, headers=["Amount ($1k)"], show_index=True, title="Top Government Buys"
)
fig, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI)
@@ -280,7 +280,7 @@ def display_government_sells(
.abs()
.head(n=num)
)
rich_table_from_df(
print_rich_table(
df, headers=["Amount ($1k)"], show_index=True, title="Top Government Trades"
)
fig, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI)
@@ -343,7 +343,7 @@ def display_last_contracts(
df_contracts["Description"] = df_contracts["Description"].apply(
lambda x: "\n".join(textwrap.wrap(x, 50))
)
rich_table_from_df(
print_rich_table(
df_contracts,
headers=list(df_contracts.columns),
show_index=False,
@@ -468,7 +468,7 @@ def display_government_trading(
df_gov = df_gov.sort_values("TransactionDate", ascending=True)
if raw:
rich_table_from_df(
print_rich_table(
df_gov,
headers=list(df_gov.columns),
show_index=False,
@@ -512,7 +512,7 @@ def display_contracts(
df_contracts.drop_duplicates(inplace=True)
if raw:
rich_table_from_df(
print_rich_table(
df_contracts,
headers=list(df_contracts.columns),
show_index=False,
@@ -560,7 +560,7 @@ def display_qtr_contracts(analysis: str, num: int, raw: bool = False, export: st
tickers = quiverquant_model.analyze_qtr_contracts(analysis, num)
if analysis in ("upmom", "downmom"):
if raw:
rich_table_from_df(
print_rich_table(
pd.DataFrame(tickers.values),
headers=["tickers"],
show_index=False,
@@ -617,7 +617,7 @@ def display_qtr_contracts(analysis: str, num: int, raw: bool = False, export: st
plt.show()
elif analysis == "total":
rich_table_from_df(tickers, headers=["Total"], title="Quarterly Contracts")
print_rich_table(tickers, headers=["Total"], title="Quarterly Contracts")
export_data(
export, os.path.dirname(os.path.abspath(__file__)), "qtrcontracts", df_contracts
@@ -655,7 +655,7 @@ def display_hist_contracts(ticker: str, raw: bool = False, export: str = ""):
]
if raw:
rich_table_from_df(
print_rich_table(
df_contracts,
headers=list(df_contracts.columns),
title="Historical Quarterly Government Contracts",
@@ -708,7 +708,7 @@ def display_top_lobbying(num: int, raw: bool = False, export: str = ""):
).sort_values(by="Amount", ascending=False)
if raw:
rich_table_from_df(
print_rich_table(
lobbying_by_ticker.head(num),
headers=["Amount ($100k)"],
show_index=True,

View File

@@ -8,7 +8,7 @@ from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import (
export_data,
get_next_stock_market_days,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.stocks.insider import businessinsider_model
@@ -55,7 +55,7 @@ def insider_activity(
if raw:
df_insider.index = pd.to_datetime(df_insider.index).date
rich_table_from_df(
print_rich_table(
df_insider.sort_index(ascending=False)
.head(n=num)
.applymap(lambda x: x.replace(".00", "").replace(",", "")),

View File

@@ -4,7 +4,7 @@ __docformat__ = "numpy"
import os
import pandas as pd
from gamestonk_terminal.stocks.insider import finviz_model
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.rich_config import console
@@ -36,7 +36,7 @@ def last_insider_activity(ticker: str, num: int, export: str):
]
]
rich_table_from_df(
print_rich_table(
df.head(num),
headers=list(df.columns),
show_index=True,

View File

@@ -9,7 +9,7 @@ import pandas as pd
from gamestonk_terminal.helper_funcs import (
patch_pandas_text_adjustment,
export_data,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.insider.openinsider_model import (
get_open_insider_link,
@@ -187,7 +187,7 @@ def print_insider_data(type_insider: str, limit: int = 10, export: str = ""):
lambda x: "\n".join(textwrap.wrap(x, width=20)) if isinstance(x, str) else x
)
rich_table_from_df(
print_rich_table(
df,
headers=[x.title() for x in df.columns],
show_index=False,
@@ -281,7 +281,7 @@ def print_insider_filter(
df_insider = df_insider.drop(columns=["Filing Date"])
console.print("")
rich_table_from_df(
print_rich_table(
df_insider,
headers=[x.title() for x in df_insider.columns],
title="Insider filtered",

View File

@@ -3,7 +3,7 @@ __docformat__ = "numpy"
import os
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.options import barchart_model
from gamestonk_terminal.rich_config import console
@@ -21,7 +21,7 @@ def print_options_data(ticker: str, export: str):
data = barchart_model.get_options_info(ticker)
rich_table_from_df(
print_rich_table(
data, show_index=False, headers=list(data.columns), title="Options Information"
)
console.print("")

View File

@@ -3,7 +3,7 @@ __docformat__ = "numpy"
import os
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.options import chartexchange_model
from gamestonk_terminal.rich_config import console
@@ -38,7 +38,7 @@ def display_raw(
df,
)
rich_table_from_df(
print_rich_table(
df.head(num),
headers=list(df.columns),
show_index=True,

View File

@@ -5,7 +5,7 @@ import os
import pandas as pd
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.stocks.options import fdscanner_model
from gamestonk_terminal.rich_config import console
@@ -41,7 +41,7 @@ def display_options(
data = data[data.Type == "Put"]
if calls_only:
data = data[data.Type == "Call"]
rich_table_from_df(
print_rich_table(
data[:num],
headers=list(data.columns),
show_index=False,

View File

@@ -10,7 +10,7 @@ from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.parent_classes import BaseController
from gamestonk_terminal.helper_funcs import (
parse_known_args_and_warn,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.menu import session
from gamestonk_terminal.stocks.options import yfinance_view
@@ -155,7 +155,7 @@ class PricingController(BaseController):
)
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
rich_table_from_df(
print_rich_table(
self.prices,
headers=list(self.prices.columns),
show_index=False,

View File

@@ -12,7 +12,7 @@ from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.options import syncretism_model
from gamestonk_terminal.rich_config import console
@@ -86,7 +86,7 @@ def view_screener_output(
if n_show > 0:
df_res = df_res.head(n_show)
rich_table_from_df(
print_rich_table(
df_res, headers=list(df_res.columns), show_index=False, title="Screener Output"
)
console.print("")
@@ -134,7 +134,7 @@ def view_historical_greeks(
df = syncretism_model.get_historical_greeks(ticker, expiry, chain_id, strike, put)
if raw:
rich_table_from_df(
print_rich_table(
df.tail(n_show), headers=list(df.columns), title="Historical Greeks"
)

View File

@@ -18,7 +18,7 @@ from gamestonk_terminal.helper_funcs import (
export_data,
patch_pandas_text_adjustment,
plot_autoscale,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.options import op_helpers, tradier_model
from gamestonk_terminal.rich_config import console
@@ -135,7 +135,7 @@ def display_chains(
df = calls_df if calls_only else puts_df
if calls_only or puts_only:
rich_table_from_df(
print_rich_table(
df,
headers=[x.title() for x in df.columns],
show_index=False,
@@ -164,7 +164,7 @@ def display_chains(
else col
for col in chain_table.columns
]
rich_table_from_df(
print_rich_table(
chain_table, headers=headers, show_index=False, title="Option chain"
)
@@ -598,7 +598,7 @@ def display_historical(
)
if raw:
rich_table_from_df(
print_rich_table(
df_hist,
headers=[x.title() for x in df_hist.columns],
title="Historical Option Prices",

View File

@@ -23,7 +23,7 @@ from gamestonk_terminal.helper_funcs import (
export_data,
plot_autoscale,
excel_columns,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.options import op_helpers, yfinance_model
from gamestonk_terminal.stocks.options.yfinance_model import (
@@ -606,7 +606,7 @@ def show_parity(
if ask:
console.print("Warning: Options with no current ask price not shown.\n")
rich_table_from_df(
print_rich_table(
show,
headers=[x.title() for x in show.columns],
show_index=False,
@@ -679,7 +679,7 @@ def risk_neutral_vals(
new_df = new_df[new_df["Strike"] >= mini]
new_df = new_df[new_df["Strike"] <= maxi]
rich_table_from_df(
print_rich_table(
new_df,
headers=[x.title() for x in new_df.columns],
show_index=False,

View File

@@ -7,7 +7,7 @@ import difflib
import pandas as pd
from gamestonk_terminal.helper_funcs import (
export_data,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.screener.finviz_model import (
get_screener_data,
@@ -191,7 +191,7 @@ def screener(
df_screen = df_screen.fillna("")
rich_table_from_df(
print_rich_table(
df_screen.head(n=limit),
headers=list(df_screen.columns),
show_index=False,

View File

@@ -14,7 +14,7 @@ from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal.helper_funcs import (
plot_autoscale,
export_data,
rich_table_from_df,
print_rich_table,
)
from gamestonk_terminal.stocks.sector_industry_analysis import financedatabase_model
from gamestonk_terminal.rich_config import console
@@ -126,7 +126,7 @@ def display_bars_financials(
df = df_all.head(limit)
if raw:
rich_table_from_df(
print_rich_table(
df, headers=list(df.columns), show_index=False, title="Bars Financials"
)
else:
@@ -279,7 +279,7 @@ def display_companies_per_sector_in_country(
title += " excluding exchanges" if exclude_exchanges else " including exchanges"
if raw:
rich_table_from_df(df, headers=list(df.columns), show_index=True, title=title)
print_rich_table(df, headers=list(df.columns), show_index=True, title=title)
else:
colors = [
"b",
@@ -426,7 +426,7 @@ def display_companies_per_industry_in_country(
title += " excluding exchanges" if exclude_exchanges else " including exchanges"
if raw:
rich_table_from_df(df, headers=list(df.columns), show_index=True, title=title)
print_rich_table(df, headers=list(df.columns), show_index=True, title=title)
else:
colors = [
"b",
@@ -578,7 +578,7 @@ def display_companies_per_industry_in_sector(
title += " excluding exchanges" if exclude_exchanges else " including exchanges"
if raw:
rich_table_from_df(
print_rich_table(
df,
headers=list(df.columns),
show_index=True,
@@ -735,7 +735,7 @@ def display_companies_per_country_in_sector(
title += " excluding exchanges" if exclude_exchanges else " including exchanges"
if raw:
rich_table_from_df(df, headers=list(df.columns), show_index=True, title=title)
print_rich_table(df, headers=list(df.columns), show_index=True, title=title)
else:
colors = [
"b",
@@ -885,7 +885,7 @@ def display_companies_per_country_in_industry(
title += " excluding exchanges" if exclude_exchanges else " including exchanges"
if raw:
rich_table_from_df(df, headers=list(df.columns), show_index=True, title=title)
print_rich_table(df, headers=list(df.columns), show_index=True, title=title)
else:
colors = [
"b",

View File

@@ -6,7 +6,7 @@ import os
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.technical_analysis import tradingview_model
from gamestonk_terminal.helper_funcs import export_data, rich_table_from_df
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
def print_recommendation(
@@ -38,7 +38,7 @@ def print_recommendation(
"recom",
recom,
)
rich_table_from_df(
print_rich_table(
recom,
headers=list(recom.columns),
title="Ticker Recomendation",

View File

@@ -23,7 +23,7 @@ from pyEX.common.exception import PyEXception
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal import thought_of_the_day as thought
from gamestonk_terminal.helper_funcs import rich_table_from_df
from gamestonk_terminal.helper_funcs import print_rich_table
from gamestonk_terminal.rich_config import console
# pylint: disable=too-many-statements,no-member,too-many-branches,C0302
@@ -274,7 +274,7 @@ def check_api_keys():
else:
key_dict["SENTIMENT_INVESTOR"] = "Defined, test unsuccessful"
rich_table_from_df(
print_rich_table(
pd.DataFrame(key_dict.items()),
show_index=False,
headers=["API", "Key"],

View File

@@ -314,7 +314,7 @@ def pytest_configure(config: Config) -> None:
def effect(df, *xargs, **kwargs): # pylint: disable=unused-argument
print(df.to_string())
helper_funcs.rich_table_from_df = effect
helper_funcs.print_rich_table = effect
config.addinivalue_line("markers", "record_stdout: Mark the test as text record.")

View File

@@ -291,7 +291,7 @@ def test_call_func_expect_queue(expected_queue, func, queue):
(
"call_show",
[],
"rich_table_from_df",
"print_rich_table",
[
PRICES,
],