Merge pull request #158 from DidierRLopes/disable-ion

Add Feature Flags and disable prompt_toolkit by default due to conflict with ion
This commit is contained in:
Artem Veremey
2021-03-12 11:31:36 -08:00
committed by GitHub
26 changed files with 145 additions and 51 deletions

View File

@@ -136,9 +136,9 @@ Note: The libraries specified in the [requirements.txt](/requirements.txt) file
*If you would like to use optional Machine Learning features:*
* Update your [config_terminal.py](/gamestonk_terminal/config_terminal.py) with:
* Update your [feature_flags.py](/gamestonk_terminal/feature_flags.py) with:
```
ENABLE_PREDICT = False
ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT") or True
```
* Install optional ML features dependencies collection with poetry:

View File

@@ -25,9 +25,3 @@ API_POLYGON_KEY = os.getenv("GT_API_POLYGON_KEY") or "REPLACE_ME"
API_TWITTER_KEY = os.getenv("GT_API_TWITTER_KEY") or "REPLACE_ME"
API_TWITTER_SECRET_KEY = os.getenv("GT_API_TWITTER_SECRET_KEY") or "REPLACE_ME"
API_TWITTER_BEARER_TOKEN = os.getenv("GT_API_TWITTER_BEARER_TOKEN") or "REPLACE_ME"
USE_COLOR = True
USE_FLAIR = "stars"
# Enable Prediction features
ENABLE_PREDICT = False

View File

@@ -15,7 +15,7 @@ from gamestonk_terminal.helper_funcs import (
patch_pandas_text_adjustment,
parse_known_args_and_warn,
)
from gamestonk_terminal.config_terminal import USE_COLOR
from gamestonk_terminal import feature_flags as gtff
def direction_color_red_green(val: str) -> str:
@@ -119,7 +119,7 @@ def ark_orders(l_args):
pd.set_option("mode.chained_assignment", None)
df_orders = add_order_total(df_orders.head(ns_parser.n_num))
if USE_COLOR:
if gtff.USE_COLOR:
df_orders["direction"] = df_orders["direction"].apply(direction_color_red_green)
patch_pandas_text_adjustment()

View File

@@ -12,6 +12,7 @@ from gamestonk_terminal.discovery import (
unusual_whales_api,
yahoo_finance_api,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import get_flair
from gamestonk_terminal.menu import session
from prompt_toolkit.completion import NestedCompleter
@@ -74,7 +75,7 @@ def disc_menu():
# Loop forever and ever
while True:
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(
f"{get_flair()} (disc)> ",
completer=completer,

View File

@@ -11,7 +11,7 @@ from gamestonk_terminal.helper_funcs import (
patch_pandas_text_adjustment,
parse_known_args_and_warn,
)
from gamestonk_terminal.config_terminal import USE_COLOR
from gamestonk_terminal import feature_flags as gtff
def buy_sell_ratio_color_red_green(val: str) -> str:
@@ -137,7 +137,7 @@ def orders(l_args):
pd.set_option("display.max_colwidth", None)
if USE_COLOR:
if gtff.USE_COLOR:
df_orders["Buy / Sell Ratio"] = df_orders["Buy / Sell Ratio"].apply(
buy_sell_ratio_color_red_green
)

View File

@@ -6,6 +6,7 @@ from gamestonk_terminal.due_diligence import finviz_api as fvz_api
from gamestonk_terminal.due_diligence import market_watch_api as mw_api
from gamestonk_terminal.due_diligence import quandl_api as q_api
from gamestonk_terminal.due_diligence import reddit_api as r_api
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import get_flair
from gamestonk_terminal.menu import session
from prompt_toolkit.completion import NestedCompleter
@@ -74,7 +75,7 @@ def dd_menu(df_stock, s_ticker, s_start, s_interval):
# Loop forever and ever
while True:
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(
f"{get_flair()} (dd)> ",
completer=completer,

View File

@@ -0,0 +1,9 @@
import os
USE_COLOR = os.getenv("GTFF_USE_COLOR") or True
USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars"
USE_ION = os.getenv("GTFF_USE_ION") or True
USE_PROMPT_TOOLKIT = os.getenv("GTFF_USE_PROMPT_TOOLKIT") or False
# Enable Prediction features
ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT") or False

View File

@@ -12,7 +12,7 @@ import pandas as pd
import pandas.io.formats.format
from pandas._config.config import get_option
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -53,6 +53,10 @@ def plot_view_stock(df, symbol):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -349,7 +353,7 @@ def get_flair() -> str:
"yy": "(☯)",
}
if flair.get(cfg.USE_FLAIR):
return flair[cfg.USE_FLAIR]
if flair.get(gtff.USE_FLAIR):
return flair[gtff.USE_FLAIR]
return ""

View File

@@ -11,6 +11,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -150,7 +152,10 @@ def arima(l_args, s_ticker, df_stock):
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -11,6 +11,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
trend = "Ad" # Additive damped, A Additive, N None
@@ -165,7 +167,10 @@ def exponential_smoothing(l_args, s_ticker, df_stock):
linestyle="--",
color="k",
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -10,6 +10,8 @@ from gamestonk_terminal.helper_funcs import (
parse_known_args_and_warn,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
warnings.simplefilter("ignore")
@@ -81,7 +83,10 @@ def fbprophet(l_args, s_ticker, df_stock):
df_stock["ds"].values[0], get_next_stock_market_days(l_pred_days[-1], 1)[-1]
)
plt.title(f"Fb Prophet on {s_ticker} - {ns_parser.n_days} days prediction")
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -11,6 +11,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -118,7 +120,10 @@ def k_nearest_neighbors(l_args, s_ticker, df_stock):
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -17,6 +17,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal import config_neural_network_models as cfg_nn_models
@@ -253,7 +255,10 @@ def mlp(l_args, s_ticker, df_stock):
linestyle="--",
color="k",
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data
@@ -443,7 +448,10 @@ def rnn(l_args, s_ticker, df_stock):
linestyle="--",
color="k",
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data
@@ -633,7 +641,10 @@ def lstm(l_args, s_ticker, df_stock):
linestyle="--",
color="k",
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -1,6 +1,7 @@
import argparse
import matplotlib.pyplot as plt
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import get_flair
from gamestonk_terminal.menu import session
from gamestonk_terminal.prediction_techniques import (
@@ -74,7 +75,7 @@ def pred_menu(df_stock, s_ticker, s_start, s_interval):
# Loop forever and ever
while True:
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(
f"{get_flair()} (pred)> ",
completer=completer,

View File

@@ -14,6 +14,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
USER_INPUT = 0
@@ -137,7 +139,10 @@ def regression(l_args, s_ticker, df_stock, polynomial):
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -11,6 +11,8 @@ from gamestonk_terminal.helper_funcs import (
print_pretty_prediction,
)
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -101,7 +103,10 @@ def simple_moving_average(l_args, s_ticker, df_stock):
plt.vlines(
df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k"
)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
# Print prediction data

View File

@@ -1,6 +1,6 @@
import argparse
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import get_flair
from gamestonk_terminal.menu import session
from gamestonk_terminal.sentiment import google_api, reddit_api, stocktwits_api
@@ -78,7 +78,7 @@ def sen_menu(s_ticker, s_start):
# Loop forever and ever
while True:
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(
f"{get_flair()} (sen)> ",
completer=completer,
@@ -136,7 +136,7 @@ def sen_menu(s_ticker, s_start):
# ----------------------------------------------------- TWITTER -------------------------------------------------
elif ns_known_args.cmd == "infer":
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
print("Predict is not enabled in config_terminal.py")
print("Twitter inference menu is disabled")
print("")
@@ -159,7 +159,7 @@ def sen_menu(s_ticker, s_start):
twitter_api.inference(l_args, s_ticker)
elif ns_known_args.cmd == "sentiment":
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
print("Predict is not enabled in config_terminal.py")
print("Twitter sentiment menu is disabled")
print("")

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas_ta as ta
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, parse_known_args_and_warn
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -101,7 +102,10 @@ def cci(l_args, s_ticker, s_interval, df_stock):
plt.gca().twinx()
plt.ylim(plt.gca().get_ylim())
plt.yticks([0.2, 0.8], ("OVERSOLD", "OVERBOUGHT"))
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -217,7 +221,10 @@ def macd(l_args, s_ticker, s_interval, df_stock):
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.xlabel("Time")
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -328,7 +335,10 @@ def rsi(l_args, s_ticker, s_interval, df_stock):
plt.gca().twinx()
plt.ylim(plt.gca().get_ylim())
plt.yticks([0.15, 0.85], ("OVERSOLD", "OVERBOUGHT"))
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -446,7 +456,10 @@ def stoch(l_args, s_ticker, s_interval, df_stock):
plt.gca().twinx()
plt.ylim(plt.gca().get_ylim())
plt.yticks([0.1, 0.9], ("OVERSOLD", "OVERBOUGHT"))
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas_ta as ta
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, parse_known_args_and_warn
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -96,7 +97,10 @@ def ema(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -171,7 +175,10 @@ def sma(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -257,7 +264,10 @@ def vwap(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -1,6 +1,7 @@
import argparse
import matplotlib.pyplot as plt
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import get_flair
from gamestonk_terminal.menu import session
from gamestonk_terminal.technical_analysis import momentum as ta_momentum
@@ -74,7 +75,7 @@ def ta_menu(df_stock, s_ticker, s_start, s_interval):
# Loop forever and ever
while True:
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(
f"{get_flair()} (ta)> ",
completer=completer,

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas_ta as ta
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, parse_known_args_and_warn
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -121,7 +122,10 @@ def plot_adx(df_stock, s_ticker, df_ta):
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ylim([0, 100])
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
@@ -221,7 +225,10 @@ def aroon(l_args, s_ticker, s_interval, df_stock):
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ylim([-100, 100])
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas_ta as ta
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, parse_known_args_and_warn
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -106,7 +107,10 @@ def bbands(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas_ta as ta
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, parse_known_args_and_warn
from gamestonk_terminal import feature_flags as gtff
register_matplotlib_converters()
@@ -129,7 +130,10 @@ def ad(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")
@@ -222,7 +226,10 @@ def obv(l_args, s_ticker, s_interval, df_stock):
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)
plt.ion()
if gtff.USE_ION:
plt.ion()
plt.show()
print("")

View File

@@ -7,6 +7,7 @@ from alpha_vantage.timeseries import TimeSeries
from prompt_toolkit.completion import NestedCompleter
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal import res_menu as rm
from gamestonk_terminal.discovery import disc_menu as dm
from gamestonk_terminal.due_diligence import dd_menu as ddm
@@ -77,7 +78,7 @@ def main():
should_print_help = False
# Get input command from user
if session:
if session and gtff.USE_PROMPT_TOOLKIT:
as_input = session.prompt(f"{get_flair()}> ", completer=completer)
else:
as_input = input(f"{get_flair()}> ")
@@ -148,7 +149,7 @@ def main():
elif ns_known_args.opt == "pred":
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
print("Predict is not enabled in config_terminal.py")
print("Prediction menu is disabled")
print("")

View File

@@ -8,12 +8,12 @@ except ModuleNotFoundError as e:
print(e)
print("Skipping the test")
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
class TestPredNeuralNetworks(unittest.TestCase):
def test_mlp(self):
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
return
# Fix: need to come up with a better way of doing this

View File

@@ -10,19 +10,19 @@ except ModuleNotFoundError as e:
print(e)
print("Skipping the test")
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import feature_flags as gtff
class TestSentimentTwitterApi(unittest.TestCase):
def test_inference(self):
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
return
# Fix: implement a better twitter client
# inference([], "PLTR")
return
def test_sentiment(self):
if not cfg.ENABLE_PREDICT:
if not gtff.ENABLE_PREDICT:
return
# Fix: implement a better twitter client
# sentiment([], "PLTR")