@@ -689,13 +689,16 @@ def sgplot(sg, new=True, axes=None, style=1, kdata=None):
689
689
)
690
690
691
691
692
- def evplot (ev , ref_kdata , new = True , axes = None ):
692
+ def evplot (ev , ref_kdata , new = True , axes = None , upcolor = 'red' , downcolor = 'blue' , alpha = 0.2 ):
693
693
"""绘制市场有效判断
694
694
695
695
:param EnvironmentBase cn: 系统有效条件
696
696
:param KData ref_kdata: 用于日期参考
697
697
:param new: 仅在未指定axes的情况下生效,当为True时,创建新的窗口对象并在其中进行绘制
698
698
:param axes: 指定在那个轴对象中进行绘制
699
+ :param upcolor: 有效时的颜色
700
+ :param downcolor: 无效时的颜色
701
+ :param alpha: 透明度
699
702
"""
700
703
refdates = ref_kdata .get_datetime_list ()
701
704
if axes is None :
@@ -709,18 +712,21 @@ def evplot(ev, ref_kdata, new=True, axes=None):
709
712
x = np .array ([i for i in range (len (refdates ))])
710
713
y1 = np .array ([1 if ev .is_valid (d ) else - 1 for d in refdates ])
711
714
y2 = np .array ([- 1 if ev .is_valid (d ) else 1 for d in refdates ])
712
- axes .fill_between (x , y1 , y2 , where = y2 > y1 , facecolor = 'blue' , alpha = 0.6 )
713
- axes .fill_between (x , y1 , y2 , where = y2 < y1 , facecolor = 'red' , alpha = 0.6 )
715
+ axes .fill_between (x , y1 , y2 , where = y2 > y1 , facecolor = downcolor , alpha = alpha )
716
+ axes .fill_between (x , y1 , y2 , where = y2 < y1 , facecolor = upcolor , alpha = alpha )
714
717
715
718
716
- def cnplot (cn , new = True , axes = None , kdata = None ):
719
+ def cnplot (cn , new = True , axes = None , kdata = None , upcolor = 'red' , downcolor = 'blue' , alpha = 0.2 ):
717
720
"""绘制系统有效条件
718
721
719
722
:param ConditionBase cn: 系统有效条件
720
723
:param new: 仅在未指定axes的情况下生效,当为True时,创建新的窗口对象并在其中进行绘制
721
724
:param axes: 指定在那个轴对象中进行绘制
722
725
:param KData kdata: 指定的KData,如该值为None,则认为该系统有效条件已经
723
726
指定了交易对象,否则,使用该参数作为交易对象
727
+ :param upcolor: 有效数时的颜色
728
+ :param downcolor: 无效时的颜色
729
+ :param alpha: 透明度
724
730
"""
725
731
if kdata is None :
726
732
kdata = cn .to
@@ -739,8 +745,8 @@ def cnplot(cn, new=True, axes=None, kdata=None):
739
745
x = np .array ([i for i in range (len (refdates ))])
740
746
y1 = np .array ([1 if cn .is_valid (d ) else - 1 for d in refdates ])
741
747
y2 = np .array ([- 1 if cn .is_valid (d ) else 1 for d in refdates ])
742
- axes .fill_between (x , y1 , y2 , where = y2 > y1 , facecolor = 'blue' , alpha = 0.6 )
743
- axes .fill_between (x , y1 , y2 , where = y2 < y1 , facecolor = 'red' , alpha = 0.6 )
748
+ axes .fill_between (x , y1 , y2 , where = y2 > y1 , facecolor = downcolor , alpha = alpha )
749
+ axes .fill_between (x , y1 , y2 , where = y2 < y1 , facecolor = upcolor , alpha = alpha )
744
750
745
751
746
752
def sysplot (sys , new = True , axes = None , style = 1 , only_draw_close = False ):
0 commit comments