@@ -400,16 +400,25 @@ def plot( data, **kwargs ):
400400 collections = _construct_mpf_collections (ptype ,dates ,xdates ,opens ,highs ,lows ,closes ,volumes ,config ,style )
401401
402402 if ptype in VALID_PMOVE_TYPES :
403- collections , new_dates , volumes , brick_values , size = collections
404- formatter = IntegerIndexDateTimeFormatter (new_dates , fmtstring )
405- xdates = np .arange (len (new_dates ))
403+ collections , calculated_values = collections
404+ volumes = calculated_values ['volumes' ]
405+ pmove_dates = calculated_values ['dates' ]
406+ pmove_values = calculated_values ['values' ]
407+ if all ([isinstance (v ,(list ,tuple )) for v in pmove_values ]):
408+ pmove_avgvals = [sum (v )/ len (v ) for v in pmove_values ]
409+ else :
410+ pmove_avgvals = pmove_values
411+ pmove_size = calculated_values ['size' ]
412+ pmove_counts = calculated_values ['counts' ] if 'counts' in calculated_values else None
413+ formatter = IntegerIndexDateTimeFormatter (pmove_dates , fmtstring )
414+ xdates = np .arange (len (pmove_dates ))
406415
407416 if collections is not None :
408417 for collection in collections :
409418 axA1 .add_collection (collection )
410419
411420 if ptype in VALID_PMOVE_TYPES :
412- mavprices = _plot_mav (axA1 ,config ,xdates ,brick_values )
421+ mavprices = _plot_mav (axA1 ,config ,xdates ,pmove_avgvals )
413422 else :
414423 mavprices = _plot_mav (axA1 ,config ,xdates ,closes )
415424
@@ -428,8 +437,8 @@ def plot( data, **kwargs ):
428437 _lows = lows
429438 _highs = highs
430439 else :
431- _lows = brick_values
432- _highs = [brick + size for brick in brick_values ]
440+ _lows = pmove_avgvals
441+ _highs = [value + pmove_size for value in pmove_avgvals ]
433442
434443 miny = np .nanmin (_lows )
435444 maxy = np .nanmax (_highs )
@@ -458,13 +467,18 @@ def plot( data, **kwargs ):
458467
459468 if config ['return_calculated_values' ] is not None :
460469 retdict = config ['return_calculated_values' ]
461- if ptype in VALID_PMOVE_TYPES :
462- prekey = ptype
463- retdict [prekey + '_bricks' ] = brick_values
464- retdict [prekey + '_dates' ] = mdates .num2date (new_dates )
465- retdict [prekey + '_size' ] = size
466- if config ['volume' ]:
467- retdict [prekey + '_volumes' ] = volumes
470+ if ptype == 'renko' :
471+ retdict ['renko_bricks' ] = pmove_values
472+ retdict ['renko_dates' ] = mdates .num2date (pmove_dates )
473+ retdict ['renko_size' ] = pmove_size
474+ retdict ['renko_volumes' ] = volumes if config ['volume' ] else None
475+ elif ptype == 'pnf' :
476+ retdict ['pnf_dates' ] = mdates .num2date (pmove_dates )
477+ retdict ['pnf_counts' ] = pmove_counts
478+ retdict ['pnf_values' ] = pmove_values
479+ retdict ['pnf_avgvals' ] = pmove_avgvals
480+ retdict ['pnf_size' ] = pmove_size
481+ retdict ['pnf_volumes' ] = volumes if config ['volume' ] else None
468482 if config ['mav' ] is not None :
469483 mav = config ['mav' ]
470484 if len (mav ) != len (mavprices ):
@@ -480,7 +494,7 @@ def plot( data, **kwargs ):
480494 # Note: these are NOT mutually exclusive, so the order of this
481495 # if/elif is important: VALID_PMOVE_TYPES must be first.
482496 if ptype in VALID_PMOVE_TYPES :
483- dtix = pd .DatetimeIndex ([dt for dt in mdates .num2date (new_dates )])
497+ dtix = pd .DatetimeIndex ([dt for dt in mdates .num2date (pmove_dates )])
484498 elif not config ['show_nontrading' ]:
485499 dtix = data .index
486500 else :
0 commit comments