freqtrade_origin/freqtrade/tests/strategy/test_default_strategy.py
Matthias f286ba6b87 overload populate_indicators to work with and without pair argumen
all while not breaking users strategies
2018-07-29 20:55:40 +02:00

36 lines
1.2 KiB
Python

import json
import pytest
from pandas import DataFrame
from freqtrade.exchange.exchange_helpers import parse_ticker_dataframe
from freqtrade.strategy.default_strategy import DefaultStrategy
@pytest.fixture
def result():
with open('freqtrade/tests/testdata/ETH_BTC-1m.json') as data_file:
return parse_ticker_dataframe(json.load(data_file))
def test_default_strategy_structure():
assert hasattr(DefaultStrategy, 'minimal_roi')
assert hasattr(DefaultStrategy, 'stoploss')
assert hasattr(DefaultStrategy, 'ticker_interval')
assert hasattr(DefaultStrategy, 'populate_indicators')
assert hasattr(DefaultStrategy, 'populate_buy_trend')
assert hasattr(DefaultStrategy, 'populate_sell_trend')
def test_default_strategy(result):
strategy = DefaultStrategy({})
pair = 'ETH/BTC'
assert type(strategy.minimal_roi) is dict
assert type(strategy.stoploss) is float
assert type(strategy.ticker_interval) is str
indicators = strategy.populate_indicators(result, pair)
assert type(indicators) is DataFrame
assert type(strategy.populate_buy_trend(indicators, pair)) is DataFrame
assert type(strategy.populate_sell_trend(indicators, pair)) is DataFrame