mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 04:13:06 +00:00
fixing some formatting
This commit is contained in:
@@ -8,6 +8,7 @@ from typing import Optional
|
||||
import pandas as pd
|
||||
|
||||
from openbb_terminal import OpenBBFigure, theme
|
||||
from openbb_terminal.core.session.current_user import get_current_user
|
||||
from openbb_terminal.decorators import check_api_key, log_start_end
|
||||
from openbb_terminal.helper_funcs import (
|
||||
export_data,
|
||||
@@ -130,13 +131,14 @@ def short_interest(
|
||||
fig = plot_short_interest(symbol, df_short_interest, nyse, True)
|
||||
|
||||
if raw:
|
||||
df_short_interest["% of Volume Shorted"] = df_short_interest[
|
||||
"% of Volume Shorted"
|
||||
].apply(lambda x: f"{x/100:.2%}")
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
df_short_interest["% of Volume Shorted"] = df_short_interest[
|
||||
"% of Volume Shorted"
|
||||
].apply(lambda x: f"{x/100:.2%}")
|
||||
|
||||
df_short_interest = df_short_interest.applymap(
|
||||
lambda x: lambda_long_number_format(x)
|
||||
).sort_index(ascending=False)
|
||||
df_short_interest = df_short_interest.applymap(
|
||||
lambda x: lambda_long_number_format(x)
|
||||
).sort_index(ascending=False)
|
||||
|
||||
print_rich_table(
|
||||
df_short_interest,
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Optional, Union
|
||||
import pandas as pd
|
||||
|
||||
from openbb_terminal import OpenBBFigure, theme
|
||||
from openbb_terminal.core.session.current_user import get_current_user
|
||||
from openbb_terminal.decorators import check_api_key, log_start_end
|
||||
from openbb_terminal.helper_funcs import (
|
||||
export_data,
|
||||
@@ -105,9 +106,10 @@ def cost_to_borrow(
|
||||
fig = plot_cost_to_borrow(symbol, df_cost_to_borrow, True)
|
||||
|
||||
if raw:
|
||||
df_cost_to_borrow["Available"] = df_cost_to_borrow["Available"].apply(
|
||||
lambda x: lambda_long_number_format(x)
|
||||
)
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
df_cost_to_borrow["Available"] = df_cost_to_borrow["Available"].apply(
|
||||
lambda x: lambda_long_number_format(x)
|
||||
)
|
||||
print_rich_table(
|
||||
df_cost_to_borrow,
|
||||
headers=list(df_cost_to_borrow.columns),
|
||||
|
||||
@@ -112,7 +112,9 @@ def get_key_metrics(symbol: str) -> pd.DataFrame:
|
||||
|
||||
df_fa = pd.json_normalize(result_json)
|
||||
df_fa = df_fa[list(result_json.keys())].T
|
||||
df_fa = df_fa.applymap(lambda x: lambda_long_number_format(x))
|
||||
print(df_fa)
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
df_fa = df_fa.applymap(lambda x: lambda_long_number_format(x))
|
||||
clean_df_index(df_fa)
|
||||
df_fa = df_fa.rename(
|
||||
index={
|
||||
|
||||
@@ -661,8 +661,9 @@ def clean_metrics_df(data: pd.DataFrame, num: int, mask: bool = False) -> pd.Dat
|
||||
for row, dt_type in date_rows.items():
|
||||
if row in data.index:
|
||||
data.loc[row] = pd.to_datetime(data.loc[row], format=dt_type)
|
||||
|
||||
data = data.applymap(lambda x: lambda_long_number_format(x))
|
||||
# we dont want to format this going to pywry window
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
data = data.applymap(lambda x: lambda_long_number_format(x))
|
||||
clean_df_index(data)
|
||||
data.columns.name = "Fiscal Date Ending"
|
||||
data = data.rename(
|
||||
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
from typing import List, Optional
|
||||
|
||||
import pandas as pd
|
||||
from openbb_terminal.core.session.current_user import get_current_user
|
||||
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import (
|
||||
@@ -196,7 +197,7 @@ def screener(
|
||||
console.print(
|
||||
f"Wrong sort column provided! Provide one of these: {', '.join(d_cols_to_sort[data_type])}"
|
||||
)
|
||||
|
||||
df_original = df_screen.copy()
|
||||
df_screen = df_screen.fillna("")
|
||||
|
||||
if data_type == "ownership":
|
||||
@@ -235,9 +236,12 @@ def screener(
|
||||
lambda x: lambda_long_number_format(x, 1)
|
||||
)
|
||||
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
df_original = df_screen
|
||||
|
||||
print_rich_table(
|
||||
df_screen,
|
||||
headers=list(df_screen.columns),
|
||||
df_original,
|
||||
headers=list(df_original.columns),
|
||||
show_index=False,
|
||||
title="Finviz Screener",
|
||||
export=bool(export),
|
||||
@@ -248,7 +252,7 @@ def screener(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
data_type,
|
||||
df_screen,
|
||||
df_original,
|
||||
sheet_name,
|
||||
)
|
||||
|
||||
|
||||
@@ -329,13 +329,16 @@ def get_quote(symbols: list[str]) -> pd.DataFrame:
|
||||
if not df_fa.empty:
|
||||
clean_df_index(df_fa)
|
||||
for c in df_fa.columns:
|
||||
df_fa.loc["Market cap"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Market cap"][c]
|
||||
)
|
||||
df_fa.loc["Shares outstanding"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Shares outstanding"][c]
|
||||
)
|
||||
df_fa.loc["Volume"][c] = lambda_long_number_format(df_fa.loc["Volume"][c])
|
||||
if not get_current_user().preferences.USE_INTERACTIVE_DF:
|
||||
df_fa.loc["Market cap"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Market cap"][c]
|
||||
)
|
||||
df_fa.loc["Shares outstanding"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Shares outstanding"][c]
|
||||
)
|
||||
df_fa.loc["Volume"][c] = lambda_long_number_format(
|
||||
df_fa.loc["Volume"][c]
|
||||
)
|
||||
# Check if there is a valid earnings announcement
|
||||
if df_fa.loc["Earnings announcement"][c]:
|
||||
earning_announcement = datetime.strptime(
|
||||
|
||||
Reference in New Issue
Block a user