mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
Pylint fixes for gamestonk_terminal/prediction_techniques/arima.py and fbprophet.py
This commit is contained in:
@@ -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("")
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user