Example #1
0
    def to_image(self, file_image, mav=(5, 20, 120, 250), max_k_count=1000, dpi=50):
        """保存成图片

        :param file_image: str
            图片名称,支持 jpg/png/svg 格式,注意后缀
        :param mav: tuple of int
            均线系统参数
        :param max_k_count: int
            设定最大K线数量,这个值越大,生成的图片越长
        :param dpi: int
            图片分辨率
        :return:
        """
        plot_ka(self, file_image=file_image, mav=mav, max_k_count=max_k_count, dpi=dpi)
Example #2
0
def test_bei_chi():
    df = get_kline(ts_code="000001.SH",
                   end_dt="2020-04-28 15:00:00",
                   freq='D',
                   asset='I')
    ka = KlineAnalyze(df, name="日线")
    plot_ka(ka, file_image="test.jpg")

    # 线段背驰
    zs1 = {
        "start_dt": '2018-07-26 15:00:00',
        "end_dt": '2018-10-19 15:00:00',
        "direction": "down"
    }
    zs2 = {
        "start_dt": '2018-01-29 15:00:00',
        "end_dt": '2018-07-06 15:00:00',
        "direction": "down"
    }
    assert is_bei_chi(ka, zs1, zs2, mode='xd', adjust=0.9)

    zs1 = {
        "start_dt": '2013-12-10 15:00:00',
        "end_dt": '2014-01-20 15:00:00',
        "direction": "down"
    }
    zs2 = {
        "start_dt": '2013-09-12 15:00:00',
        "end_dt": '2013-11-14 15:00:00',
        "direction": "down"
    }
    assert not is_bei_chi(ka, zs1, zs2, mode='xd', adjust=0.9)

    # 笔背驰
    zs1 = {"start_dt": '2019-05-17 15:00:00', "end_dt": '2019-06-10 15:00:00'}
    zs2 = {"start_dt": '2019-04-08 15:00:00', "end_dt": '2019-05-10 15:00:00'}
    assert is_bei_chi(ka, zs1, zs2, mode='bi', adjust=0.9)

    zs1 = {"start_dt": '2018-09-28 15:00:00', "end_dt": '2018-10-19 15:00:00'}
    zs2 = {"start_dt": '2018-08-28 15:00:00', "end_dt": '2018-09-12 15:00:00'}
    assert not is_bei_chi(ka, zs1, zs2, mode='bi', adjust=0.9)