mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
black
This commit is contained in:
@@ -48,7 +48,9 @@ def clean_attr_desc(attr: Optional[Any] = None) -> Optional[str]:
|
||||
return (
|
||||
attr.__doc__.splitlines()[1].lstrip()
|
||||
if not attr.__doc__.splitlines()[0]
|
||||
else attr.__doc__.splitlines()[0].lstrip() if attr.__doc__ else ""
|
||||
else attr.__doc__.splitlines()[0].lstrip()
|
||||
if attr.__doc__
|
||||
else ""
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -158,7 +158,9 @@ def display_crypto_heatmap(
|
||||
)
|
||||
fig.add_trace(treemap["data"][0], row=1, col=1)
|
||||
|
||||
fig.data[0].texttemplate = (
|
||||
fig.data[
|
||||
0
|
||||
].texttemplate = (
|
||||
"<br> <br> <b>%{label}<br> %{customdata[0]:.2f}% <br> <br> <br><br><b>"
|
||||
)
|
||||
fig.data[0].insidetextfont = dict(
|
||||
|
||||
@@ -382,9 +382,9 @@ class Handler:
|
||||
|
||||
for ticker in tickers:
|
||||
if ticker not in st.session_state["indicators_dfs"]:
|
||||
st.session_state["indicators_dfs"][ticker] = (
|
||||
await self.load_ticker_data(ticker, interval, start, end, source)
|
||||
)
|
||||
st.session_state["indicators_dfs"][
|
||||
ticker
|
||||
] = await self.load_ticker_data(ticker, interval, start, end, source)
|
||||
if st.session_state["indicators_dfs"][ticker].empty:
|
||||
indicators_dfs = st.session_state["indicators_dfs"]
|
||||
del indicators_dfs[ticker]
|
||||
|
||||
@@ -1743,15 +1743,15 @@ class EconometricsController(BaseController):
|
||||
self.regression[regression][
|
||||
"independent"
|
||||
] = independent_variables
|
||||
self.regression[regression_name]["model"] = (
|
||||
regression_view.display_panel(
|
||||
regression_df[dependent_variable],
|
||||
regression_df[independent_variables],
|
||||
regression,
|
||||
ns_parser.entity_effects,
|
||||
ns_parser.time_effects,
|
||||
ns_parser.export,
|
||||
)
|
||||
self.regression[regression_name][
|
||||
"model"
|
||||
] = regression_view.display_panel(
|
||||
regression_df[dependent_variable],
|
||||
regression_df[independent_variables],
|
||||
regression,
|
||||
ns_parser.entity_effects,
|
||||
ns_parser.time_effects,
|
||||
ns_parser.export,
|
||||
)
|
||||
else:
|
||||
console.print(
|
||||
|
||||
@@ -1436,9 +1436,9 @@ class EconomyController(BaseController):
|
||||
|
||||
if not df.empty:
|
||||
for series_id, data in detail.items():
|
||||
self.FRED_TITLES[series_id] = (
|
||||
f"{data['title']} ({data['units']})"
|
||||
)
|
||||
self.FRED_TITLES[
|
||||
series_id
|
||||
] = f"{data['title']} ({data['units']})"
|
||||
|
||||
# Making data available at the class level
|
||||
self.DATASETS["fred"][series_id] = df[series_id]
|
||||
|
||||
@@ -374,10 +374,10 @@ def get_cpi(
|
||||
for series_id, country_value, frequency_value, unit_value in series[
|
||||
["series_id", "country", "frequency", "units"]
|
||||
].values:
|
||||
series_dictionary[f"{country_value}-{frequency_value}-{unit_value}"] = (
|
||||
get_series_data(
|
||||
series_id=series_id, start_date=start_date, end_date=end_date
|
||||
)
|
||||
series_dictionary[
|
||||
f"{country_value}-{frequency_value}-{unit_value}"
|
||||
] = get_series_data(
|
||||
series_id=series_id, start_date=start_date, end_date=end_date
|
||||
)
|
||||
|
||||
df = pd.DataFrame.from_dict(series_dictionary)
|
||||
|
||||
@@ -265,7 +265,9 @@ def plot_cpi(
|
||||
title += (
|
||||
" Indices"
|
||||
if len(df.columns) > 1
|
||||
else f" Index for {country}" if country else ""
|
||||
else f" Index for {country}"
|
||||
if country
|
||||
else ""
|
||||
)
|
||||
|
||||
fig = OpenBBFigure(yaxis_title=ylabel_dict.get(units, "Index (2015=100)"))
|
||||
|
||||
@@ -1245,7 +1245,9 @@ def plot_icebofa(
|
||||
title = (
|
||||
""
|
||||
if df.empty
|
||||
else "ICE BofA Bond Benchmark Indices" if len(df.columns) > 1 else df.columns[0]
|
||||
else "ICE BofA Bond Benchmark Indices"
|
||||
if len(df.columns) > 1
|
||||
else df.columns[0]
|
||||
)
|
||||
|
||||
fig = OpenBBFigure(yaxis_title="Yield (%)" if units == "percent" else "Index")
|
||||
|
||||
@@ -83,7 +83,9 @@ def plot_treasuries(
|
||||
term = (
|
||||
"Short and Long"
|
||||
if short_term and long_term
|
||||
else "Long" if long_term else "Short"
|
||||
else "Long"
|
||||
if long_term
|
||||
else "Short"
|
||||
)
|
||||
title = f"{term} Term Interest Rates {' with forecasts' if forecast else ''}"
|
||||
fig.set_title(title)
|
||||
|
||||
@@ -202,17 +202,17 @@ class TerminalStyle:
|
||||
continue
|
||||
|
||||
if stf.name.endswith(".mplstyle"):
|
||||
self.mpl_styles_available[stf.name.replace(".mplstyle", "")] = (
|
||||
os.path.join(folder, stf)
|
||||
)
|
||||
self.mpl_styles_available[
|
||||
stf.name.replace(".mplstyle", "")
|
||||
] = os.path.join(folder, stf)
|
||||
elif stf.name.endswith(".mplrc.json"):
|
||||
self.mpl_rcparams_available[stf.name.replace(".mplrc.json", "")] = (
|
||||
os.path.join(folder, stf)
|
||||
)
|
||||
self.mpl_rcparams_available[
|
||||
stf.name.replace(".mplrc.json", "")
|
||||
] = os.path.join(folder, stf)
|
||||
elif stf.name.endswith(".mpfstyle.json"):
|
||||
self.mpf_styles_available[stf.name.replace(".mpfstyle.json", "")] = (
|
||||
os.path.join(folder, stf)
|
||||
)
|
||||
self.mpf_styles_available[
|
||||
stf.name.replace(".mpfstyle.json", "")
|
||||
] = os.path.join(folder, stf)
|
||||
elif stf.name.endswith(".richstyle.json"):
|
||||
self.console_styles_available[
|
||||
stf.name.replace(".richstyle.json", "")
|
||||
|
||||
@@ -1159,7 +1159,9 @@ def text_adjustment_justify(self, texts, max_len, mode="right"):
|
||||
justify = (
|
||||
str.ljust
|
||||
if (mode == "left")
|
||||
else str.rjust if (mode == "right") else str.center
|
||||
else str.rjust
|
||||
if (mode == "right")
|
||||
else str.center
|
||||
)
|
||||
out = []
|
||||
for s in texts:
|
||||
|
||||
@@ -45,7 +45,9 @@ def transform(
|
||||
lambda series: (
|
||||
series
|
||||
if skipPredicate is not None and skipPredicate(series)
|
||||
else series * multiplier if isinstance(series, (float, int)) else series
|
||||
else series * multiplier
|
||||
if isinstance(series, (float, int))
|
||||
else series
|
||||
),
|
||||
axis,
|
||||
)
|
||||
|
||||
@@ -383,16 +383,16 @@ def get_daily_sector_prices(start_date, end_date) -> dict:
|
||||
sector_ticker,
|
||||
) in sp500_tickers.items(): # iterate thru the sectors
|
||||
# load the data required from yfinance
|
||||
sp500_tickers_data[sector] = (
|
||||
{ # builds a dictionary entry for the sector with adj close data
|
||||
"sector_data": yf.download(
|
||||
sector_ticker,
|
||||
start=start_date,
|
||||
end=end_date,
|
||||
progress=False,
|
||||
ignore_tz=True,
|
||||
)["Adj Close"]
|
||||
}
|
||||
) # stores the data here
|
||||
sp500_tickers_data[
|
||||
sector
|
||||
] = { # builds a dictionary entry for the sector with adj close data
|
||||
"sector_data": yf.download(
|
||||
sector_ticker,
|
||||
start=start_date,
|
||||
end=end_date,
|
||||
progress=False,
|
||||
ignore_tz=True,
|
||||
)["Adj Close"]
|
||||
} # stores the data here
|
||||
|
||||
return sp500_tickers_data
|
||||
|
||||
@@ -261,11 +261,13 @@ class PortfolioController(BaseController):
|
||||
categories["COUNTRY"][transaction["Ticker"]] = transaction[
|
||||
"Country"
|
||||
]
|
||||
categories["CURRENT_INVESTED_AMOUNT"][transaction["Ticker"]] = (
|
||||
transactions[
|
||||
transactions["Ticker"] == transaction["Ticker"]
|
||||
]["Investment"].sum()
|
||||
)
|
||||
categories["CURRENT_INVESTED_AMOUNT"][
|
||||
transaction["Ticker"]
|
||||
] = transactions[
|
||||
transactions["Ticker"] == transaction["Ticker"]
|
||||
][
|
||||
"Investment"
|
||||
].sum()
|
||||
categories["CURRENCY"][transaction["Ticker"]] = transaction[
|
||||
"Currency"
|
||||
]
|
||||
|
||||
@@ -1191,7 +1191,9 @@ def get_blacklitterman(
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_ef(portfolio_engine: Optional[PoEngine] = None, **kwargs) -> Tuple[
|
||||
def get_ef(
|
||||
portfolio_engine: Optional[PoEngine] = None, **kwargs
|
||||
) -> Tuple[
|
||||
pd.DataFrame,
|
||||
pd.DataFrame,
|
||||
pd.DataFrame,
|
||||
|
||||
@@ -74,9 +74,9 @@ class ReportController(BaseController):
|
||||
self.choices[report_name] = {}
|
||||
for arg in self.PARAMETERS_DICT[report_name]:
|
||||
if report_name in reports_model.REPORT_CHOICES:
|
||||
self.choices[report_name]["--" + arg] = (
|
||||
reports_model.REPORT_CHOICES[report_name]["--" + arg]
|
||||
)
|
||||
self.choices[report_name][
|
||||
"--" + arg
|
||||
] = reports_model.REPORT_CHOICES[report_name]["--" + arg]
|
||||
|
||||
self.choices["support"] = self.SUPPORT_CHOICES
|
||||
self.choices["about"] = self.ABOUT_CHOICES
|
||||
|
||||
@@ -50,9 +50,9 @@ def catching_diff_url_formats(ftd_urls: list) -> list:
|
||||
ftd_url
|
||||
== "https://www.sec.gov/files/data/fails-deliver-data/cnsfails201910a.zip"
|
||||
):
|
||||
ftd_urls[i] = (
|
||||
"https://www.sec.gov/files/data/fails-deliver-data/cnsfails201910a_0.zip"
|
||||
)
|
||||
ftd_urls[
|
||||
i
|
||||
] = "https://www.sec.gov/files/data/fails-deliver-data/cnsfails201910a_0.zip"
|
||||
|
||||
return ftd_urls
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ def get_high_short_interest() -> DataFrame:
|
||||
shorted_stock_data = a_stock_txt.split("\n")
|
||||
|
||||
if len(shorted_stock_data) == 8:
|
||||
df_high_short_interest.loc[len(df_high_short_interest.index)] = (
|
||||
shorted_stock_data[:-1]
|
||||
)
|
||||
df_high_short_interest.loc[
|
||||
len(df_high_short_interest.index)
|
||||
] = shorted_stock_data[:-1]
|
||||
|
||||
shorted_stock_data = []
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ def display_heatmap(
|
||||
)
|
||||
fig.add_trace(treemap["data"][0], row=1, col=1)
|
||||
|
||||
fig.data[0].texttemplate = (
|
||||
fig.data[
|
||||
0
|
||||
].texttemplate = (
|
||||
"<br> <br> <b>%{label}<br> %{customdata[0]:.2f}% <br> <br> <br><br><b>"
|
||||
)
|
||||
fig.data[0].insidetextfont = dict(family="Arial Black", size=20, color="white")
|
||||
|
||||
@@ -95,10 +95,10 @@ def get_management(symbol: str) -> pd.DataFrame:
|
||||
df_management = df_management.set_index("Name")
|
||||
|
||||
for s_name in df_management.index:
|
||||
df_management.loc[s_name]["Info"] = (
|
||||
f"http://www.google.com/search?q={s_name} {symbol.upper()}".replace(
|
||||
" ", "%20"
|
||||
)
|
||||
df_management.loc[s_name][
|
||||
"Info"
|
||||
] = f"http://www.google.com/search?q={s_name} {symbol.upper()}".replace(
|
||||
" ", "%20"
|
||||
)
|
||||
|
||||
return df_management
|
||||
|
||||
@@ -163,7 +163,9 @@ def display_price_target_from_analysts(
|
||||
lambda x: (
|
||||
theme.up_color
|
||||
if x == "BUY"
|
||||
else theme.down_color if x == "SELL" else "#b3a8a8"
|
||||
else theme.down_color
|
||||
if x == "SELL"
|
||||
else "#b3a8a8"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -988,7 +988,9 @@ class CreateExcelFA:
|
||||
df = (
|
||||
self.df["IS"]
|
||||
if title in self.df["IS"].index
|
||||
else self.df["BS"] if title in self.df["BS"].index else self.df["CF"]
|
||||
else self.df["BS"]
|
||||
if title in self.df["BS"].index
|
||||
else self.df["CF"]
|
||||
)
|
||||
ind = (
|
||||
df.index.get_loc(title)
|
||||
|
||||
@@ -213,20 +213,20 @@ def print_insider_filter(
|
||||
new_df_insider["Trade Type"] == "S - Sale"
|
||||
].apply(lambda_red_highlight)
|
||||
if not new_df_insider[new_df_insider["Trade Type"] == "S - Sale+OE"].empty:
|
||||
new_df_insider[new_df_insider["Trade Type"] == "S - Sale+OE"] = (
|
||||
new_df_insider[new_df_insider["Trade Type"] == "S - Sale+OE"].apply(
|
||||
lambda_yellow_highlight
|
||||
)
|
||||
new_df_insider[
|
||||
new_df_insider["Trade Type"] == "S - Sale+OE"
|
||||
] = new_df_insider[new_df_insider["Trade Type"] == "S - Sale+OE"].apply(
|
||||
lambda_yellow_highlight
|
||||
)
|
||||
if not new_df_insider[new_df_insider["Trade Type"] == "F - Tax"].empty:
|
||||
new_df_insider[new_df_insider["Trade Type"] == "F - Tax"] = new_df_insider[
|
||||
new_df_insider["Trade Type"] == "F - Tax"
|
||||
].apply(lambda_magenta_highlight)
|
||||
if not new_df_insider[new_df_insider["Trade Type"] == "P - Purchase"].empty:
|
||||
new_df_insider[new_df_insider["Trade Type"] == "P - Purchase"] = (
|
||||
new_df_insider[new_df_insider["Trade Type"] == "P - Purchase"].apply(
|
||||
lambda_green_highlight
|
||||
)
|
||||
new_df_insider[
|
||||
new_df_insider["Trade Type"] == "P - Purchase"
|
||||
] = new_df_insider[new_df_insider["Trade Type"] == "P - Purchase"].apply(
|
||||
lambda_green_highlight
|
||||
)
|
||||
|
||||
patch_pandas_text_adjustment()
|
||||
|
||||
Reference in New Issue
Block a user