From a0a22ee2cff2be0f062de0ec60bf096e2cb1a51a Mon Sep 17 00:00:00 2001 From: Didier Rodrigues Lopes Date: Thu, 23 Dec 2021 16:25:18 +0000 Subject: [PATCH] Discordbot Technical Analysis (#1089) * fix bug with window size on discordbot * pylint and black fixes * black linter --- discordbot/stocks/government/contracts.py | 6 ++--- discordbot/stocks/government/gtrades.py | 6 ++--- discordbot/stocks/government/histcont.py | 6 ++--- discordbot/stocks/government/lastcontracts.py | 3 +-- discordbot/stocks/government/lasttrades.py | 4 ++-- discordbot/stocks/government/lobbying.py | 4 ++-- discordbot/stocks/government/qtrcontracts.py | 6 ++--- discordbot/stocks/government/topbuys.py | 6 ++--- discordbot/stocks/government/toplobbying.py | 6 ++--- discordbot/stocks/government/topsells.py | 6 ++--- discordbot/stocks/technical_analysis/ad.py | 8 +++---- discordbot/stocks/technical_analysis/adosc.py | 8 +++---- discordbot/stocks/technical_analysis/adx.py | 8 +++---- discordbot/stocks/technical_analysis/aroon.py | 8 +++---- .../stocks/technical_analysis/bbands.py | 8 +++---- discordbot/stocks/technical_analysis/cci.py | 8 +++---- discordbot/stocks/technical_analysis/cg.py | 8 +++---- .../stocks/technical_analysis/donchian.py | 8 +++---- discordbot/stocks/technical_analysis/ema.py | 23 ++++++++----------- discordbot/stocks/technical_analysis/fib.py | 8 +++---- .../stocks/technical_analysis/fisher.py | 8 +++---- discordbot/stocks/technical_analysis/hma.py | 23 ++++++++----------- discordbot/stocks/technical_analysis/kc.py | 8 +++---- discordbot/stocks/technical_analysis/macd.py | 8 +++---- discordbot/stocks/technical_analysis/obv.py | 8 +++---- discordbot/stocks/technical_analysis/recom.py | 3 ++- discordbot/stocks/technical_analysis/rsi.py | 8 +++---- discordbot/stocks/technical_analysis/sma.py | 23 ++++++++----------- discordbot/stocks/technical_analysis/stoch.py | 8 +++---- .../stocks/technical_analysis/summary.py | 3 ++- discordbot/stocks/technical_analysis/view.py | 7 +++--- discordbot/stocks/technical_analysis/wma.py | 23 ++++++++----------- discordbot/stocks/technical_analysis/zlma.py | 23 ++++++++----------- 33 files changed, 143 insertions(+), 158 deletions(-) diff --git a/discordbot/stocks/government/contracts.py b/discordbot/stocks/government/contracts.py index 5c719908ac68..051473fa1324 100644 --- a/discordbot/stocks/government/contracts.py +++ b/discordbot/stocks/government/contracts.py @@ -3,13 +3,13 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def contracts_command(ctx, ticker="", past_transaction_days="", raw=""): """Displays contracts associated with tickers [quiverquant.com]""" diff --git a/discordbot/stocks/government/gtrades.py b/discordbot/stocks/government/gtrades.py index bb15edc69dd2..20b767ca33c2 100644 --- a/discordbot/stocks/government/gtrades.py +++ b/discordbot/stocks/government/gtrades.py @@ -5,13 +5,13 @@ import matplotlib.dates as mdates import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def gtrades_command( ctx, ticker="", gov_type="", past_transactions_months="", raw="" diff --git a/discordbot/stocks/government/histcont.py b/discordbot/stocks/government/histcont.py index b9d5a933e03d..948051a3da38 100644 --- a/discordbot/stocks/government/histcont.py +++ b/discordbot/stocks/government/histcont.py @@ -3,13 +3,13 @@ from matplotlib import pyplot as plt import numpy as np -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def histcont_command(ctx, ticker=""): """Displays historical quarterly-contracts [quiverquant.com]""" diff --git a/discordbot/stocks/government/lastcontracts.py b/discordbot/stocks/government/lastcontracts.py index 9f35d25b4205..a352d6b85fdc 100644 --- a/discordbot/stocks/government/lastcontracts.py +++ b/discordbot/stocks/government/lastcontracts.py @@ -1,11 +1,10 @@ import discord import pandas as pd +from gamestonk_terminal.stocks.government import quiverquant_model import discordbot.config_discordbot as cfg from discordbot.helpers import pagination -from gamestonk_terminal.stocks.government import quiverquant_model - async def lastcontracts_command(ctx, past_transactions_days="", num=""): """Displays last government contracts [quiverquant.com]""" diff --git a/discordbot/stocks/government/lasttrades.py b/discordbot/stocks/government/lasttrades.py index faef8e74fbe7..c57cbfb2a452 100644 --- a/discordbot/stocks/government/lasttrades.py +++ b/discordbot/stocks/government/lasttrades.py @@ -1,8 +1,8 @@ import discord -import discordbot.config_discordbot as cfg -from discordbot.helpers import pagination from gamestonk_terminal.stocks.government import quiverquant_model +import discordbot.config_discordbot as cfg +from discordbot.helpers import pagination async def lasttrades_command( diff --git a/discordbot/stocks/government/lobbying.py b/discordbot/stocks/government/lobbying.py index 94459c413102..9e4e9a11ce03 100644 --- a/discordbot/stocks/government/lobbying.py +++ b/discordbot/stocks/government/lobbying.py @@ -1,8 +1,8 @@ import discord -import discordbot.config_discordbot as cfg -from discordbot.helpers import pagination from gamestonk_terminal.stocks.government import quiverquant_model +import discordbot.config_discordbot as cfg +from discordbot.helpers import pagination async def lobbying_command(ctx, ticker="", num=""): diff --git a/discordbot/stocks/government/qtrcontracts.py b/discordbot/stocks/government/qtrcontracts.py index cc1833325761..f1b04d20f634 100644 --- a/discordbot/stocks/government/qtrcontracts.py +++ b/discordbot/stocks/government/qtrcontracts.py @@ -3,13 +3,13 @@ from matplotlib import pyplot as plt import numpy as np -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def qtrcontracts_command(ctx, num="", analysis=""): """Displays a look at government contracts [quiverquant.com]""" diff --git a/discordbot/stocks/government/topbuys.py b/discordbot/stocks/government/topbuys.py index 8e62ddad319a..d051f5da5f9a 100644 --- a/discordbot/stocks/government/topbuys.py +++ b/discordbot/stocks/government/topbuys.py @@ -4,13 +4,13 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def topbuys_command( ctx, gov_type="", past_transactions_months="", num="", raw="" diff --git a/discordbot/stocks/government/toplobbying.py b/discordbot/stocks/government/toplobbying.py index 46abc6b9bd91..ec0b500e464e 100644 --- a/discordbot/stocks/government/toplobbying.py +++ b/discordbot/stocks/government/toplobbying.py @@ -3,13 +3,13 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def toplobbying_command(ctx, num="", raw=""): """Displays top lobbying firms [quiverquant.com]""" diff --git a/discordbot/stocks/government/topsells.py b/discordbot/stocks/government/topsells.py index 3b099d75977f..5063a5fd7f96 100644 --- a/discordbot/stocks/government/topsells.py +++ b/discordbot/stocks/government/topsells.py @@ -4,13 +4,13 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal.stocks.government import quiverquant_model from gamestonk_terminal.helper_funcs import plot_autoscale +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def topsells_command( ctx, gov_type="", past_transactions_months="", num="", raw="" diff --git a/discordbot/stocks/technical_analysis/ad.py b/discordbot/stocks/technical_analysis/ad.py index 9104475e0fa4..db26413e858e 100644 --- a/discordbot/stocks/technical_analysis/ad.py +++ b/discordbot/stocks/technical_analysis/ad.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volume_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def ad_command(ctx, ticker="", is_open="False", start="", end=""): """Displays chart with accumulation/distribution line [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/adosc.py b/discordbot/stocks/technical_analysis/adosc.py index 59fa8155098f..4a5ceaf04259 100644 --- a/discordbot/stocks/technical_analysis/adosc.py +++ b/discordbot/stocks/technical_analysis/adosc.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volume_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def adosc_command( ctx, ticker="", is_open="False", fast="3", slow="10", start="", end="" diff --git a/discordbot/stocks/technical_analysis/adx.py b/discordbot/stocks/technical_analysis/adx.py index 6c009cdcfebf..ffec07fb7472 100644 --- a/discordbot/stocks/technical_analysis/adx.py +++ b/discordbot/stocks/technical_analysis/adx.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import trend_indicators_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def adx_command( ctx, ticker="", length="14", scalar="100", drift="1", start="", end="" diff --git a/discordbot/stocks/technical_analysis/aroon.py b/discordbot/stocks/technical_analysis/aroon.py index 85234f3450eb..bd7f551ec865 100644 --- a/discordbot/stocks/technical_analysis/aroon.py +++ b/discordbot/stocks/technical_analysis/aroon.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import trend_indicators_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def aroon_command(ctx, ticker="", length="25", scalar="100", start="", end=""): """Displays chart with aroon indicator [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/bbands.py b/discordbot/stocks/technical_analysis/bbands.py index a81451f70b43..c0df5a6962c9 100644 --- a/discordbot/stocks/technical_analysis/bbands.py +++ b/discordbot/stocks/technical_analysis/bbands.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volatility_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def bbands_command( ctx, ticker="", length="5", n_std="2", mamode="sma", start="", end="" diff --git a/discordbot/stocks/technical_analysis/cci.py b/discordbot/stocks/technical_analysis/cci.py index 3a65eeb60749..90c2bd5f3d92 100644 --- a/discordbot/stocks/technical_analysis/cci.py +++ b/discordbot/stocks/technical_analysis/cci.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def cci_command(ctx, ticker="", length="14", scalar="0.015", start="", end=""): """Displays chart with commodity channel index [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/cg.py b/discordbot/stocks/technical_analysis/cg.py index 507c8a587409..99b8f7cba83e 100644 --- a/discordbot/stocks/technical_analysis/cg.py +++ b/discordbot/stocks/technical_analysis/cg.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import numpy as np -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def cg_command(ctx, ticker="", length="14", start="", end=""): """Displays chart with centre of gravity [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/donchian.py b/discordbot/stocks/technical_analysis/donchian.py index 2035e0e2ab62..5697ceefa07d 100644 --- a/discordbot/stocks/technical_analysis/donchian.py +++ b/discordbot/stocks/technical_analysis/donchian.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volatility_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def donchian_command( ctx, ticker="", upper_length="25", lower_length="100", start="", end="" diff --git a/discordbot/stocks/technical_analysis/ema.py b/discordbot/stocks/technical_analysis/ema.py index 023ac74f8af1..31d5e5f2160d 100644 --- a/discordbot/stocks/technical_analysis/ema.py +++ b/discordbot/stocks/technical_analysis/ema.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import overlap_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def ema_command(ctx, ticker="", window="", offset="", start="", end=""): """Displays chart with exponential moving average [Yahoo Finance]""" @@ -40,15 +40,12 @@ async def ema_command(ctx, ticker="", window="", offset="", start="", end=""): if window == "": window = [20, 50] else: - window_temp = [] - i = 0 - b = 0 - while i < len(window): - if window[i] == ",": - window_temp.append(float(window[b:i])) - l_legend.append(float(window[b:i])) - b = i - i += 1 + window_temp = list() + for wind in window.split(","): + try: + window_temp.append(float(wind)) + except Exception as e: + raise Exception("Window needs to be a float") from e window = window_temp if offset == "": diff --git a/discordbot/stocks/technical_analysis/fib.py b/discordbot/stocks/technical_analysis/fib.py index b99963f516bb..472c8c0016fb 100644 --- a/discordbot/stocks/technical_analysis/fib.py +++ b/discordbot/stocks/technical_analysis/fib.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import custom_indicators_model from gamestonk_terminal import config_plot as cfp +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def fib_command(ctx, ticker="", start="", end=""): """Displays chart with fibonacci retracement [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/fisher.py b/discordbot/stocks/technical_analysis/fisher.py index 30bc89577d6f..82a9f1bc0e13 100644 --- a/discordbot/stocks/technical_analysis/fisher.py +++ b/discordbot/stocks/technical_analysis/fisher.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def fisher_command(ctx, ticker="", length="14", start="", end=""): """Displays chart with fisher transformation [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/hma.py b/discordbot/stocks/technical_analysis/hma.py index f830f7da0f81..e0adc0975c14 100644 --- a/discordbot/stocks/technical_analysis/hma.py +++ b/discordbot/stocks/technical_analysis/hma.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import overlap_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def hma_command(ctx, ticker="", window="", offset="", start="", end=""): """Displays chart with hull moving average [Yahoo Finance]""" @@ -40,15 +40,12 @@ async def hma_command(ctx, ticker="", window="", offset="", start="", end=""): if window == "": window = [20, 50] else: - window_temp = [] - i = 0 - b = 0 - while i < len(window): - if window[i] == ",": - window_temp.append(float(window[b:i])) - l_legend.append(float(window[b:i])) - b = i - i += 1 + window_temp = list() + for wind in window.split(","): + try: + window_temp.append(float(wind)) + except Exception as e: + raise Exception("Window needs to be a float") from e window = window_temp if offset == "": diff --git a/discordbot/stocks/technical_analysis/kc.py b/discordbot/stocks/technical_analysis/kc.py index d1fb2890d34d..15b5cf199e2d 100644 --- a/discordbot/stocks/technical_analysis/kc.py +++ b/discordbot/stocks/technical_analysis/kc.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volatility_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def kc_command( ctx, ticker="", length="20", scalar="2", mamode="sma", offset="0", start="", end="" diff --git a/discordbot/stocks/technical_analysis/macd.py b/discordbot/stocks/technical_analysis/macd.py index 464342ebce90..f7cf23ed01a4 100644 --- a/discordbot/stocks/technical_analysis/macd.py +++ b/discordbot/stocks/technical_analysis/macd.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def macd_command( ctx, ticker="", fast="12", slow="26", signal="9", start="", end="" diff --git a/discordbot/stocks/technical_analysis/obv.py b/discordbot/stocks/technical_analysis/obv.py index e622a132f8f6..10661620f37f 100644 --- a/discordbot/stocks/technical_analysis/obv.py +++ b/discordbot/stocks/technical_analysis/obv.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import volume_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def obv_command(ctx, ticker="", start="", end=""): """Displays chart with on balance volume [Yahoo Finance]""" diff --git a/discordbot/stocks/technical_analysis/recom.py b/discordbot/stocks/technical_analysis/recom.py index 385f6afae6d3..ec957b140dd4 100644 --- a/discordbot/stocks/technical_analysis/recom.py +++ b/discordbot/stocks/technical_analysis/recom.py @@ -1,8 +1,9 @@ import discord -import discordbot.config_discordbot as cfg from gamestonk_terminal.stocks.technical_analysis import tradingview_model +import discordbot.config_discordbot as cfg + async def recom_command(ctx, ticker=""): """Displays text of a given stocks recommendation based on ta [Tradingview API]""" diff --git a/discordbot/stocks/technical_analysis/rsi.py b/discordbot/stocks/technical_analysis/rsi.py index 658815cb00ae..56987a1fda6b 100644 --- a/discordbot/stocks/technical_analysis/rsi.py +++ b/discordbot/stocks/technical_analysis/rsi.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def rsi_command( ctx, ticker="", length="14", scalar="100", drift="1", start="", end="" diff --git a/discordbot/stocks/technical_analysis/sma.py b/discordbot/stocks/technical_analysis/sma.py index 7af513d7f133..e6627df7ad1e 100644 --- a/discordbot/stocks/technical_analysis/sma.py +++ b/discordbot/stocks/technical_analysis/sma.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import overlap_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def sma_command(ctx, ticker="", window="", offset="", start="", end=""): """Displays chart with simple moving average [Yahoo Finance]""" @@ -40,15 +40,12 @@ async def sma_command(ctx, ticker="", window="", offset="", start="", end=""): if window == "": window = [20, 50] else: - window_temp = [] - i = 0 - b = 0 - while i < len(window): - if window[i] == ",": - window_temp.append(float(window[b:i])) - l_legend.append(float(window[b:i])) - b = i - i += 1 + window_temp = list() + for wind in window.split(","): + try: + window_temp.append(float(wind)) + except Exception as e: + raise Exception("Window needs to be a float") from e window = window_temp if offset == "": diff --git a/discordbot/stocks/technical_analysis/stoch.py b/discordbot/stocks/technical_analysis/stoch.py index 459c9e036156..c10abd7108bc 100644 --- a/discordbot/stocks/technical_analysis/stoch.py +++ b/discordbot/stocks/technical_analysis/stoch.py @@ -3,14 +3,14 @@ import discord from matplotlib import pyplot as plt -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import momentum_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def stoch_command( ctx, ticker="", fast_k="14", slow_d="3", slow_k="3", start="", end="" diff --git a/discordbot/stocks/technical_analysis/summary.py b/discordbot/stocks/technical_analysis/summary.py index cd23ab87e96d..898d011325b6 100644 --- a/discordbot/stocks/technical_analysis/summary.py +++ b/discordbot/stocks/technical_analysis/summary.py @@ -1,8 +1,9 @@ import discord -import discordbot.config_discordbot as cfg from gamestonk_terminal.stocks.technical_analysis import finbrain_model +import discordbot.config_discordbot as cfg + async def summary_command(ctx, ticker=""): """Displays text of a given stocks ta summary [FinBrain API]""" diff --git a/discordbot/stocks/technical_analysis/view.py b/discordbot/stocks/technical_analysis/view.py index 36988b07213a..946b63b8a52c 100644 --- a/discordbot/stocks/technical_analysis/view.py +++ b/discordbot/stocks/technical_analysis/view.py @@ -4,14 +4,13 @@ import matplotlib.pyplot as plt from PIL import Image -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur - from gamestonk_terminal.helper_funcs import plot_autoscale - from gamestonk_terminal.stocks.technical_analysis import finviz_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur + async def view_command(ctx, ticker=""): """Displays image from Finviz [Finviz]""" diff --git a/discordbot/stocks/technical_analysis/wma.py b/discordbot/stocks/technical_analysis/wma.py index ecab0f4ff933..3bdb9bcaf478 100644 --- a/discordbot/stocks/technical_analysis/wma.py +++ b/discordbot/stocks/technical_analysis/wma.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import overlap_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def wma_command(ctx, ticker="", window="", offset="", start="", end=""): """Displays chart with weighted moving average [Yahoo Finance]""" @@ -40,15 +40,12 @@ async def wma_command(ctx, ticker="", window="", offset="", start="", end=""): if window == "": window = [20, 50] else: - window_temp = [] - i = 0 - b = 0 - while i < len(window): - if window[i] == ",": - window_temp.append(float(window[b:i])) - l_legend.append(float(window[b:i])) - b = i - i += 1 + window_temp = list() + for wind in window.split(","): + try: + window_temp.append(float(wind)) + except Exception as e: + raise Exception("Window needs to be a float") from e window = window_temp if offset == "": diff --git a/discordbot/stocks/technical_analysis/zlma.py b/discordbot/stocks/technical_analysis/zlma.py index a04340363d4c..14756a9c59a1 100644 --- a/discordbot/stocks/technical_analysis/zlma.py +++ b/discordbot/stocks/technical_analysis/zlma.py @@ -4,14 +4,14 @@ from matplotlib import pyplot as plt import pandas as pd -import discordbot.config_discordbot as cfg -from discordbot.run_discordbot import gst_imgur -import discordbot.helpers - from gamestonk_terminal.helper_funcs import plot_autoscale from gamestonk_terminal.common.technical_analysis import overlap_model from gamestonk_terminal.config_plot import PLOT_DPI +import discordbot.config_discordbot as cfg +from discordbot.run_discordbot import gst_imgur +import discordbot.helpers + async def zlma_command(ctx, ticker="", window="", offset="", start="", end=""): """Displays chart with zero lag moving average [Yahoo Finance]""" @@ -40,15 +40,12 @@ async def zlma_command(ctx, ticker="", window="", offset="", start="", end=""): if window == "": window = [20] else: - window_temp = [] - i = 0 - b = 0 - while i < len(window): - if window[i] == ",": - window_temp.append(float(window[b:i])) - l_legend.append(float(window[b:i])) - b = i - i += 1 + window_temp = list() + for wind in window.split(","): + try: + window_temp.append(float(wind)) + except Exception as e: + raise Exception("Window needs to be a float") from e window = window_temp if offset == "":