Change default SMA and EMA to 20

This commit is contained in:
didier
2021-02-05 00:34:37 +00:00
parent effa13a7f3
commit 98cb9683b8

View File

@@ -16,7 +16,7 @@ def ema(l_args, s_ticker, s_interval, df_stock):
contribution. This method allows the moving average to be more responsive to changes
in the data. """)
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=10, help='length')
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=20, help='length')
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
try:
@@ -29,11 +29,11 @@ def ema(l_args, s_ticker, s_interval, df_stock):
# Daily
if s_interval == "1440min":
df_ta = ta.ema(df_stock['5. adjusted close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "EMA")
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, f"{ns_parser.n_length} EMA")
# Intraday
else:
df_ta = ta.ema(df_stock['4. close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "EMA")
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, f"{ns_parser.n_length} EMA")
except:
print("")
@@ -50,7 +50,7 @@ def sma(l_args, s_ticker, s_interval, df_stock):
This makes it less responsive to recent changes in the data, which can be useful for
filtering out those changes. """)
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=10, help='length')
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=20, help='length')
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
try:
@@ -63,11 +63,11 @@ def sma(l_args, s_ticker, s_interval, df_stock):
# Daily
if s_interval == "1440min":
df_ta = ta.sma(df_stock['5. adjusted close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "SMA")
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, f"{ns_parser.n_length} SMA")
# Intraday
else:
df_ta = ta.sma(df_stock['4. close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "SMA")
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, f"{ns_parser.n_length} SMA")
except:
print("")