@@ -165,13 +165,13 @@ def _updown_colors(upcolor,downcolor,opens,closes,use_prev_close=False):
165
165
return [first ] + _list
166
166
167
167
168
- def _updownhollow_colors (upcolor ,downcolor ,uphollow , downhollow ,opens ,closes ):
169
- if upcolor == downcolor == downhollow == uphollow :
168
+ def _updownhollow_colors (upcolor ,downcolor ,hollowcolor ,opens ,closes ):
169
+ if upcolor == downcolor :
170
170
return upcolor
171
- umap = {True : upcolor , False : uphollow }
172
- dmap = {True : downcolor , False : downhollow }
173
- _list = [ umap [cls > opn ] if cls > cls0 else dmap [ cls < opn ] for opn0 , cls0 , opn , cls in zip ( opens [0 : - 1 ], closes [ 0 : - 1 ], opens [ 1 :], closes [ 1 :]) ]
174
- first = upcolor if closes [ 0 ] > opens [0 ] else downcolor
171
+ umap = {True : hollowcolor , False : upcolor }
172
+ dmap = {True : hollowcolor , False : downcolor }
173
+ first = umap [closes [ 0 ] > opens [0 ] ]
174
+ _list = [ umap [ cls > opn ] if cls > cls0 else dmap [ cls > opn ] for opn0 , cls0 , opn , cls in zip ( opens [0 : - 1 ], closes [ 0 : - 1 ], opens [ 1 :], closes [ 1 :]) ]
175
175
return [first ] + _list
176
176
177
177
@@ -488,17 +488,6 @@ def _construct_candlestick_collections(dates, opens, highs, lows, closes, market
488
488
return [rangeCollection , barCollection ]
489
489
490
490
491
- def alpha_handler (color , alpha ):
492
- """Checks the color input for an alpha value. Returns the rgba color code with lesser
493
- of existing or provided alpha
494
- """
495
- color_code = mcolors .to_rgba (color )
496
- if color_code [- 1 ] <= alpha :
497
- return color_code
498
- else :
499
- return mcolors .to_rgba (color , alpha )
500
-
501
-
502
491
def _construct_hollow_candlestick_collections (dates , opens , highs , lows , closes , marketcolors = None , config = None ):
503
492
"""Represent the open, close as a bar line and high low range as a
504
493
vertical line. Same as basic candlestick, but utilizes solid and hollow candlesticks
@@ -530,7 +519,7 @@ def _construct_hollow_candlestick_collections(dates, opens, highs, lows, closes,
530
519
_check_input (opens , highs , lows , closes )
531
520
532
521
if marketcolors is None :
533
- marketcolors = _get_mpfstyle ('hollow ' )['marketcolors' ]
522
+ marketcolors = _get_mpfstyle ('classic ' )['marketcolors' ]
534
523
#print('default market colors:',marketcolors)
535
524
536
525
datalen = len (dates )
@@ -555,22 +544,16 @@ def _construct_hollow_candlestick_collections(dates, opens, highs, lows, closes,
555
544
556
545
alpha = marketcolors ['alpha' ]
557
546
558
- uc = alpha_handler (marketcolors ['candle' ][ 'up' ], alpha )
559
- dc = alpha_handler (marketcolors ['candle' ]['down' ], alpha )
560
- try :
561
- uh = alpha_handler (marketcolors ['hollow' ]['up' ], alpha )
562
- dh = alpha_handler (marketcolors ['hollow' ]['down' ], alpha )
563
- except KeyError as e :
564
- raise Exception ('Improper style definition for hollow candle type plotting' ) from e
565
- colors = _updownhollow_colors (uc , dc , uh , dh , opens , closes )
547
+ uc = mcolors .to_rgba (marketcolors ['candle' ][ 'up' ], alpha )
548
+ dc = mcolors .to_rgba (marketcolors ['candle' ]['down' ], alpha )
549
+
550
+ hc = mcolors .to_rgba (marketcolors ['hollow' ]) if 'hollow' in marketcolors else (0 ,0 ,0 ,0 )
551
+
552
+ colors = _updownhollow_colors (uc , dc , hc , opens , closes ) # for candle body.
566
553
567
- uc = mcolors .to_rgba (marketcolors ['edge' ][ 'up' ], 1.0 )
568
- dc = mcolors .to_rgba (marketcolors ['edge' ]['down' ], 1.0 )
569
- edgecolor = _updownhollow_colors (uc , dc , uc , dc , opens , closes )
554
+ edgecolor = _updown_colors (uc , dc , opens , closes , use_prev_close = True )
570
555
571
- uc = mcolors .to_rgba (marketcolors ['wick' ][ 'up' ], 1.0 )
572
- dc = mcolors .to_rgba (marketcolors ['wick' ]['down' ], 1.0 )
573
- wickcolor = _updownhollow_colors (uc , dc , uc , dc , opens , closes )
556
+ wickcolor = _updown_colors (uc , dc , opens , closes , use_prev_close = True )
574
557
575
558
lw = config ['_width_config' ]['candle_linewidth' ]
576
559
0 commit comments