From 66f4b2f50a19496eabdfb2fd7522f589a093a044 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Tue, 2 Mar 2021 19:53:23 -0800 Subject: [PATCH] Pylint fixes for gamestonk_terminal/prediction_techniques/arima.py and fbprophet.py --- .../prediction_techniques/arima.py | 34 +++++++++++-------- .../prediction_techniques/fbprophet.py | 28 +++++++-------- gamestonk_terminal/sentiment/reddit_api.py | 6 ++-- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/gamestonk_terminal/prediction_techniques/arima.py b/gamestonk_terminal/prediction_techniques/arima.py index e1c784ff79b..a66cbf847ae 100644 --- a/gamestonk_terminal/prediction_techniques/arima.py +++ b/gamestonk_terminal/prediction_techniques/arima.py @@ -1,26 +1,29 @@ import argparse -from gamestonk_terminal.helper_funcs import * -import pandas as pd import matplotlib.pyplot as plt +import pandas as pd from pandas.plotting import register_matplotlib_converters - -register_matplotlib_converters() import pmdarima from statsmodels.tsa.arima.model import ARIMA +from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days + +register_matplotlib_converters() # -------------------------------------------------- ARIMA -------------------------------------------------- +# pylint: disable=unused-argument def arima(l_args, s_ticker, s_interval, df_stock): parser = argparse.ArgumentParser( prog="arima", - description="""In statistics and econometrics, and in particular in time - series analysis, an autoregressive integrated moving average (ARIMA) model - is a generalization of an autoregressive moving average (ARMA) model. Both - of these models are fitted to time series data either to better understand - the data or to predict future points in the series (forecasting). - ARIMA(p,d,q) where parameters p, d, and q are non-negative integers, p is - the order (number of time lags) of the autoregressive model, d is the degree - of differencing (the number of times the data have had past values subtracted), - and q is the order of the moving-average model.""", + description=""" + In statistics and econometrics, and in particular in time + series analysis, an autoregressive integrated moving average (ARIMA) model + is a generalization of an autoregressive moving average (ARMA) model. Both + of these models are fitted to time series data either to better understand + the data or to predict future points in the series (forecasting). + ARIMA(p,d,q) where parameters p, d, and q are non-negative integers, p is + the order (number of time lags) of the autoregressive model, d is the degree + of differencing (the number of times the data have had past values subtracted), + and q is the order of the moving-average model. + """, ) parser.add_argument( @@ -140,7 +143,7 @@ def arima(l_args, s_ticker, s_interval, df_stock): plt.axvspan( df_stock.index[-1], df_pred.index[-1], facecolor="tab:orange", alpha=0.2 ) - xmin, xmax, ymin, ymax = plt.axis() + _, _, ymin, ymax = plt.axis() plt.vlines( df_stock.index[-1], ymin, ymax, linewidth=1, linestyle="--", color="k" ) @@ -152,5 +155,6 @@ def arima(l_args, s_ticker, s_interval, df_stock): print(df_pred.to_string()) print("") - except: + except Exception as e: + print(e) print("") diff --git a/gamestonk_terminal/prediction_techniques/fbprophet.py b/gamestonk_terminal/prediction_techniques/fbprophet.py index 8f6081f4b3a..c92ae42f704 100644 --- a/gamestonk_terminal/prediction_techniques/fbprophet.py +++ b/gamestonk_terminal/prediction_techniques/fbprophet.py @@ -1,26 +1,25 @@ import argparse -import numpy as np -import pandas as pd +import warnings import matplotlib.pyplot as plt +import pandas as pd from pandas.plotting import register_matplotlib_converters +from fbprophet import Prophet +from gamestonk_terminal.helper_funcs import check_positive, get_next_stock_market_days register_matplotlib_converters() -import datetime -from datetime import datetime -from alpha_vantage.timeseries import TimeSeries -from gamestonk_terminal.helper_funcs import * -from fbprophet import Prophet -import warnings warnings.simplefilter("ignore") # ----------------------------------------------------- FBPROPHET ----------------------------------------------------- +# pylint: disable=unused-argument def fbprophet(l_args, s_ticker, s_interval, df_stock): parser = argparse.ArgumentParser( prog="fbprophet", - description="""Facebook Prophet is a forecasting procedure that is fast and provides - completely automated forecasts that can be tuned by hand by data scientists and analysts. - It was developed by Facebook's data science team and is open source. """, + description=""" + Facebook Prophet is a forecasting procedure that is fast and provides + completely automated forecasts that can be tuned by hand by data scientists and analysts. + It was developed by Facebook's data science team and is open source. + """, ) parser.add_argument( @@ -56,9 +55,9 @@ def fbprophet(l_args, s_ticker, s_interval, df_stock): close_prices = model.make_future_dataframe(periods=ns_parser.n_days) forecast = model.predict(close_prices) - fig, ax = plt.subplots() + _, ax = plt.subplots() model.plot(forecast, ax=ax, xlabel="Time", ylabel="Share Price ($)") - xmin, xmax, ymin, ymax = ax.axis() + _, _, ymin, ymax = ax.axis() ax.vlines( df_stock["ds"].values[-1], ymin, @@ -87,5 +86,6 @@ def fbprophet(l_args, s_ticker, s_interval, df_stock): print(df_pred.to_string()) print("") - except: + except Exception as e: + print(e) print("") diff --git a/gamestonk_terminal/sentiment/reddit_api.py b/gamestonk_terminal/sentiment/reddit_api.py index 102692a7ccb..dbb788d4620 100644 --- a/gamestonk_terminal/sentiment/reddit_api.py +++ b/gamestonk_terminal/sentiment/reddit_api.py @@ -241,8 +241,10 @@ def popular_tickers(l_args): action="store", dest="s_subreddit", type=str, - help="""subreddits to look for tickers, e.g. pennystocks,stocks. - Default: pennystocks, RobinHoodPennyStocks, Daytrading, StockMarket, stocks, investing, wallstreetbets""", + help=""" + subreddits to look for tickers, e.g. pennystocks,stocks. + Default: pennystocks, RobinHoodPennyStocks, Daytrading, StockMarket, stocks, investing, wallstreetbets + """, ) parser.add_argument( "-d",