Skip to content

Commit 5431b72

Browse files
merge master into branch fill_between
2 parents 6bfc0be + ec52c80 commit 5431b72

File tree

10 files changed

+1973
-75
lines changed

10 files changed

+1973
-75
lines changed

examples/scratch_pad/mav_cross_issue518.ipynb

Lines changed: 570 additions & 0 deletions
Large diffs are not rendered by default.

examples/scratch_pad/plotting.issue508.py

Lines changed: 1272 additions & 0 deletions
Large diffs are not rendered by default.

examples/styles.ipynb

Lines changed: 89 additions & 22 deletions
Large diffs are not rendered by default.

examples/using_lines.ipynb

Lines changed: 26 additions & 25 deletions
Large diffs are not rendered by default.

src/mplfinance/_arg_validators.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@ def _get_valid_plot_types(plottype=None):
9494

9595
if plottype is None:
9696
return _valid_types_all
97-
98-
if plottype not in _valid_types_all:
99-
return None
10097
elif plottype in _alias_types:
10198
return _alias_types[plottype]
102-
else:
103-
return plottype
99+
return plottype
104100

105101

106102
def _mav_validator(mav_value):

src/mplfinance/_panels.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ def _build_panels( figure, config ):
2222
------
2323
The following items are used from `config`:
2424
25-
num_panels : integer (0-9) or None
25+
num_panels : integer (0-31) or None
2626
number of panels to create
2727
2828
addplot : dict or None
2929
value for the `addplot=` kwarg passed into `mplfinance.plot()`
3030
31-
volume_panel : integer (0-9) or None
31+
volume_panel : integer (0-31) or None
3232
panel id (0-number_of_panels)
3333
34-
main_panel : integer (0-9) or None
34+
main_panel : integer (0-31) or None
3535
panel id (0-number_of_panels)
3636
3737
panel_ratios : sequence or None
@@ -68,7 +68,7 @@ def _build_panels( figure, config ):
6868
panel_ratios = config['panel_ratios']
6969

7070
if not _valid_panel_id(main_panel):
71-
raise ValueError('main_panel id must be integer 0 to 9, but is '+str(main_panel))
71+
raise ValueError('main_panel id must be integer 0 to 31, but is '+str(main_panel))
7272

7373
if num_panels is None: # then infer the number of panels:
7474
pset = {0} # start with a set including only panel zero
@@ -85,12 +85,12 @@ def _build_panels( figure, config ):
8585
if panel in backwards_panel_compatibility:
8686
panel = backwards_panel_compatibility[panel]
8787
if not _valid_panel_id(panel):
88-
raise ValueError('addplot panel must be integer 0 to 9, but is "'+str(panel)+'"')
88+
raise ValueError('addplot panel must be integer 0 to 31, but is "'+str(panel)+'"')
8989
pset.add(panel)
9090

9191
if volume is True:
9292
if not _valid_panel_id(volume_panel):
93-
raise ValueError('volume_panel must be integer 0 to 9, but is "'+str(volume_panel)+'"')
93+
raise ValueError('volume_panel must be integer 0 to 31, but is "'+str(volume_panel)+'"')
9494
pset.add(volume_panel)
9595

9696
pset.add(main_panel)

src/mplfinance/_styles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _valid_make_mpf_style_kwargs():
6666

6767
'base_mpl_style': { 'Default' : None,
6868
'Description' : 'matplotlib style to use as base of new mplfinance style',
69-
'Validator' : lambda value: isinstance(value,str) }, # and is in plt.style.available
69+
'Validator' : lambda value: isinstance(value,(str,list))}, # and is in plt.style.available
7070

7171
'marketcolors' : { 'Default' : None,
7272
'Description' : 'market colors object, from `mpf.make_market_colors()`',

src/mplfinance/_utils.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ def _construct_ohlc_collections(dates, opens, highs, lows, closes, marketcolors=
557557

558558
if marketcolors is None:
559559
mktcolors = _get_mpfstyle('classic')['marketcolors']['ohlc']
560-
#print('default mktcolors=',mktcolors)
561560
else:
562561
mktcolors = marketcolors['ohlc']
563562

@@ -635,7 +634,6 @@ def _construct_candlestick_collections(dates, opens, highs, lows, closes, market
635634

636635
if marketcolors is None:
637636
marketcolors = _get_mpfstyle('classic')['marketcolors']
638-
#print('default market colors:',marketcolors)
639637

640638
datalen = len(dates)
641639

@@ -719,7 +717,6 @@ def _construct_hollow_candlestick_collections(dates, opens, highs, lows, closes,
719717

720718
if marketcolors is None:
721719
marketcolors = _get_mpfstyle('classic')['marketcolors']
722-
#print('default market colors:',marketcolors)
723720

724721
datalen = len(dates)
725722

@@ -828,7 +825,6 @@ def _construct_renko_collections(dates, highs, lows, volumes, config_renko_param
828825
renko_params = _process_kwargs(config_renko_params, _valid_renko_kwargs())
829826
if marketcolors is None:
830827
marketcolors = _get_mpfstyle('classic')['marketcolors']
831-
#print('default market colors:',marketcolors)
832828

833829
brick_size = renko_params['brick_size']
834830
atr_length = renko_params['atr_length']
@@ -1005,7 +1001,6 @@ def _construct_pointnfig_collections(dates, highs, lows, volumes, config_pointnf
10051001
pointnfig_params = _process_kwargs(config_pointnfig_params, _valid_pnf_kwargs())
10061002
if marketcolors is None:
10071003
marketcolors = _get_mpfstyle('classic')['marketcolors']
1008-
#print('default market colors:',marketcolors)
10091004

10101005
box_size = pointnfig_params['box_size']
10111006
atr_length = pointnfig_params['atr_length']
@@ -1218,9 +1213,6 @@ def _construct_aline_collections(alines, dtix=None):
12181213
else:
12191214
aconfig = _process_kwargs({}, _valid_lines_kwargs())
12201215

1221-
#print('aconfig=',aconfig)
1222-
#print('alines=',alines)
1223-
12241216
alines = _alines_validator(alines, returnStandardizedValue=True)
12251217
if alines is None:
12261218
raise ValueError('Unable to standardize alines value: '+str(alines))
@@ -1403,6 +1395,7 @@ def _construct_tline_collections(tlines, dtix, dates, opens, highs, lows, closes
14031395
# reconstruct the data frame:
14041396
df = pd.DataFrame({'open':opens,'high':highs,'low':lows,'close':closes},
14051397
index=pd.DatetimeIndex(mdates.num2date(dates)) )
1398+
df.index = df.index.tz_localize(None)
14061399

14071400
# possible `tvalue`s : close,open,high,low,oc_avg,hl_avg,ohlc_avg,hilo
14081401
# 'hilo' means high on the up trend, low on the down trend.
@@ -1436,7 +1429,7 @@ def _tline_lsq(dfslice,tline_use):
14361429
x1, x2 = xs[0], xs[-1]
14371430
y1 = m*x1 + b
14381431
y2 = m*x2 + b
1439-
x1, x2 = mdates.num2date(x1), mdates.num2date(x2)
1432+
x1, x2 = mdates.num2date(x1).replace(tzinfo=None), mdates.num2date(x2).replace(tzinfo=None)
14401433
return ((x1,y1),(x2,y2))
14411434

14421435
if isinstance(tline_use,str):

src/mplfinance/_version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
version_info = (0, 12, 9, 'beta', 0)
1+
version_info = (0, 12, 8, 'beta', 11)
32

43
_specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''}
54

src/mplfinance/plotting.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,18 +857,18 @@ def plot( data, **kwargs ):
857857
save = config['savefig']
858858
if isinstance(save,dict):
859859
if config['tight_layout'] and 'bbox_inches' not in save:
860-
plt.savefig(**save,bbox_inches='tight')
860+
fig.savefig(**save,bbox_inches='tight')
861861
else:
862-
plt.savefig(**save)
862+
fig.savefig(**save)
863863
else:
864864
if config['tight_layout']:
865-
plt.savefig(save,bbox_inches='tight')
865+
fig.savefig(save,bbox_inches='tight')
866866
else:
867-
plt.savefig(save)
867+
fig.savefig(save)
868868
if config['closefig']: # True or 'auto'
869869
plt.close(fig)
870870
elif not config['returnfig']:
871-
plt.show(block=config['block']) # https://stackoverflow.com/a/13361748/1639359
871+
plt.show(block=config['block']) # https://stackoverflow.com/a/13361748/1639359
872872
if config['closefig'] == True or (config['block'] and config['closefig']):
873873
plt.close(fig)
874874

0 commit comments

Comments
 (0)