Skip to content

Commit 1f710ca

Browse files
Merge pull request #498 from DanielGoldfarb/master
completed kwarg descriptions for `mpf.kwarg_help()`
2 parents 8fa38f2 + 6110d05 commit 1f710ca

File tree

6 files changed

+227
-131
lines changed

6 files changed

+227
-131
lines changed

src/mplfinance/_styles.py

+31-25
Original file line numberDiff line numberDiff line change
@@ -61,60 +61,61 @@ def _apply_mpfstyle(style):
6161
def _valid_make_mpf_style_kwargs():
6262
vkwargs = {
6363
'base_mpf_style': { 'Default' : None,
64-
'Description' : '',
64+
'Description' : 'mplfinance style to use as base of new mplfinance style',
6565
'Validator' : lambda value: value in _styles.keys() },
6666

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

7171
'marketcolors' : { 'Default' : None,
72-
'Description' : '',
72+
'Description' : 'market colors object, from `mpf.make_market_colors()`',
7373
'Validator' : lambda value: isinstance(value,dict) },
7474

7575
'mavcolors' : { 'Default' : None,
76-
'Description' : '',
76+
'Description' : 'sequence of colors to use for moving averages',
7777
'Validator' : lambda value: isinstance(value,list) }, # TODO: all([_mpf_is_color_like(v) for v in value.values()])
7878

7979

8080
'facecolor' : { 'Default' : None,
81-
'Description' : '',
81+
'Description' : 'background color for Axes',
8282
'Validator' : lambda value: isinstance(value,str) },
8383

8484
'edgecolor' : { 'Default' : None,
85-
'Description' : '',
85+
'Description' : 'edge color for Axes',
8686
'Validator' : lambda value: isinstance(value,str) },
8787

8888
'figcolor' : { 'Default' : None,
89-
'Description' : '',
89+
'Description' : 'background color for Figure.',
9090
'Validator' : lambda value: isinstance(value,str) },
9191

9292
'gridcolor' : { 'Default' : None,
93-
'Description' : '',
93+
'Description' : 'color for grid lines',
9494
'Validator' : lambda value: isinstance(value,str) },
9595

9696
'gridstyle' : { 'Default' : None,
97-
'Description' : '',
97+
'Description' : "grid line style ('-', '--', '-.', ':', '', offset, on-off-seq)."+
98+
" (see also: https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)",
9899
'Validator' : lambda value: isinstance(value,str) },
99100

100101
'gridaxis' : { 'Default' : None,
101-
'Description' : '',
102+
'Description' : "grid lines 'vertical', 'horizontal', or 'both'",
102103
'Validator' : lambda value: value in [ 'vertical'[0:len(value)], 'horizontal'[0:len(value)], 'both'[0:len(value)] ] },
103104

104105
'y_on_right' : { 'Default' : None,
105-
'Description' : '',
106+
'Description' : 'True|False primary Axes y-ticks and labels on right.',
106107
'Validator' : lambda value: isinstance(value,bool) },
107108

108109
'rc' : { 'Default' : None,
109-
'Description' : '',
110+
'Description' : 'rcparams overrides (dict) (all other rcparams unchanged)',
110111
'Validator' : lambda value: isinstance(value,dict) },
111112

112113
'legacy_rc' : { 'Default' : None, # Just in case someone depended upon old behavior
113-
'Description' : '',
114+
'Description' : 'rcparams to set (dict) (all other rcparams cleared)',
114115
'Validator' : lambda value: isinstance(value,dict) },
115116

116117
'style_name' : { 'Default' : None,
117-
'Description' : '',
118+
'Description' : 'name for this style; useful when calling `mpf.write_style_file(style,filename)`',
118119
'Validator' : lambda value: isinstance(value,str) },
119120

120121
}
@@ -209,55 +210,60 @@ def _valid_mpf_style(value):
209210
def _valid_make_marketcolors_kwargs():
210211
vkwargs = {
211212
'up' : { 'Default' : None,
212-
'Description' : '',
213+
'Description' : 'color to indicate up',
213214
'Validator' : lambda value: _mpf_is_color_like(value) },
214215

215216
'down' : { 'Default' : None,
216-
'Description' : '',
217+
'Description' : 'color to indicate down',
217218
'Validator' : lambda value: _mpf_is_color_like(value) },
218219

219220
'hollow' : { 'Default' : None,
220-
'Description' : '',
221+
'Description' : "color for hollow candles (for `type=hollow`)",
221222
'Validator' : lambda value: _mpf_is_color_like(value) },
222223

223224
'alpha' : { 'Default' : None,
224-
'Description' : '',
225+
'Description' : 'opacity 0.0 (transparent) to 1.0 (opaque);'+
226+
' applies to candles,renko,pnf (but not ohlc bars)',
225227
'Validator' : lambda value: (isinstance(value,float)
226228
and 0.0 <= value and 1.0 >= value ) },
227229

228230
'edge' : { 'Default' : None,
229-
'Description' : '',
231+
'Description' : 'color of candle edge; may also be "i" or "inherit"'+
232+
' to take color from base_mpf_style',
230233
'Validator' : lambda value: _valid_mpf_color_spec(value) },
231234

232235
'wick' : { 'Default' : None,
233-
'Description' : '',
236+
'Description' : "color of candle wick; may be single color,"+
237+
" or may be dict with keys 'up' and 'down'",
234238
'Validator' : lambda value: isinstance(value,dict)
235239
or isinstance(value,str)
236240
or _mpf_is_color_like(value) },
237241

238242
'ohlc' : { 'Default' : None,
239-
'Description' : '',
243+
'Description' : "color of ohlc bars; may be single color,"+
244+
" or may be dict with keys 'up' and 'down'",
240245
'Validator' : lambda value: isinstance(value,dict)
241246
or isinstance(value,str)
242247
or _mpf_is_color_like(value) },
243248

244249
'volume' : { 'Default' : None,
245-
'Description' : '',
250+
'Description' : "color of volume bars; may be single color,"+
251+
" or may be dict with keys 'up' and 'down'",
246252
'Validator' : lambda value: isinstance(value,dict)
247253
or isinstance(value,str)
248254
or _mpf_is_color_like(value) },
249255

250256
'vcdopcod' : { 'Default' : False,
251-
'Description' : '',
257+
'Description' : 'True/False volume color depends on price change from previous day',
252258
'Validator' : lambda value: isinstance(value,bool) },
253259

254260

255261
'inherit' : { 'Default' : False,
256-
'Description' : '',
262+
'Description' : 'inherit color from base_mpf_style for: edge,volume,ohlc,wick',
257263
'Validator' : lambda value: isinstance(value,bool) },
258264

259265
'base_mpf_style': { 'Default' : None,
260-
'Description' : '',
266+
'Description' : 'mplfinance style market colors as basis for new market colors object',
261267
'Validator' : lambda value: isinstance(value,str) },
262268
}
263269

src/mplfinance/_utils.py

+37-15
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,12 @@ def _valid_renko_kwargs():
387387
'''
388388
vkwargs = {
389389
'brick_size' : { 'Default' : 'atr',
390-
'Description' : '',
390+
'Description' : 'size of each brick on y-axis (typically price).'+
391+
' specify a number, or specify "atr" for average true range.',
391392
'Validator' : lambda value: isinstance(value,(float,int))
392393
or value == 'atr' },
393394
'atr_length' : { 'Default' : 14,
394-
'Description' : '',
395+
'Description' : 'number of periods for atr calculation (if brick size is "atr")',
395396
'Validator' : lambda value: isinstance(value,int)
396397
or value == 'total' },
397398
}
@@ -416,16 +417,18 @@ def _valid_pnf_kwargs():
416417
'''
417418
vkwargs = {
418419
'box_size' : { 'Default' : 'atr',
419-
'Description' : '',
420+
'Description' : 'size of each box on y-axis (typically price).'+
421+
' specify a number, or specify "atr" for average true range.',
420422
'Validator' : lambda value: isinstance(value,(float,int))
421423
or value == 'atr' },
422424
'atr_length' : { 'Default' : 14,
423-
'Description' : '',
425+
'Description' : 'number of periods for atr calculation (if box size is "atr")',
424426
'Validator' : lambda value: isinstance(value,int)
425427
or value == 'total' },
426428

427429
'reversal' : { 'Default' : 1,
428-
'Description' : '',
430+
'Description' : 'number of boxes, in opposite direction, needed to reverse'+
431+
' a trend (i.e. to start a new column).',
429432
'Validator' : lambda value: isinstance(value,int) },
430433
}
431434

@@ -451,52 +454,71 @@ def _valid_lines_kwargs():
451454
valid_linestyles = ['-','solid','--','dashed','-.','dashdot',':','dotted',None,' ','']
452455
vkwargs = {
453456
'hlines' : { 'Default' : None,
454-
'Description' : '',
457+
'Description' : 'Draw one or more HORIZONTAL LINES across entire plot, by'+
458+
' specifying a price, or sequence of prices. May also be a dict'+
459+
' with key `hlines` specifying a price or sequence of prices, plus'+
460+
' one or more of the following keys: `colors`, `linestyle`,'+
461+
' `linewidths`, `alpha`.',
455462
'Validator' : _bypass_kwarg_validation },
456463

457464
'vlines' : { 'Default' : None,
458-
'Description' : '',
465+
'Description' : 'Draw one or more VERTICAL LINES across entire plot, by'+
466+
' specifying a date[time], or sequence of date[time]. May also'+
467+
' be a dict with key `vlines` specifying a date[time] or sequence'+
468+
' of date[time], plus one or more of the following keys:'+
469+
' `colors`, `linestyle`, `linewidths`, `alpha`.',
459470
'Validator' : _bypass_kwarg_validation },
460471

461472
'alines' : { 'Default' : None,
462-
'Description' : '',
473+
'Description' : 'Draw one or more ARBITRARY LINES anywhere on the plot, by'+
474+
' specifying a sequence of two or more date/price pairs, or by'+
475+
' specifying a sequence of sequences of two or more date/price pairs.'+
476+
' May also be a dict with key `alines` (as date/price pairs described above),'+
477+
' plus one or more of the following keys:'+
478+
' `colors`, `linestyle`, `linewidths`, `alpha`.',
463479
'Validator' : _bypass_kwarg_validation },
464480

465481
'tlines' : { 'Default' : None,
466-
'Description' : '',
482+
'Description' : 'Draw one or more TREND LINES by specifying one or more pairs of date[times]'+
483+
' between which each trend line should be drawn. May also be a dict with key'+
484+
' `tlines` as just described, plus one or more of the following keys:'+
485+
' `colors`, `linestyle`, `linewidths`, `alpha`, `tline_use`,`tline_method`.',
467486
'Validator' : _bypass_kwarg_validation },
468487

469488
'colors' : { 'Default' : None,
470-
'Description' : '',
489+
'Description' : 'Color of [hvat]lines (or sequence of colors, if each line to be a different color)',
471490
'Validator' : lambda value: value is None
472491
or mcolors.is_color_like(value)
473492
or (isinstance(value,(list,tuple))
474493
and all([mcolors.is_color_like(v) for v in value]) ) },
475494

476495
'linestyle' : { 'Default' : '-',
477-
'Description' : '',
496+
'Description' : 'line style of [hvat]lines (or sequence of line styles, if each line to have a different linestyle)',
478497
'Validator' : lambda value: value is None or value in valid_linestyles or
479498
all([v in valid_linestyles for v in value]) },
480499

481500
'linewidths': { 'Default' : None,
482-
'Description' : '',
501+
'Description' : 'line width of [hvat]lines (or sequence of line widths, if each line to have a different width)',
483502
'Validator' : lambda value: value is None
484503
or isinstance(value,(float,int))
485504
or all([isinstance(v,(float,int)) for v in value]) },
486505

487506
'alpha' : { 'Default' : 1.0,
488-
'Description' : '',
507+
'Description' : 'Opacity of [hvat]lines. float from 0.0 to 1.0 '+
508+
' (1.0 means fully opaque; 0.0 means transparent.',
489509
'Validator' : lambda value: isinstance(value,(float,int)) },
490510

491511

492512
'tline_use' : { 'Default' : 'close',
493-
'Description' : '',
513+
'Description' : 'value to use for TREND LINE ("open","high","low","close") or sequence of'+
514+
' any combination of "open", "high", "low", "close" to use a average of the'+
515+
' specified values to determine the trend line.',
494516
'Validator' : lambda value: isinstance(value,str)
495517
or (isinstance(value,(list,tuple))
496518
and all([isinstance(v,str) for v in value]) ) },
497519

498520
'tline_method': { 'Default' : 'point-to-point',
499-
'Description' : '',
521+
'Description' : 'method for TREND LINE determination: "point-to-point" or "least-squares"',
500522
'Validator' : lambda value: value in ['point-to-point','least-squares'] }
501523
}
502524

src/mplfinance/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
version_info = (0, 12, 8, 'beta', 8)
2+
version_info = (0, 12, 8, 'beta', 9)
33

44
_specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''}
55

0 commit comments

Comments
 (0)