def _valid_plot_kwargs(): ''' Construct and return the "valid kwargs table" for the mplfinance.plot() function. A valid kwargs table is a `dict` of `dict`s. The keys of the outer dict are the valid key-words for the function. The value for each key is a dict containing 2 specific keys: "Default", and "Validator" with the following values: "Default" - The default value for the kwarg if none is specified. "Validator" - A function that takes the caller specified value for the kwarg, and validates that it is the correct type, and (for kwargs with a limited set of allowed values) may also validate that the kwarg value is one of the allowed values. ''' vkwargs = { 'type': { 'Default': 'ohlc', 'Validator': lambda value: value in ['candle', 'candlestick', 'ohlc', 'bars', 'ohlc_bars', 'line'] }, 'style': { 'Default': 'default', 'Validator': lambda value: value in _styles.available_styles() or isinstance( value, dict) }, 'volume': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'mav': { 'Default': None, 'Validator': _mav_validator }, 'study': { 'Default': None, #'Validator' : lambda value: isinstance(value,dict) }, #{'studyname': {study parms}} example: {'TE':{'mav':20,'upper':2,'lower':2}} 'Validator': lambda value: _kwarg_not_implemented(value) }, 'marketcolors': { 'Default': None, # use 'style' for default, instead. 'Validator': lambda value: isinstance(value, dict) }, 'no_xgaps': { 'Default': True, # None means follow default logic below: 'Validator': lambda value: _warn_no_xgaps_deprecated(value) }, 'show_nontrading': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'figscale': { 'Default': 1.0, # scale base figure size up or down. 'Validator': lambda value: isinstance(value, float) or isinstance(value, int) }, 'figratio': { 'Default': (8.00, 5.75), # aspect ratio; will equal fig size when figscale=1.0 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], (float, int)) and isinstance(value[1], (float, int)) }, 'linecolor': { 'Default': 'k', # line color in line plot 'Validator': lambda value: mcolors.is_color_like(value) }, 'title': { 'Default': None, # Plot Title 'Validator': lambda value: isinstance(value, str) }, 'ylabel': { 'Default': 'Price', # y-axis label 'Validator': lambda value: isinstance(value, str) }, 'ylabel_lower': { 'Default': None, # y-axis label default logic below 'Validator': lambda value: isinstance(value, str) }, #'xlabel' : { 'Default' : None, # x-axis label, default is None because obvious it's time or date # 'Validator' : lambda value: isinstance(value,str) }, 'addplot': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or (isinstance( value, list) and all([isinstance(d, dict) for d in value])) }, 'savefig': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or isinstance(value, str) or isinstance(value, io.BytesIO) }, 'block': { 'Default': True, 'Validator': lambda value: isinstance(value, bool) }, } _validate_vkwargs_dict(vkwargs) return vkwargs
def _valid_plot_kwargs(): """ Construct and return the "valid kwargs table" for the mplfinance.plot() function. A valid kwargs table is a `dict` of `dict`s. The keys of the outer dict are the valid key-words for the function. The value for each key is a dict containing 2 specific keys: "Default", and "Validator" with the following values: "Default" - The default value for the kwarg if none is specified. "Validator" - A function that takes the caller specified value for the kwarg, and validates that it is the correct type, and (for kwargs with a limited set of allowed values) may also validate that the kwarg value is one of the allowed values. """ vkwargs = { "columns": { "Default": ("Open", "High", "Low", "Close", "Volume"), "Validator": lambda value: isinstance(value, (tuple, list)) and len(value) == 5 and all(isinstance(c, str) for c in value), }, "type": { "Default": "ohlc", "Validator": lambda value: value in [ "candle", "candlestick", "ohlc", "bars", "ohlc_bars", "line", "renko", "pnf", "p&f", "pointnfigure", ], }, "style": { "Default": "default", "Validator": lambda value: value in _styles.available_styles() or isinstance( value, dict), }, "volume": { "Default": False, "Validator": lambda value: isinstance(value, bool), }, "mav": { "Default": None, "Validator": _mav_validator }, "renko_params": { "Default": dict(), "Validator": lambda value: isinstance(value, dict), }, "pointnfig_params": { "Default": dict(), "Validator": lambda value: isinstance(value, dict), }, "study": { "Default": None, #'Validator' : lambda value: isinstance(value,dict) }, #{'studyname': {study parms}} example: {'TE':{'mav':20,'upper':2,'lower':2}} "Validator": lambda value: _kwarg_not_implemented(value), }, "marketcolors": { "Default": None, # use 'style' for default, instead. "Validator": lambda value: isinstance(value, dict), }, "no_xgaps": { "Default": True, # None means follow default logic below: "Validator": lambda value: _warn_no_xgaps_deprecated(value), }, "show_nontrading": { "Default": False, "Validator": lambda value: isinstance(value, bool), }, "figscale": { "Default": 1.0, # scale base figure size up or down. "Validator": lambda value: isinstance(value, float) or isinstance(value, int), }, "figratio": { "Default": ( 8.00, 5.75, ), # aspect ratio; will equal fig size when figscale=1.0 "Validator": lambda value: isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], (float, int)) and isinstance(value[1], (float, int)), }, "linecolor": { "Default": "k", # line color in line plot "Validator": lambda value: mcolors.is_color_like(value), }, "title": { "Default": None, # Plot Title "Validator": lambda value: isinstance(value, str), }, "ylabel": { "Default": "Price", # y-axis label "Validator": lambda value: isinstance(value, str), }, "ylabel_lower": { "Default": None, # y-axis label default logic below "Validator": lambda value: isinstance(value, str), }, #'xlabel' : { 'Default' : None, # x-axis label, default is None because obvious it's time or date # 'Validator' : lambda value: isinstance(value,str) }, "addplot": { "Default": None, "Validator": lambda value: isinstance(value, dict) or (isinstance( value, list) and all([isinstance(d, dict) for d in value])), }, "savefig": { "Default": None, "Validator": lambda value: isinstance(value, dict) or isinstance(value, str) or isinstance(value, io.BytesIO), }, "block": { "Default": True, "Validator": lambda value: isinstance(value, bool) }, "returnfig": { "Default": False, "Validator": lambda value: isinstance(value, bool), }, "return_calculated_values": { "Default": None, "Validator": lambda value: isinstance(value, dict) and len(value) == 0, }, } _validate_vkwargs_dict(vkwargs) return vkwargs
def _valid_plot_kwargs(): ''' Construct and return the "valid kwargs table" for the mplfinance.plot() function. A valid kwargs table is a `dict` of `dict`s. The keys of the outer dict are the valid key-words for the function. The value for each key is a dict containing 2 specific keys: "Default", and "Validator" with the following values: "Default" - The default value for the kwarg if none is specified. "Validator" - A function that takes the caller specified value for the kwarg, and validates that it is the correct type, and (for kwargs with a limited set of allowed values) may also validate that the kwarg value is one of the allowed values. ''' vkwargs = { 'columns': { 'Default': ('Open', 'High', 'Low', 'Close', 'Volume'), 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 5 and all(isinstance(c, str) for c in value) }, 'type': { 'Default': 'ohlc', 'Validator': lambda value: value in ('candle', 'candlestick', 'ohlc', 'ohlc_bars', 'line', 'renko', 'pnf') }, 'style': { 'Default': 'default', 'Validator': lambda value: value in _styles.available_styles() or isinstance( value, dict) }, 'volume': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'mav': { 'Default': None, 'Validator': _mav_validator }, 'renko_params': { 'Default': dict(), 'Validator': lambda value: isinstance(value, dict) }, 'pnf_params': { 'Default': dict(), 'Validator': lambda value: isinstance(value, dict) }, 'study': { 'Default': None, 'Validator': lambda value: _kwarg_not_implemented(value) }, 'marketcolors': { 'Default': None, # use 'style' for default, instead. 'Validator': lambda value: isinstance(value, dict) }, 'no_xgaps': { 'Default': True, # None means follow default logic below: 'Validator': lambda value: _warn_no_xgaps_deprecated(value) }, 'show_nontrading': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'figscale': { 'Default': 1.0, # scale base figure size up or down. 'Validator': lambda value: isinstance(value, float) or isinstance(value, int) }, 'figratio': { 'Default': DEFAULT_FIGRATIO, # aspect ratio; scaled to 8.0 height 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], (float, int)) and isinstance(value[1], (float, int)) }, 'figsize': { 'Default': None, # figure size; overrides figratio and figscale 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], (float, int)) and isinstance(value[1], (float, int)) }, 'linecolor': { 'Default': None, # line color in line plot 'Validator': lambda value: mcolors.is_color_like(value) }, 'title': { 'Default': None, # Plot Title 'Validator': lambda value: isinstance(value, str) }, 'ylabel': { 'Default': 'Price', # y-axis label 'Validator': lambda value: isinstance(value, str) }, 'ylabel_lower': { 'Default': None, # y-axis label default logic below 'Validator': lambda value: isinstance(value, str) }, 'addplot': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or (isinstance( value, list) and all([isinstance(d, dict) for d in value])) }, 'savefig': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or isinstance(value, str) or isinstance(value, io.BytesIO) }, 'block': { 'Default': True, 'Validator': lambda value: isinstance(value, bool) }, 'returnfig': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'return_calculated_values': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) and len(value) == 0 }, 'set_ylim': { 'Default': None, 'Validator': lambda value: isinstance(value, (list, tuple)) and len(value) == 2 and all([isinstance(v, (int, float)) for v in value]) }, 'set_ylim_panelB': { 'Default': None, 'Validator': lambda value: isinstance(value, (list, tuple)) and len(value) == 2 and all([isinstance(v, (int, float)) for v in value]) }, 'hlines': { 'Default': None, 'Validator': lambda value: _hlines_validator(value) }, 'vlines': { 'Default': None, 'Validator': lambda value: _vlines_validator(value) }, 'alines': { 'Default': None, 'Validator': lambda value: _alines_validator(value) }, 'tlines': { 'Default': None, 'Validator': lambda value: _tlines_validator(value) }, 'panel_ratios': { 'Default': None, 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) <= 10 and all([isinstance(v, (int, float)) for v in value]) }, 'main_panel': { 'Default': 0, 'Validator': lambda value: _valid_panel_id(value) }, 'volume_panel': { 'Default': 1, 'Validator': lambda value: _valid_panel_id(value) }, 'num_panels': { 'Default': None, 'Validator': lambda value: isinstance(value, int) and value in range(1, 10 + 1) }, 'datetime_format': { 'Default': None, 'Validator': lambda value: isinstance(value, str) }, 'xrotation': { 'Default': 45, 'Validator': lambda value: isinstance(value, (int, float)) }, 'axisoff': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'closefig': { 'Default': 'auto', 'Validator': lambda value: isinstance(value, bool) }, 'fill_between': { 'Default': None, 'Validator': lambda value: _num_or_seq_of_num(value) or (isinstance(value, dict) and 'y1' in value and _num_or_seq_of_num( value['y1'])) }, 'tight_layout': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'width_adjuster_version': { 'Default': 'v1', 'Validator': lambda value: value in ('v0', 'v1') }, 'scale_width_adjustment': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) and len(value) > 0 }, 'update_width_config': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) and len(value) > 0 }, 'return_width_config': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) and len(value) == 0 }, 'saxbelow': { 'Default': True, # Issue#115 Comment#639446764 'Validator': lambda value: isinstance(value, bool) }, } _validate_vkwargs_dict(vkwargs) return vkwargs
def _valid_plot_kwargs(): ''' Construct and return the "valid kwargs table" for the mplfinance.plot() function. A valid kwargs table is a `dict` of `dict`s. The keys of the outer dict are the valid key-words for the function. The value for each key is a dict containing 2 specific keys: "Default", and "Validator" with the following values: "Default" - The default value for the kwarg if none is specified. "Validator" - A function that takes the caller specified value for the kwarg, and validates that it is the correct type, and (for kwargs with a limited set of allowed values) may also validate that the kwarg value is one of the allowed values. ''' vkwargs = { 'columns': { 'Default': ('Open', 'High', 'Low', 'Close', 'Volume'), 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 5 and all(isinstance(c, str) for c in value) }, 'type': { 'Default': 'ohlc', 'Validator': lambda value: value in ('candle', 'candlestick', 'ohlc', 'ohlc_bars', 'line', 'renko', 'pnf') }, 'style': { 'Default': 'default', 'Validator': lambda value: value in _styles.available_styles() or isinstance( value, dict) }, 'volume': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) or value in ['B', 'C'] }, 'mav': { 'Default': None, 'Validator': _mav_validator }, 'renko_params': { 'Default': dict(), 'Validator': lambda value: isinstance(value, dict) }, 'pnf_params': { 'Default': dict(), 'Validator': lambda value: isinstance(value, dict) }, 'study': { 'Default': None, 'Validator': lambda value: _kwarg_not_implemented(value) }, 'marketcolors': { 'Default': None, # use 'style' for default, instead. 'Validator': lambda value: isinstance(value, dict) }, 'no_xgaps': { 'Default': True, # None means follow default logic below: 'Validator': lambda value: _warn_no_xgaps_deprecated(value) }, 'show_nontrading': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'figscale': { 'Default': 1.0, # scale base figure size up or down. 'Validator': lambda value: isinstance(value, float) or isinstance(value, int) }, 'figratio': { 'Default': (8.00, 5.75), # aspect ratio; will equal fig size when figscale=1.0 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 2 and isinstance(value[0], (float, int)) and isinstance(value[1], (float, int)) }, 'linecolor': { 'Default': None, # line color in line plot 'Validator': lambda value: mcolors.is_color_like(value) }, 'title': { 'Default': None, # Plot Title 'Validator': lambda value: isinstance(value, str) }, 'ylabel': { 'Default': 'Price', # y-axis label 'Validator': lambda value: isinstance(value, str) }, 'ylabel_lower': { 'Default': None, # y-axis label default logic below 'Validator': lambda value: isinstance(value, str) }, 'addplot': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or (isinstance( value, list) and all([isinstance(d, dict) for d in value])) }, 'savefig': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) or isinstance(value, str) or isinstance(value, io.BytesIO) }, 'block': { 'Default': True, 'Validator': lambda value: isinstance(value, bool) }, 'returnfig': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'return_calculated_values': { 'Default': None, 'Validator': lambda value: isinstance(value, dict) and len(value) == 0 }, 'set_ylim': { 'Default': None, 'Validator': lambda value: isinstance(value, (list, tuple)) and len(value) == 2 and all([isinstance(v, (int, float)) for v in value]) }, 'set_ylim_panelB': { 'Default': None, 'Validator': lambda value: isinstance(value, (list, tuple)) and len(value) == 2 and all([isinstance(v, (int, float)) for v in value]) }, 'set_ylim_panelC': { 'Default': None, 'Validator': lambda value: isinstance(value, (list, tuple)) and len(value) == 2 and all([isinstance(v, (int, float)) for v in value]) }, 'hlines': { 'Default': None, 'Validator': lambda value: _hlines_validator(value) }, 'vlines': { 'Default': None, 'Validator': lambda value: _vlines_validator(value) }, 'alines': { 'Default': None, 'Validator': lambda value: _alines_validator(value) }, 'tlines': { 'Default': None, 'Validator': lambda value: _tlines_validator(value) }, 'panel_order': { 'Default': 'ABC', 'Validator': lambda value: isinstance(value, str) and len(value) == 3 and ( ('A' in value and 'B' in value and 'C' in value) or ('a' in value and 'b' in value and 'c' in value)) }, 'panel_ratio': { 'Default': (5, 2, 2), 'Validator': lambda value: isinstance(value, (tuple, list)) and len(value) == 3 and all([isinstance(v, (int, float)) for v in value]) }, 'datetime_format': { 'Default': None, 'Validator': lambda value: isinstance(value, str) }, 'xrotation': { 'Default': 45, 'Validator': lambda value: isinstance(value, (int, float)) }, 'axesoff': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'axesoffdark': { 'Default': False, 'Validator': lambda value: isinstance(value, bool) }, 'closefig': { 'Default': 'auto', 'Validator': lambda value: isinstance(value, bool) }, 'yscale': { 'Default': None, 'Validator': lambda value: isinstance(value, str) or (isinstance(value, dict) and 'yscale' in value) }, } _validate_vkwargs_dict(vkwargs) return vkwargs