Ejemplo n.º 1
0
def test_cross_ma():
    factor = CrossMaFactor(codes=['000338'],
                           start_timestamp='2019-01-01',
                           end_timestamp='2019-06-10',
                           level=IntervalLevel.LEVEL_1DAY,
                           provider=Provider.JoinQuant,
                           windows=[5, 10],
                           adjust_type='qfq')
    print(factor.factor_df.tail())
    print(factor.result_df.tail())

    score = factor.result_df['score']

    assert score[('stock_sz_000338', '2019-06-03')] == True
    assert score[('stock_sz_000338', '2019-06-04')] == True
    assert ('stock_sz_000338',
            '2019-06-05') not in score or score[('stock_sz_000338',
                                                 '2019-06-05')] == False
    assert ('stock_sz_000338',
            '2019-06-06') not in score or score[('stock_sz_000338',
                                                 '2019-06-06')] == False
    assert ('stock_sz_000338',
            '2019-06-10') not in score or score[('stock_sz_000338',
                                                 '2019-06-10')] == False

    factor.move_on()
    score = factor.result_df['score']
    assert score[('stock_sz_000338', '2019-06-17')] == True
Ejemplo n.º 2
0
def test_cross_ma():
    factor = CrossMaFactor(entity_type='stock',
                           codes=['000338'],
                           start_timestamp='2019-01-01',
                           end_timestamp='2019-06-10',
                           level=IntervalLevel.LEVEL_1DAY,
                           provider='joinquant',
                           windows=[5,10])
    print(factor.get_factor_df().tail())
    print(factor.get_result_df().tail())

    score = factor.get_result_df()['score']

    assert score[('stock_sz_000338', '2019-06-03')] == True
    assert score[('stock_sz_000338', '2019-06-04')] == True
    assert ('stock_sz_000338', '2019-06-05') not in score or score[('stock_sz_000338', '2019-06-05')] == False
    assert ('stock_sz_000338', '2019-06-06') not in score or score[('stock_sz_000338', '2019-06-06')] == False
    assert ('stock_sz_000338', '2019-06-10') not in score or score[('stock_sz_000338', '2019-06-10')] == False

    factor.move_on()
    score = factor.get_result_df()['score']
    assert score[('stock_sz_000338', '2019-06-17')] == True
Ejemplo n.º 3
0
def test_cross_ma():
    factor = CrossMaFactor(
        codes=["000338"],
        start_timestamp="2019-01-01",
        end_timestamp="2019-06-10",
        level=IntervalLevel.LEVEL_1DAY,
        provider="joinquant",
        windows=[5, 10],
        adjust_type="qfq",
    )
    print(factor.factor_df.tail())
    print(factor.result_df.tail())

    score = factor.result_df["filter_result"]

    assert score[("stock_sz_000338", "2019-06-03")] == True
    assert score[("stock_sz_000338", "2019-06-04")] == True
    assert ("stock_sz_000338", "2019-06-05") not in score or score[("stock_sz_000338", "2019-06-05")] == False
    assert ("stock_sz_000338", "2019-06-06") not in score or score[("stock_sz_000338", "2019-06-06")] == False
    assert ("stock_sz_000338", "2019-06-10") not in score or score[("stock_sz_000338", "2019-06-10")] == False

    factor.move_on()
    score = factor.result_df["filter_result"]
    assert score[("stock_sz_000338", "2019-06-17")] == True