diff --git a/src/mplfinance/_arg_validators.py b/src/mplfinance/_arg_validators.py index d7398232..55c320b3 100644 --- a/src/mplfinance/_arg_validators.py +++ b/src/mplfinance/_arg_validators.py @@ -30,21 +30,6 @@ def _check_and_prepare_data(data, config): if not isinstance(data.index,pd.core.indexes.datetimes.DatetimeIndex): raise TypeError('Expect data.index as DatetimeIndex') - if (len(data.index) > config['warn_too_much_data'] and - (config['type']=='candle' or config['type']=='ohlc' or config['type']=='hollow_and_filled') - ): - warnings.warn('\n\n ================================================================= '+ - '\n\n WARNING: YOU ARE PLOTTING SO MUCH DATA THAT IT MAY NOT BE'+ - '\n POSSIBLE TO SEE DETAILS (Candles, Ohlc-Bars, Etc.)'+ - '\n For more information see:'+ - '\n - https://github.com/matplotlib/mplfinance/wiki/Plotting-Too-Much-Data'+ - '\n '+ - '\n TO SILENCE THIS WARNING, set `type=\'line\'` in `mpf.plot()`'+ - '\n OR set kwarg `warn_too_much_data=N` where N is an integer '+ - '\n LARGER than the number of data points you want to plot.'+ - '\n\n ================================================================ ', - category=UserWarning) - # We will not be fully case-insensitive (since Pandas columns as NOT case-insensitive) # but because so many people have requested it, for the default column names we will # try both Capitalized and lower case: @@ -57,10 +42,22 @@ def _check_and_prepare_data(data, config): o, h, l, c, v = columns cols = [o, h, l, c] - if config['tz_localize']: - dates = mdates.date2num(data.index.tz_localize(None).to_pydatetime()) - else: # Just in case someone was depending on this bug (Issue 236) - dates = mdates.date2num(data.index.to_pydatetime()) + if config['volume'] != False: + expect_cols = columns + else: + expect_cols = cols + + for col in expect_cols: + if col not in data.columns: + for dc in data.columns: + if dc.strip() != dc: + warnings.warn('\n ================================================================= '+ + '\n Input DataFrame column name "'+dc+'" '+ + '\n contains leading and/or trailing whitespace.',category=UserWarning) + raise ValueError('Column "'+col+'" NOT FOUND in Input DataFrame!'+ + '\n CHECK that your column names are correct AND/OR'+ + '\n CHECK for leading or trailing blanks in your column names.') + opens = data[o].values highs = data[h].values lows = data[l].values @@ -75,6 +72,26 @@ def _check_and_prepare_data(data, config): if not all( isinstance(v,(float,int)) for v in data[col] ): raise ValueError('Data for column "'+str(col)+'" must be ALL float or int.') + if config['tz_localize']: + dates = mdates.date2num(data.index.tz_localize(None).to_pydatetime()) + else: # Just in case someone was depending on this bug (Issue 236) + dates = mdates.date2num(data.index.to_pydatetime()) + + if (len(data.index) > config['warn_too_much_data'] and + (config['type']=='candle' or config['type']=='ohlc' or config['type']=='hollow_and_filled') + ): + warnings.warn('\n\n ================================================================= '+ + '\n\n WARNING: YOU ARE PLOTTING SO MUCH DATA THAT IT MAY NOT BE'+ + '\n POSSIBLE TO SEE DETAILS (Candles, Ohlc-Bars, Etc.)'+ + '\n For more information see:'+ + '\n - https://github.com/matplotlib/mplfinance/wiki/Plotting-Too-Much-Data'+ + '\n '+ + '\n TO SILENCE THIS WARNING, set `type=\'line\'` in `mpf.plot()`'+ + '\n OR set kwarg `warn_too_much_data=N` where N is an integer '+ + '\n LARGER than the number of data points you want to plot.'+ + '\n\n ================================================================ ', + category=UserWarning) + return dates, opens, highs, lows, closes, volumes def _get_valid_plot_types(plottype=None): diff --git a/src/mplfinance/_version.py b/src/mplfinance/_version.py index e16ebafe..52221d42 100644 --- a/src/mplfinance/_version.py +++ b/src/mplfinance/_version.py @@ -1,4 +1,4 @@ -version_info = (0, 12, 9, 'beta', 4) +version_info = (0, 12, 9, 'beta', 5) _specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''} diff --git a/src/mplfinance/plotting.py b/src/mplfinance/plotting.py index 4826b42c..4e849f92 100644 --- a/src/mplfinance/plotting.py +++ b/src/mplfinance/plotting.py @@ -1235,7 +1235,7 @@ def _auto_secondary_y( panels, panid, ylo, yhi ): def _valid_addplot_kwargs(): - valid_linestyles = ('-','solid','--','dashed','-.','dashdot','.','dotted',None,' ','') + valid_linestyles = ('-','solid','--','dashed','-.','dashdot',':','dotted',None,' ','') valid_types = ('line','scatter','bar', 'ohlc', 'candle','step') valid_stepwheres = ('pre','post','mid') valid_edgecolors = ('face', 'none', None)