Merge branch 'economics_menu_upgrade' of https://github.com/JerBouma/GamestonkTerminal into economics_menu_upgrade

This commit is contained in:
Jeroen Bouma
2022-03-14 18:39:09 +01:00
36 changed files with 8274 additions and 7703 deletions

View File

@@ -9,7 +9,6 @@ import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.config_terminal import theme
from gamestonk_terminal.common.behavioural_analysis import finbrain_model
from gamestonk_terminal.config_plot import PLOT_DPI
@@ -20,6 +19,8 @@ from gamestonk_terminal.helper_funcs import (
print_rich_table,
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -118,7 +119,7 @@ def display_sentiment_analysis(
df_sentiment.sort_index(ascending=True, inplace=True)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
color_df = df_sentiment["Sentiment Analysis"].apply(
lambda_sentiment_coloring, last_val=0
)

View File

@@ -10,7 +10,6 @@ from typing import Union, Optional, List
import matplotlib.pyplot as plt
import pandas as pd
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.common.prediction_techniques import arima_model
from gamestonk_terminal.common.prediction_techniques.pred_helper import (
print_prediction_kpis,
@@ -26,6 +25,7 @@ from gamestonk_terminal.helper_funcs import (
print_rich_table,
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -283,7 +283,7 @@ def display_arima(
df_pred = df_pred.to_frame()
df_pred["Real"] = df_future.values
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_pred["Real"] = df_pred["Real"].astype(float)
df_pred["Prediction"] = df_pred["Prediction"].astype(float)
df_pred["Dif"] = 100 * (df_pred.Prediction - df_pred.Real) / df_pred.Real

View File

@@ -12,7 +12,6 @@ import numpy as np
import pandas as pd
from gamestonk_terminal.config_terminal import theme
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.common.prediction_techniques import ets_model
from gamestonk_terminal.common.prediction_techniques.pred_helper import (
lambda_price_prediction_backtesting_color,
@@ -28,6 +27,7 @@ from gamestonk_terminal.helper_funcs import (
plot_autoscale,
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -291,7 +291,7 @@ def display_exponential_smoothing(
df_pred = df_pred.to_frame()
df_pred["Real"] = df_future
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
patch_pandas_text_adjustment()

View File

@@ -28,10 +28,10 @@ from gamestonk_terminal.helper_funcs import (
print_rich_table,
)
from gamestonk_terminal import config_neural_network_models as cfg
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.config_terminal import theme
from gamestonk_terminal.config_plot import PLOT_DPI
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -559,7 +559,7 @@ def lambda_price_prediction_color(val: float, last_val: float) -> str:
def print_pretty_prediction(df_pred: pd.DataFrame, last_price: float):
"""Print predictions"""
console.print("")
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_pred = pd.DataFrame(df_pred)
df_pred.columns = ["pred"]
df_pred["pred"] = df_pred["pred"].apply(
@@ -588,7 +588,7 @@ def print_pretty_prediction(df_pred: pd.DataFrame, last_price: float):
def print_pretty_prediction_nn(df_pred: pd.DataFrame, last_price: float):
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
console.print(f"Actual price: [yellow]{last_price:.2f} $[/yellow]\n")
console.print("Prediction:")
console.print(

View File

@@ -9,7 +9,6 @@ import matplotlib.pyplot as plt
import pandas as pd
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.common.prediction_techniques import regression_model
from gamestonk_terminal.common.prediction_techniques.pred_helper import (
lambda_price_prediction_backtesting_color,
@@ -26,6 +25,7 @@ from gamestonk_terminal.helper_funcs import (
plot_autoscale,
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -246,7 +246,7 @@ def display_regression(
df_pred = df_pred.to_frame()
df_pred["Real"] = df_future
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
patch_pandas_text_adjustment()

View File

@@ -6,7 +6,6 @@ import os
import pandas as pd
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.common.behavioural_analysis.finbrain_model import get_sentiment
from gamestonk_terminal.common.behavioural_analysis.finbrain_view import (
plot_sentiment,
@@ -15,6 +14,7 @@ from gamestonk_terminal.common.behavioural_analysis.finbrain_view import (
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import export_data
from gamestonk_terminal.rich_config import console
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -57,7 +57,7 @@ def display_crypto_sentiment_analysis(coin: str, export: str) -> None:
plot_sentiment(df_sentiment, coin)
df_sentiment.sort_index(ascending=True, inplace=True)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
console.print(
df_sentiment["Sentiment Analysis"]
.apply(lambda_sentiment_coloring, last_val=0)

View File

@@ -13,9 +13,6 @@ USE_TABULATE_DF = strtobool(os.getenv("GTFF_USE_TABULATE_DF", "True"))
# Use clear console after each command
USE_CLEAR_AFTER_CMD = strtobool(os.getenv("GTFF_USE_CLEAR_AFTER_CMD", "False"))
# Use coloring features
USE_COLOR = strtobool(os.getenv("GTFF_USE_COLOR", "True"))
# Select console flair (choose from the list in helper_funcs.py)
USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or ":stars"
@@ -52,9 +49,6 @@ ENABLE_EXIT_AUTO_HELP = strtobool(os.getenv("GTFF_ENABLE_EXIT_AUTO_HELP", "False
# Remember contexts during session
REMEMBER_CONTEXTS = strtobool(os.getenv("GTFF_REMEMBER_CONTEXTS", "True"))
# Use the colorful rich terminal
ENABLE_RICH = strtobool(os.getenv("GTFF_ENABLE_RICH", "True"))
# Use the colorful rich terminal
ENABLE_RICH_PANEL = strtobool(os.getenv("GTFF_ENABLE_RICH_PANEL", "True"))

View File

@@ -1,11 +1,13 @@
"""Rich Module"""
__docformat__ = "numpy"
import os
from rich import panel
from rich.console import Console, Theme
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
# https://rich.readthedocs.io/en/stable/appendix/colors.html#appendix-colors
# https://rich.readthedocs.io/en/latest/highlighting.html#custom-highlighters
@@ -26,6 +28,8 @@ RICH_TAGS = [
"[/help]",
]
USE_COLOR = True
def no_panel(renderable, *args, **kwargs): # pylint: disable=unused-argument
return renderable
@@ -49,7 +53,7 @@ class ConsoleAndPanel:
def print(self, *args, **kwargs):
if kwargs and "text" in list(kwargs) and "menu" in list(kwargs):
if gtff.ENABLE_RICH:
if not os.getenv("TEST_MODE"):
if gtff.ENABLE_RICH_PANEL:
self.console.print(
panel.Panel(
@@ -64,14 +68,10 @@ class ConsoleAndPanel:
else:
print(self.filter_rich_tags(kwargs["text"]))
else:
if gtff.ENABLE_RICH:
if not os.getenv("TEST_MODE"):
self.console.print(*args, **kwargs)
else:
print(*args, **kwargs)
console = ConsoleAndPanel()
def disable_rich():
gtff.ENABLE_RICH = False

View File

@@ -81,8 +81,6 @@ class SettingsController(BaseController):
help_text += (
f" [{color}]cls clear console after each command[/{color}]\n"
)
color = "green" if gtff.USE_COLOR else "red"
help_text += f" [{color}]color use coloring features[/{color}]\n"
color = "green" if gtff.USE_PROMPT_TOOLKIT else "red"
help_text += f" [{color}]promptkit enable prompt toolkit (autocomplete and history)[/{color}]\n"
color = "green" if gtff.ENABLE_PREDICT else "red"
@@ -95,8 +93,6 @@ class SettingsController(BaseController):
help_text += f" [{color}]exithelp automatically print help when quitting menu[/{color}]\n"
color = "green" if gtff.REMEMBER_CONTEXTS else "red"
help_text += f" [{color}]rcontext remember contexts loaded params during session[/{color}]\n"
color = "green" if gtff.ENABLE_RICH else "red"
help_text += f" [{color}]rich colorful rich terminal[/{color}]\n"
color = "green" if gtff.ENABLE_RICH_PANEL else "red"
help_text += (
f" [{color}]richpanel colorful rich terminal panel[/{color}]\n"
@@ -160,13 +156,6 @@ class SettingsController(BaseController):
)
console.print("")
@log_start_end(log=logger)
def call_color(self, _):
"""Process color command"""
gtff.USE_COLOR = not gtff.USE_COLOR
dotenv.set_key(self.env_file, "GTFF_USE_COLOR", str(gtff.USE_COLOR))
console.print("")
@log_start_end(log=logger)
def call_promptkit(self, _):
"""Process promptkit command"""
@@ -226,13 +215,6 @@ class SettingsController(BaseController):
dotenv.set_key(self.env_file, "GTFF_USE_DATETIME", str(gtff.USE_DATETIME))
console.print("")
@log_start_end(log=logger)
def call_rich(self, _):
"""Process rich command"""
gtff.ENABLE_RICH = not gtff.ENABLE_RICH
dotenv.set_key(self.env_file, "GTFF_ENABLE_RICH", str(gtff.ENABLE_RICH))
console.print("")
@log_start_end(log=logger)
def call_richpanel(self, _):
"""Process richpanel command"""

View File

@@ -5,7 +5,6 @@ import logging
import os
from typing import List
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import (
export_data,
@@ -15,6 +14,7 @@ from gamestonk_terminal.helper_funcs import (
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.comparison_analysis import marketwatch_model
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -50,7 +50,7 @@ def display_income_comparison(
df_financials_compared,
)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials_compared = df_financials_compared.applymap(
lambda_financials_colored_values
)
@@ -99,7 +99,7 @@ def display_balance_comparison(
df_financials_compared,
)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials_compared = df_financials_compared.applymap(
lambda_financials_colored_values
)
@@ -151,7 +151,7 @@ def display_cashflow_comparison(
df_financials_compared,
)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials_compared = df_financials_compared.applymap(
lambda_financials_colored_values
)

View File

@@ -4,11 +4,11 @@ __docformat__ = "numpy"
import logging
import os
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.discovery import ark_model
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -74,7 +74,7 @@ def ark_orders_view(
if sort_col:
df_orders = df_orders.sort_values(by=sort_col, ascending=ascending)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_orders["direction"] = df_orders["direction"].apply(
lambda_direction_color_red_green
)

View File

@@ -7,11 +7,11 @@ import re
import pandas as pd
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.discovery import fidelity_model
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -79,7 +79,7 @@ def orders_view(num: int, export: str):
pd.set_option("display.max_colwidth", None)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_orders["Buy / Sell Ratio"] = df_orders["Buy / Sell Ratio"].apply(
lambda_buy_sell_ratio_color_red_green
)

View File

@@ -5,11 +5,11 @@ import logging
import os
from typing import Any, List
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import export_data, print_rich_table
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.due_diligence import finviz_model
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -74,7 +74,7 @@ def analyst(ticker: str, export: str = ""):
"""
df = finviz_model.get_analyst_data(ticker)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df["category"] = df["category"].apply(lambda_category_color_red_green)
print_rich_table(

View File

@@ -11,7 +11,6 @@ from typing import List
import pandas as pd
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import (
lambda_financials_colored_values,
@@ -21,6 +20,7 @@ from gamestonk_terminal.helper_funcs import (
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.fundamental_analysis import market_watch_model as mwm
from gamestonk_terminal import rich_config
# pylint: disable=too-many-branches
@@ -79,7 +79,7 @@ def income(other_args: List[str], ticker: str):
df_financials = mwm.prepare_df_financials(ticker, "income", ns_parser.b_quarter)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials = df_financials.applymap(lambda_financials_colored_values)
patch_pandas_text_adjustment()
@@ -156,7 +156,7 @@ def balance(other_args: List[str], ticker: str):
df_financials = mwm.prepare_df_financials(ticker, "balance", ns_parser.b_quarter)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials = df_financials.applymap(lambda_financials_colored_values)
patch_pandas_text_adjustment()
@@ -229,7 +229,7 @@ def cash(other_args: List[str], ticker: str):
df_financials = mwm.prepare_df_financials(ticker, "cashflow", ns_parser.b_quarter)
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
df_financials = df_financials.applymap(lambda_financials_colored_values)
patch_pandas_text_adjustment()

View File

@@ -9,7 +9,6 @@ import pandas as pd
import requests
from bs4 import BeautifulSoup
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import (
export_data,
@@ -21,6 +20,7 @@ from gamestonk_terminal.stocks.insider.openinsider_model import (
get_open_insider_data,
get_open_insider_link,
)
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -264,7 +264,7 @@ def print_insider_filter(
columns=["Filing Link", "Ticker Link", "Insider Link"]
).head(limit)
if gtff.USE_COLOR and not links:
if rich_config.USE_COLOR and not links:
if not df_insider[df_insider["Trade Type"] == "S - Sale"].empty:
df_insider[df_insider["Trade Type"] == "S - Sale"] = df_insider[
df_insider["Trade Type"] == "S - Sale"

View File

@@ -15,7 +15,6 @@ import seaborn as sns
from gamestonk_terminal.config_terminal import theme
from gamestonk_terminal import config_plot as cfp
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.helper_funcs import (
export_data,
@@ -25,6 +24,7 @@ from gamestonk_terminal.helper_funcs import (
)
from gamestonk_terminal.rich_config import console
from gamestonk_terminal.stocks.options import op_helpers, tradier_model
from gamestonk_terminal import rich_config
logger = logging.getLogger(__name__)
@@ -153,7 +153,7 @@ def display_chains(
puts_df = puts_df[puts_df.columns[::-1]]
chain_table = calls_df.merge(puts_df, on="strike")
if gtff.USE_COLOR:
if rich_config.USE_COLOR:
call_cols = [col for col in chain_table if col.endswith("_x")]
put_cols = [col for col in chain_table if col.endswith("_y")]
patch_pandas_text_adjustment()

View File

@@ -19,15 +19,6 @@
"default": false,
"value": ""
},
"GTFF_USE_COLOR":
{
"type": "bool",
"form": "checkbox",
"title": "Colors",
"description": "Use coloring features",
"default": true,
"value": ""
},
"GTFF_USE_FLAIR":
{
"type": "string",

View File

@@ -349,7 +349,6 @@ def log_settings() -> None:
settings_dict = {}
settings_dict["tab"] = "activated" if gtff.USE_TABULATE_DF else "deactivated"
settings_dict["cls"] = "activated" if gtff.USE_CLEAR_AFTER_CMD else "deactivated"
settings_dict["color"] = "activated" if gtff.USE_COLOR else "deactivated"
settings_dict["promptkit"] = (
"activated" if gtff.USE_PROMPT_TOOLKIT else "deactivated"
)
@@ -364,7 +363,6 @@ def log_settings() -> None:
"activated" if gtff.ENABLE_EXIT_AUTO_HELP else "deactivated"
)
settings_dict["rcontext"] = "activated" if gtff.REMEMBER_CONTEXTS else "deactivated"
settings_dict["rich"] = "activated" if gtff.ENABLE_RICH else "deactivated"
settings_dict["richpanel"] = (
"activated" if gtff.ENABLE_RICH_PANEL else "deactivated"
)

View File

@@ -17,7 +17,6 @@ from _pytest.mark.structures import Mark
# IMPORTATION INTERNAL
from gamestonk_terminal import decorators
from gamestonk_terminal import rich_config
from gamestonk_terminal import helper_funcs
@@ -31,6 +30,8 @@ EXTENSIONS_MATCHING: Dict[str, List[Type]] = {
"txt": [str],
}
os.environ["TEST_MODE"] = "True"
class Record:
@staticmethod
@@ -342,8 +343,6 @@ def brotli_check():
def disable_rich():
rich_config.disable_rich()
def effect(df, *xargs, **kwargs): # pylint: disable=unused-argument
print(df.to_string())
@@ -362,8 +361,8 @@ def pytest_configure(config: Config) -> None:
config.addinivalue_line("markers", "record_stdout: Mark the test as text record.")
brotli_check()
disable_rich()
enable_debug()
disable_rich()
disable_check_api()

View File

@@ -14,32 +14,32 @@ interactions:
uri: https://api.finbrain.tech/v0/sentiments/AAPL
response:
body:
string: '{"ticker":"AAPL","name":"Apple Inc.\r","sentimentAnalysis":{"2022-01-31":"-0.108","2022-01-28":"-0.097","2022-01-27":"0.301","2022-01-26":"-0.006","2022-01-25":"0.062","2022-01-24":"0.175","2022-01-21":"0.215","2022-01-20":"-0.062","2022-01-19":"0.313","2022-01-18":"0.244"}}'
string: '{"ticker":"AAPL","name":"Apple Inc.\r","sentimentAnalysis":{"2022-03-11":"0.069","2022-03-10":"0.206","2022-03-09":"-0.157","2022-03-08":"-0.309","2022-03-07":"0.129","2022-03-04":"-0.046","2022-03-03":"-0.245","2022-03-02":"-0.062","2022-03-01":"0.014","2022-02-28":"0.095"}}'
headers:
Connection:
- keep-alive
Content-Length:
- '275'
- '276'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 01 Feb 2022 00:30:03 GMT
- Mon, 14 Mar 2022 03:46:23 GMT
X-Amzn-Trace-Id:
- Root=1-61f87f0a-710723e13736fbc61c793c9b;Sampled=0
- Root=1-622eba8f-6ae4ca31342448fb6a4da34f;Sampled=0
access-control-allow-origin:
- '*'
etag:
- W/"113-JsF4I7O9Rz0xHyQHBNod6fHqCyA"
- W/"114-6eGu8gjokOhQsKD8+DjGvjRdJcE"
x-amz-apigw-id:
- M1jJvENGoAMF2qA=
- O9IWYFUFoAMFosw=
x-amzn-Remapped-connection:
- close
x-amzn-Remapped-content-length:
- '275'
- '276'
x-amzn-Remapped-date:
- Tue, 01 Feb 2022 00:30:03 GMT
- Mon, 14 Mar 2022 03:46:23 GMT
x-amzn-RequestId:
- d6c38d8b-bd0b-4323-8900-286a071d7905
- 4b9d1851-3b0e-46a1-b8cc-c33c674f4a48
x-powered-by:
- Express
status:

View File

@@ -6,6 +6,7 @@ import pytest
# IMPORTATION INTERNAL
from gamestonk_terminal.common.behavioural_analysis import finbrain_view
from gamestonk_terminal import helper_funcs
@pytest.mark.default_cassette("test_display_sentiment_analysis")
@@ -19,8 +20,10 @@ def test_display_sentiment_analysis(color, mocker):
)
# MOCK GTFF
mocker.patch.object(target=finbrain_view.gtff, attribute="USE_ION", new=True)
mocker.patch.object(target=finbrain_view.gtff, attribute="USE_COLOR", new=color)
mocker.patch.object(target=helper_funcs.gtff, attribute="USE_ION", new=True)
mocker.patch.object(
target=finbrain_view.rich_config, attribute="USE_COLOR", new=color
)
# MOCK VISUALIZE_OUTPUT
mocker.patch(
@@ -44,7 +47,7 @@ def test_display_sentiment_analysis_empty_df(mocker):
)
# MOCK GTFF
mocker.patch.object(target=finbrain_view.gtff, attribute="USE_ION", new=True)
mocker.patch.object(target=helper_funcs.gtff, attribute="USE_ION", new=True)
# MOCK GET_SENTIMENT
mocker.patch(

View File

@@ -0,0 +1,13 @@
0
date
2022-02-28 [green]0.095[/green]
2022-03-01 [green]0.014[/green]
2022-03-02 [red]-0.062[/red]
2022-03-03 [red]-0.245[/red]
2022-03-04 [red]-0.046[/red]
2022-03-07 [green]0.129[/green]
2022-03-08 [red]-0.309[/red]
2022-03-09 [red]-0.157[/red]
2022-03-10 [green]0.206[/green]
2022-03-11 [green]0.069[/green]

View File

@@ -1,13 +1,13 @@
0
date
2022-01-18 0.244
2022-01-19 0.313
2022-01-20 -0.062
2022-01-21 0.215
2022-01-24 0.175
2022-01-25 0.062
2022-01-26 -0.006
2022-01-27 0.301
2022-01-28 -0.097
2022-01-31 -0.108
2022-02-28 0.095
2022-03-01 0.014
2022-03-02 -0.062
2022-03-03 -0.245
2022-03-04 -0.046
2022-03-07 0.129
2022-03-08 -0.309
2022-03-09 -0.157
2022-03-10 0.206
2022-03-11 0.069

View File

@@ -1,13 +1,13 @@
0
date
2022-01-18 [green]0.244[/green]
2022-01-19 [green]0.313[/green]
2022-01-20 [red]-0.062[/red]
2022-01-21 [green]0.215[/green]
2022-01-24 [green]0.175[/green]
2022-01-25 [green]0.062[/green]
2022-01-26 [red]-0.006[/red]
2022-01-27 [green]0.301[/green]
2022-01-28 [red]-0.097[/red]
2022-01-31 [red]-0.108[/red]
2022-02-28 [green]0.095[/green]
2022-03-01 [green]0.014[/green]
2022-03-02 [red]-0.062[/red]
2022-03-03 [red]-0.245[/red]
2022-03-04 [red]-0.046[/red]
2022-03-07 [green]0.129[/green]
2022-03-08 [red]-0.309[/red]
2022-03-09 [red]-0.157[/red]
2022-03-10 [green]0.206[/green]
2022-03-11 [green]0.069[/green]

View File

@@ -14,22 +14,15 @@ def vcr_config():
}
@pytest.mark.default_cassette("test_display_income_comparison")
@pytest.mark.vcr
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"tab",
[True, False],
)
def test_display_income_comparison(mocker, tab):
def test_display_income_comparison(mocker):
mocker.patch.object(
target=marketwatch_view.gtff,
target=marketwatch_view.rich_config,
attribute="USE_COLOR",
new=True,
)
mocker.patch.object(
target=marketwatch_view.gtff, attribute="USE_TABULATE_DF", new=tab
)
marketwatch_view.display_income_comparison(
similar=["TSLA", "GM"],
timeframe="31-Dec-2020",
@@ -38,22 +31,15 @@ def test_display_income_comparison(mocker, tab):
)
@pytest.mark.default_cassette("test_display_balance_comparison")
@pytest.mark.vcr
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"tab",
[True, False],
)
def test_display_balance_comparison(mocker, tab):
def test_display_balance_comparison(mocker):
mocker.patch.object(
target=marketwatch_view.gtff,
target=marketwatch_view.rich_config,
attribute="USE_COLOR",
new=True,
)
mocker.patch.object(
target=marketwatch_view.gtff, attribute="USE_TABULATE_DF", new=tab
)
marketwatch_view.display_balance_comparison(
similar=["TSLA", "GM"],
timeframe="31-Dec-2020",
@@ -62,22 +48,14 @@ def test_display_balance_comparison(mocker, tab):
)
@pytest.mark.default_cassette("test_display_cashflow_comparison")
@pytest.mark.vcr
@pytest.mark.record_stdout
@pytest.mark.parametrize(
"tab",
[True, False],
)
def test_display_cashflow_comparison(mocker, tab):
def test_display_cashflow_comparison(mocker):
mocker.patch.object(
target=marketwatch_view.gtff,
target=marketwatch_view.rich_config,
attribute="USE_COLOR",
new=True,
)
mocker.patch.object(
target=marketwatch_view.gtff, attribute="USE_TABULATE_DF", new=tab
)
marketwatch_view.display_cashflow_comparison(
similar=["TSLA", "GM"],
timeframe="31-Dec-2020",

View File

@@ -0,0 +1,42 @@
Other available quarterly timeframes are: 31-Dec-2020, 31-Mar-2021, 30-Jun-2021, 30-Sep-2021, 31-Dec-2021
31-Dec-2020
TSLA GM
Item
Cash & Short Term Investments 19.62B 31.62B
Cash & Short Term Investments Growth - -
Cash Only 19.62B 22.57B
Short-Term Investments - -
Cash & ST Investments / Total Assets [green]37.63%[/green] [green]13.44%[/green]
Total Accounts Receivable 1.89B 34.24B
Total Accounts Receivable Growth - -
Accounts Receivables, Net 1.89B 34.24B
Accounts Receivables, Gross 1.89B 34.47B
Bad Debt/Doubtful Accounts - [red](224M)[/red]
Other Receivable - -
Accounts Receivable Turnover 5.70 1.10
Inventories 4.1B 10.24B
Finished Goods 1.67B 5.12B
Work in Progress 493M -
Raw Materials 1.94B 5.12B
Progress Payments & Other - -
Other Current Assets 1.11B 4.83B
Miscellaneous Current Assets 1.11B 4.83B
Total Current Assets 26.72B 80.92B
Net Property, Plant & Equipment 23.38B 78.45B
Property, Plant & Equipment - Gross 29.89B 106.27B
Buildings - -
Land & Improvements - -
Computer Software and Equipment 856M -
Other Property, Plant & Equipment - -
Accumulated Depreciation 6.52B 27.82B
Total Investments and Advances 279M 8.95B
Other Long-Term Investments 279M 544M
Long-Term Note Receivables 334M 31.78B
Intangible Assets 520M 5.23B
Net Goodwill 207M 1.91B
Net Other Intangibles 313M 3.32B
Other Assets 923M 5.72B
Total Assets 52.15B 235.19B
Total Assets Growth - -

View File

@@ -0,0 +1,24 @@
Other available quarterly timeframes are: 31-Dec-2020, 31-Mar-2021, 30-Jun-2021, 30-Sep-2021, 31-Dec-2021
31-Dec-2020
TSLA GM
Item
Net Income before Extraordinaries 296M 2.93B
Net Income Growth - -
Depreciation, Depletion & Amortization 618M 3.2B
Depreciation and Depletion - -
Amortization of Intangible Assets - -
Deferred Taxes & Investment Tax Credit - -
Deferred Taxes - 225M
Investment Tax Credit - -
Other Funds 863M 32M
Funds from Operations 1.78B 6.39B
Extraordinaries - -
Changes in Working Capital 1.24B 303M
Receivables [red](102M)[/red] -
Accounts Payable 1.34B -
Other Assets/Liabilities 259M 823M
Net Operating Cash Flow 3.02B 6.69B
Net Operating Cash Flow Growth - -
Net Operating Cash Flow / Sales [green]28.10%[/green] [green]17.84%[/green]

View File

@@ -0,0 +1,63 @@
Other available quarterly timeframes are: 31-Dec-2020, 31-Mar-2021, 30-Jun-2021, 30-Sep-2021, 31-Dec-2021
31-Dec-2020
TSLA GM
Item
Sales/Revenue 10.74B 37.52B
Sales Growth - -
Cost of Goods Sold (COGS) incl. D&A 8.68B 32.52B
COGS Growth - -
COGS excluding D&A 8.06B 29.46B
Depreciation & Amortization Expense 618M 3.06B
Depreciation - -
Amortization of Intangibles - -
Gross Income 2.07B 5B
Gross Income Growth - -
Gross Profit Margin - -
SG&A Expense 1.49B 2.13B
SGA Growth - -
Research & Development 522M -
Other SG&A 969M 2.13B
Other Operating Expense - -
Unusual Expense [red](5M)[/red] [red](521M)[/red]
EBIT after Unusual Expense 5M 521M
Non Operating Income/Expense 39M [red](5M)[/red]
Non-Operating Interest Income 6M 46M
Equity in Affiliates (Pretax) - 285M
Interest Expense 246M 275M
Interest Expense Growth - -
Gross Interest Expense 261M 275M
Interest Capitalized 15M -
Pretax Income 379M 3.44B
Pretax Income Growth - -
Pretax Margin - -
Income Tax 83M 642M
Income Tax - Current Domestic - -
Income Tax - Current Foreign - -
Income Tax - Deferred Domestic - -
Income Tax - Deferred Foreign - -
Income Tax Credits - -
Equity in Affiliates - -
Other After Tax Income (Expense) - -
Consolidated Net Income 296M 2.8B
Minority Interest Expense 26M [red](49M)[/red]
Net Income 270M 2.85B
Net Income Growth - -
Net Margin Growth - -
Extraordinaries & Discontinued Operations - -
Extra Items & Gain/Loss Sale Of Assets - -
Cumulative Effect - Accounting Chg - -
Discontinued Operations - -
Net Income After Extraordinaries 270M 2.85B
Preferred Dividends - 45M
Net Income Available to Common 270M 2.8B
EPS (Basic) 0.28 1.95
EPS (Basic) Growth - -
Basic Shares Outstanding 960M 1.44B
EPS (Diluted) 0.24 1.93
EPS (Diluted) Growth - -
Diluted Shares Outstanding 1.12B 1.45B
EBITDA 1.19B 5.93B
EBITDA Growth - -
EBITDA Margin - -

View File

@@ -51,7 +51,9 @@ def test_ark_orders_view(kwargs_dict, mocker, use_color):
mocker.patch("yfinance.download", side_effect=mock_yf_download)
mocker.patch.object(target=ark_view.gtff, attribute="USE_COLOR", new=use_color)
mocker.patch.object(
target=ark_view.rich_config, attribute="USE_COLOR", new=use_color
)
ark_view.ark_orders_view(**kwargs_dict)

View File

@@ -45,5 +45,7 @@ def test_lambda_price_change_color_red_green(val, recorder):
[True, False],
)
def test_orders_view(mocker, use_color):
mocker.patch.object(target=fidelity_view.gtff, attribute="USE_COLOR", new=use_color)
mocker.patch.object(
target=fidelity_view.rich_config, attribute="USE_COLOR", new=use_color
)
fidelity_view.orders_view(num=1, export="")

View File

@@ -7,6 +7,7 @@ import pytest
# IMPORTATION INTERNAL
from gamestonk_terminal.stocks.fundamental_analysis import market_watch_view
from gamestonk_terminal import helper_funcs
# pylint: disable=maybe-no-member
@@ -53,7 +54,7 @@ def test_call_func_no_parser(func, mocker):
[True, False],
)
def test_call_func(func, monkeypatch, use_color):
monkeypatch.setattr(market_watch_view.gtff, "USE_COLOR", use_color)
monkeypatch.setattr(market_watch_view.rich_config, "USE_COLOR", use_color)
getattr(market_watch_view, func)(other_args=list(), ticker="TSLA")
@@ -96,5 +97,5 @@ def test_display_sean_seah_warnings_empty_df(mocker):
[True, False],
)
def test_display_sean_seah_warnings(debug, monkeypatch, use_tab):
monkeypatch.setattr(market_watch_view.gtff, "USE_TABULATE_DF", use_tab)
monkeypatch.setattr(helper_funcs.gtff, "USE_TABULATE_DF", use_tab)
market_watch_view.display_sean_seah_warnings(ticker="GME", debug=debug)

View File

@@ -67,7 +67,9 @@ def test_print_insider_filter_no_table(mocker):
)
def test_print_insider_data(color, mocker):
# MOCK GTFF
mocker.patch.object(target=openinsider_view.gtff, attribute="USE_COLOR", new=color)
mocker.patch.object(
target=openinsider_view.rich_config, attribute="USE_COLOR", new=color
)
# MOCK EXPORT_DATA
mocker.patch(

View File

@@ -48,7 +48,9 @@ def test_display_chains(calls_only, max_sp, min_sp, mocker, puts_only):
mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")
# MOCK USE_COLOR
mocker.patch.object(target=tradier_view.gtff, attribute="USE_COLOR", new=True)
mocker.patch.object(
target=tradier_view.rich_config, attribute="USE_COLOR", new=True
)
tradier_view.display_chains(
ticker="AAPL",
@@ -85,7 +87,9 @@ def test_plot_oi(calls_only, max_sp, min_sp, mocker, puts_only):
mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")
# MOCK USE_COLOR
mocker.patch.object(target=tradier_view.gtff, attribute="USE_COLOR", new=True)
mocker.patch.object(
target=tradier_view.rich_config, attribute="USE_COLOR", new=True
)
tradier_view.plot_oi(
ticker="AAPL",
@@ -121,7 +125,9 @@ def test_plot_vol(calls_only, max_sp, min_sp, mocker, puts_only):
mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")
# MOCK USE_COLOR
mocker.patch.object(target=tradier_view.gtff, attribute="USE_COLOR", new=True)
mocker.patch.object(
target=tradier_view.rich_config, attribute="USE_COLOR", new=True
)
tradier_view.plot_vol(
ticker="AAPL",
@@ -153,7 +159,9 @@ def test_plot_volume_open_interest(max_sp, min_sp, min_vol, mocker):
mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")
# MOCK USE_COLOR
mocker.patch.object(target=tradier_view.gtff, attribute="USE_COLOR", new=True)
mocker.patch.object(
target=tradier_view.rich_config, attribute="USE_COLOR", new=True
)
tradier_view.plot_volume_open_interest(
ticker="AAPL",
@@ -177,7 +185,9 @@ def test_display_historical(mocker):
mocker.patch(target="gamestonk_terminal.stocks.options.tradier_view.export_data")
# MOCK USE_COLOR
mocker.patch.object(target=tradier_view.gtff, attribute="USE_COLOR", new=True)
mocker.patch.object(
target=tradier_view.rich_config, attribute="USE_COLOR", new=True
)
tradier_view.display_historical(
ticker="AAPL",