diff --git a/openbb_terminal/etf/etf_controller.py b/openbb_terminal/etf/etf_controller.py index 447634ad496..7ce0a7f7ffc 100644 --- a/openbb_terminal/etf/etf_controller.py +++ b/openbb_terminal/etf/etf_controller.py @@ -521,7 +521,10 @@ class ETFController(BaseController): "--ma", dest="mov_avg", type=str, - help="Add moving averaged to plot", + help=( + "Add moving average in number of days to plot and separate by a comma. " + "Value for ma (moving average) keyword needs to be greater than 1." + ), default="", ) @@ -550,11 +553,23 @@ class ETFController(BaseController): else: data = stocks_helper.process_candle(self.etf_data) - mov_avgs = ( - tuple(int(num) for num in ns_parser.mov_avg.split(",")) - if ns_parser.mov_avg - else None - ) + mov_avgs = [] + + if ns_parser.mov_avg: + mov_list = (num for num in ns_parser.mov_avg.split(",")) + + for num in mov_list: + try: + num = int(num) + + if num <= 1: + raise ValueError + + mov_avgs.append(num) + except ValueError: + console.print( + f"[red]{num} is not a valid moving average, must be an integer greater than 1." + ) stocks_helper.display_candle( symbol=self.etf_name, diff --git a/openbb_terminal/forex/forex_controller.py b/openbb_terminal/forex/forex_controller.py index a742f577d60..73811f44640 100644 --- a/openbb_terminal/forex/forex_controller.py +++ b/openbb_terminal/forex/forex_controller.py @@ -229,7 +229,10 @@ class ForexController(BaseController): "--ma", dest="mov_avg", type=str, - help=translate("stocks/CANDLE_mov_avg"), + help=translate( + "Add moving average in number of days to plot and separate by a comma. " + "Value for ma (moving average) keyword needs to be greater than 1." + ), default=None, ) ns_parser = self.parse_known_args_and_warn(parser, other_args) @@ -241,11 +244,17 @@ class ForexController(BaseController): for num in mov_list: try: - mov_avgs.append(int(num)) + num = int(num) + + if num <= 1: + raise ValueError + + mov_avgs.append(num) except ValueError: console.print( - f"{num} is not a valid moving average, must be integer" + f"[red]{num} is not a valid moving average, must be an integer greater than 1." ) + forex_helper.display_candle( self.data, self.to_symbol, self.from_symbol, mov_avgs ) diff --git a/openbb_terminal/forex/technical_analysis/ta_controller.py b/openbb_terminal/forex/technical_analysis/ta_controller.py index c3cf6e176a8..463e0a173c7 100644 --- a/openbb_terminal/forex/technical_analysis/ta_controller.py +++ b/openbb_terminal/forex/technical_analysis/ta_controller.py @@ -27,6 +27,7 @@ from openbb_terminal.helper_funcs import ( EXPORT_BOTH_RAW_DATA_AND_FIGURES, check_positive, check_positive_list, + check_positive_float, valid_date, ) from openbb_terminal.forex.forex_helper import FOREX_SOURCES @@ -812,7 +813,7 @@ class TechnicalAnalysisController(StockBaseController): "--std", action="store", dest="n_std", - type=check_positive, + type=check_positive_float, default=2, help="std", ) diff --git a/openbb_terminal/stocks/stocks_controller.py b/openbb_terminal/stocks/stocks_controller.py index fa59158e478..98d5fbc91ff 100644 --- a/openbb_terminal/stocks/stocks_controller.py +++ b/openbb_terminal/stocks/stocks_controller.py @@ -432,7 +432,10 @@ class StocksController(StockBaseController): "--ma", dest="mov_avg", type=str, - help="Add moving average in number of days to plot and separate by a comma", + help=( + "Add moving average in number of days to plot and separate by a comma. " + "Value for ma (moving average) keyword needs to be greater than 1." + ), default=None, ) parser.add_argument( @@ -491,10 +494,15 @@ class StocksController(StockBaseController): for num in mov_list: try: - mov_avgs.append(int(num)) + num = int(num) + + if num <= 1: + raise ValueError + + mov_avgs.append(num) except ValueError: console.print( - f"{num} is not a valid moving average, must be integer" + f"[red]{num} is not a valid moving average, must be an integer greater than 1." ) stocks_helper.display_candle( diff --git a/website/content/terminal/etf/candle/_index.md b/website/content/terminal/etf/candle/_index.md index de8e77076dd..1d320a73ecb 100644 --- a/website/content/terminal/etf/candle/_index.md +++ b/website/content/terminal/etf/candle/_index.md @@ -12,7 +12,7 @@ optional arguments: --raw Shows raw data instead of chart (default: False) -n NUM, --num NUM Number to show if raw selected (default: 20) -t, --trend Flag to add high and low trends to candle. (default: False) - --ma MOV_AVG Add moving averaged to plot (default: ) + --ma MOV_AVG Add moving average in number of days to plot and separate by a comma. Value for ma (moving average) keyword needs to be greater than 1. (default: ) -h, --help show this help message (default: False) --export {csv,json,xlsx} Export raw data into csv, json, xlsx (default: ) diff --git a/website/content/terminal/forex/candle/_index.md b/website/content/terminal/forex/candle/_index.md index 5635e3d3020..2d85ea852ec 100644 --- a/website/content/terminal/forex/candle/_index.md +++ b/website/content/terminal/forex/candle/_index.md @@ -6,7 +6,7 @@ Show candle for loaded fx data ``` optional arguments: - --ma MOV_AVG Add moving average in number of days to plot and separate by a comma (default: None) + --ma MOV_AVG Add moving average in number of days to plot and separate by a comma. Value for ma (moving average) keyword needs to be greater than 1. (default: ) -h, --help show this help message (default: False) ``` diff --git a/website/content/terminal/stocks/candle/_index.md b/website/content/terminal/stocks/candle/_index.md index 41a0d0dc568..215b857184a 100755 --- a/website/content/terminal/stocks/candle/_index.md +++ b/website/content/terminal/stocks/candle/_index.md @@ -10,7 +10,7 @@ optional arguments: -d, --descending Sort selected column descending. Only works when raw data is displayed. (default: True) --raw Shows raw data instead of chart. If sort is set those are the top ones, otherwise we grab latest data to date (default: False) -t, --trend Flag to add high and low trends to candle (default: False) - --ma MOV_AVG Add moving average in number of days to plot and separate by a comma (default: None) + --ma MOV_AVG Add moving average in number of days to plot and separate by a comma. Value for ma (moving average) keyword needs to be greater than 1. (default: None) --log Plot with y axis on log scale (default: False) -h, --help show this help message (default: False) --export EXPORT Export raw data into csv, json, xlsx (default: )