2017-11-24 22:58:35 +00:00
|
|
|
# pragma pylint: disable=missing-docstring,W0212
|
|
|
|
|
|
|
|
|
2017-11-25 00:04:11 +00:00
|
|
|
from freqtrade import exchange, optimize
|
2017-11-24 22:58:35 +00:00
|
|
|
from freqtrade.exchange import Bittrex
|
2017-11-25 00:04:11 +00:00
|
|
|
from freqtrade.optimize.backtesting import backtest
|
2017-11-24 22:58:35 +00:00
|
|
|
|
2017-12-11 21:11:06 +00:00
|
|
|
import pytest
|
2017-11-24 22:58:35 +00:00
|
|
|
|
2017-11-25 00:04:11 +00:00
|
|
|
def test_backtest(default_conf, mocker):
|
|
|
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
2017-11-24 22:58:35 +00:00
|
|
|
exchange._API = Bittrex({'key': '', 'secret': ''})
|
|
|
|
|
2017-11-25 00:04:11 +00:00
|
|
|
data = optimize.load_data(ticker_interval=5, pairs=['BTC_ETH'])
|
|
|
|
results = backtest(default_conf, optimize.preprocess(data), 10, True)
|
2017-11-24 22:58:35 +00:00
|
|
|
num_resutls = len(results)
|
|
|
|
assert num_resutls > 0
|
2017-12-11 21:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_1min_ticker_interval(default_conf, mocker):
|
|
|
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
|
|
|
exchange._API = Bittrex({'key': '', 'secret': ''})
|
|
|
|
|
|
|
|
# Run a backtesting for an exiting 5min ticker_interval
|
|
|
|
data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
|
|
|
|
results = backtest(default_conf, optimize.preprocess(data), 1, True)
|
|
|
|
assert len(results) > 0
|
|
|
|
|
|
|
|
# Run a backtesting for 5min ticker_interval
|
|
|
|
with pytest.raises(FileNotFoundError):
|
|
|
|
data = optimize.load_data(ticker_interval=5, pairs=['BTC_UNITEST'])
|
|
|
|
results = backtest(default_conf, optimize.preprocess(data), 1, True)
|