Fix tests

This commit is contained in:
Matthias 2018-11-09 19:34:18 +01:00
parent 5c5fe4c13a
commit 292962d64d
2 changed files with 9 additions and 3 deletions

View File

@ -4,9 +4,10 @@ import arrow
from pandas import DataFrame
from freqtrade.strategy.interface import SellType
from freqtrade.constants import TICKER_INTERVAL_MINUTES
ticker_start_time = arrow.get(2018, 10, 3)
ticker_interval_in_minute = 60
tests_ticker_interval = "1h"
class BTrade(NamedTuple):
@ -31,7 +32,7 @@ class BTContainer(NamedTuple):
def _get_frame_time_from_offset(offset):
return ticker_start_time.shift(
minutes=(offset * ticker_interval_in_minute)).datetime
minutes=(offset * TICKER_INTERVAL_MINUTES[tests_ticker_interval])).datetime
def _build_backtest_dataframe(ticker_with_signals):

View File

@ -6,10 +6,11 @@ from pandas import DataFrame
import pytest
from freqtrade.optimize import get_timeframe
from freqtrade.optimize.backtesting import Backtesting
from freqtrade.strategy.interface import SellType
from freqtrade.tests.optimize import (BTrade, BTContainer, _build_backtest_dataframe,
_get_frame_time_from_offset)
_get_frame_time_from_offset, tests_ticker_interval)
from freqtrade.tests.conftest import patch_exchange
@ -147,6 +148,7 @@ def test_backtest_results(default_conf, fee, mocker, caplog, data) -> None:
"""
default_conf["stoploss"] = data.stop_loss
default_conf["minimal_roi"] = {"0": data.roi}
default_conf['ticker_interval'] = tests_ticker_interval
mocker.patch('freqtrade.exchange.Exchange.get_fee', MagicMock(return_value=0.0))
patch_exchange(mocker)
frame = _build_backtest_dataframe(data.data)
@ -158,11 +160,14 @@ def test_backtest_results(default_conf, fee, mocker, caplog, data) -> None:
pair = 'UNITTEST/BTC'
# Dummy data as we mock the analyze functions
data_processed = {pair: DataFrame()}
min_date, max_date = get_timeframe({pair: frame})
results = backtesting.backtest(
{
'stake_amount': default_conf['stake_amount'],
'processed': data_processed,
'max_open_trades': 10,
'start_date': min_date,
'end_date': max_date,
}
)
print(results.T)