예제 #1
0
def test_load_tickerdata_file() -> None:
    # 7 does not exist in either format.
    assert not load_tickerdata_file(None, 'UNITTEST/BTC', '7m')
    # 1 exists only as a .json
    tickerdata = load_tickerdata_file(None, 'UNITTEST/BTC', '1m')
    assert _BTC_UNITTEST_LENGTH == len(tickerdata)
    # 8 .json is empty and will fail if it's loaded. .json.gz is a copy of 1.json
    tickerdata = load_tickerdata_file(None, 'UNITTEST/BTC', '8m')
    assert _BTC_UNITTEST_LENGTH == len(tickerdata)
예제 #2
0
def test_tickerdata_to_dataframe(default_conf) -> None:
    strategy = DefaultStrategy(default_conf)

    timerange = TimeRange(None, 'line', 0, -100)
    tick = load_tickerdata_file(None, 'UNITTEST/BTC', '1m', timerange=timerange)
    tickerlist = {'UNITTEST/BTC': tick}
    data = strategy.tickerdata_to_dataframe(tickerlist)
    assert len(data['UNITTEST/BTC']) == 99       # partial candle was removed
예제 #3
0
def test_populate_indicators(hyperopt) -> None:
    tick = load_tickerdata_file(None, 'UNITTEST/BTC', '1m')
    tickerlist = {'UNITTEST/BTC': tick}
    dataframes = hyperopt.tickerdata_to_dataframe(tickerlist)
    dataframe = hyperopt.populate_indicators(dataframes['UNITTEST/BTC'],
                                             {'pair': 'UNITTEST/BTC'})

    # Check if some indicators are generated. We will not test all of them
    assert 'adx' in dataframe
    assert 'mfi' in dataframe
    assert 'rsi' in dataframe
예제 #4
0
def test_tickerdata_to_dataframe(default_conf) -> None:
    """
    Test Analyze.tickerdata_to_dataframe() method
    """
    analyze = Analyze(default_conf)

    timerange = ((None, 'line'), None, -100)
    tick = load_tickerdata_file(None, 'BTC_UNITEST', 1, timerange=timerange)
    tickerlist = {'BTC_UNITEST': tick}
    data = analyze.tickerdata_to_dataframe(tickerlist)
    assert len(data['BTC_UNITEST']) == 100
예제 #5
0
def test_buy_strategy_generator() -> None:
    """
    Test Hyperopt.buy_strategy_generator()
    """
    tick = load_tickerdata_file(None, 'BTC_UNITEST', 1)
    tickerlist = {'BTC_UNITEST': tick}
    dataframes = _HYPEROPT.tickerdata_to_dataframe(tickerlist)
    dataframe = _HYPEROPT.populate_indicators(dataframes['BTC_UNITEST'])

    populate_buy_trend = _HYPEROPT.buy_strategy_generator({
        'uptrend_long_ema': {
            'enabled': True
        },
        'macd_below_zero': {
            'enabled': True
        },
        'uptrend_short_ema': {
            'enabled': True
        },
        'mfi': {
            'enabled': True,
            'value': 20
        },
        'fastd': {
            'enabled': True,
            'value': 20
        },
        'adx': {
            'enabled': True,
            'value': 20
        },
        'rsi': {
            'enabled': True,
            'value': 20
        },
        'over_sar': {
            'enabled': True,
        },
        'green_candle': {
            'enabled': True,
        },
        'uptrend_sma': {
            'enabled': True,
        },
        'trigger': {
            'type': 'lower_bb'
        }
    })
    result = populate_buy_trend(dataframe)
    # Check if some indicators are generated. We will not test all of them
    assert 'buy' in result
    assert 1 in result['buy']
예제 #6
0
def test_populate_indicators() -> None:
    """
    Test Hyperopt.populate_indicators()
    """
    tick = load_tickerdata_file(None, 'BTC_UNITEST', 1)
    tickerlist = {'BTC_UNITEST': tick}
    dataframes = _HYPEROPT.tickerdata_to_dataframe(tickerlist)
    dataframe = _HYPEROPT.populate_indicators(dataframes['BTC_UNITEST'])

    # Check if some indicators are generated. We will not test all of them
    assert 'adx' in dataframe
    assert 'ao' in dataframe
    assert 'cci' in dataframe
예제 #7
0
def test_tickerdata_to_dataframe(default_conf) -> None:
    """
    Test Analyze.tickerdata_to_dataframe() method
    """
    analyze = Analyze(default_conf)

    timerange = TimeRange(None, 'line', 0, -100)
    tick = load_tickerdata_file(None,
                                'UNITTEST/BTC',
                                '1m',
                                timerange=timerange)
    tickerlist = {'UNITTEST/BTC': tick}
    data = analyze.tickerdata_to_dataframe(tickerlist)
    assert len(data['UNITTEST/BTC']) == 99  # partial candle was removed
예제 #8
0
def test_common_datearray(default_conf, mocker) -> None:
    """
    Test common_datearray()
    :return: None
    """
    analyze = Analyze(default_conf)
    tick = load_tickerdata_file(None, 'BTC_UNITEST', 1)
    tickerlist = {'BTC_UNITEST': tick}
    dataframes = analyze.tickerdata_to_dataframe(tickerlist)

    dates = common_datearray(dataframes)

    assert dates.size == dataframes['BTC_UNITEST']['date'].size
    assert dates[0] == dataframes['BTC_UNITEST']['date'][0]
    assert dates[-1] == dataframes['BTC_UNITEST']['date'][-1]
예제 #9
0
def test_buy_strategy_generator(hyperopt) -> None:
    tick = load_tickerdata_file(None, 'UNITTEST/BTC', '1m')
    tickerlist = {'UNITTEST/BTC': tick}
    dataframes = hyperopt.tickerdata_to_dataframe(tickerlist)
    dataframe = hyperopt.populate_indicators(dataframes['UNITTEST/BTC'],
                                             {'pair': 'UNITTEST/BTC'})

    populate_buy_trend = hyperopt.buy_strategy_generator({
        'adx-value': 20,
        'fastd-value': 20,
        'mfi-value': 20,
        'rsi-value': 20,
        'adx-enabled': True,
        'fastd-enabled': True,
        'mfi-enabled': True,
        'rsi-enabled': True,
        'trigger': 'bb_lower'
    })
    result = populate_buy_trend(dataframe, {'pair': 'UNITTEST/BTC'})
    # Check if some indicators are generated. We will not test all of them
    assert 'buy' in result
    assert 1 in result['buy']
예제 #10
0
def test_load_tickerdata_file():
    assert not load_tickerdata_file(None, 'BTC_UNITEST', 7)
    tickerdata = load_tickerdata_file(None, 'BTC_UNITEST', 1)
    assert _btc_unittest_length == len(tickerdata)