示例#1
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',
                           short_window=5,
                           long_window=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 score[('stock_sz_000338', '2019-06-05')] == False
    assert score[('stock_sz_000338', '2019-06-06')] == False
    assert 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
示例#2
0
def test_cross_ma():
    factor = CrossMaFactor(security_type=SecurityType.stock,
                           codes=['000338'],
                           start_timestamp='2019-01-01',
                           end_timestamp='2019-06-10',
                           level=TradingLevel.LEVEL_1DAY,
                           provider=Provider.JOINQUANT,
                           short_window=5,
                           long_window=10)
    print(factor.get_depth_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 score[('stock_sz_000338', '2019-06-05')] == False
    assert score[('stock_sz_000338', '2019-06-06')] == False
    assert 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