mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Merge pull request #169 from jblestang/fix_ticker_interval
Fix ticker interval
This commit is contained in:
commit
77023c0ecf
|
@ -35,7 +35,7 @@ def get_timeframe(data: Dict[str, Dict]) -> Tuple[arrow.Arrow, arrow.Arrow]:
|
||||||
return arrow.get(min_date), arrow.get(max_date)
|
return arrow.get(min_date), arrow.get(max_date)
|
||||||
|
|
||||||
|
|
||||||
def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currency) -> str:
|
def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currency, ticker_interval) -> str:
|
||||||
"""
|
"""
|
||||||
Generates and returns a text table for the given backtest data and the results dataframe
|
Generates and returns a text table for the given backtest data and the results dataframe
|
||||||
:return: pretty printed table with tabulate as str
|
:return: pretty printed table with tabulate as str
|
||||||
|
@ -49,7 +49,7 @@ def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currenc
|
||||||
len(result.index),
|
len(result.index),
|
||||||
'{:.2f}%'.format(result.profit.mean() * 100.0),
|
'{:.2f}%'.format(result.profit.mean() * 100.0),
|
||||||
'{:.08f} {}'.format(result.profit.sum(), stake_currency),
|
'{:.08f} {}'.format(result.profit.sum(), stake_currency),
|
||||||
'{:.2f}'.format(result.duration.mean() * 5),
|
'{:.2f}'.format(result.duration.mean() * ticker_interval),
|
||||||
])
|
])
|
||||||
|
|
||||||
# Append Total
|
# Append Total
|
||||||
|
@ -58,7 +58,7 @@ def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currenc
|
||||||
len(results.index),
|
len(results.index),
|
||||||
'{:.2f}%'.format(results.profit.mean() * 100.0),
|
'{:.2f}%'.format(results.profit.mean() * 100.0),
|
||||||
'{:.08f} {}'.format(results.profit.sum(), stake_currency),
|
'{:.08f} {}'.format(results.profit.sum(), stake_currency),
|
||||||
'{:.2f}'.format(results.duration.mean() * 5),
|
'{:.2f}'.format(results.duration.mean() * ticker_interval),
|
||||||
])
|
])
|
||||||
return tabulate(tabular_data, headers=headers)
|
return tabulate(tabular_data, headers=headers)
|
||||||
|
|
||||||
|
@ -162,5 +162,5 @@ def start(args):
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
'\n====================== BACKTESTING REPORT ======================================\n%s',
|
'\n====================== BACKTESTING REPORT ======================================\n%s',
|
||||||
generate_text_table(data, results, config['stake_currency'])
|
generate_text_table(data, results, config['stake_currency'], args.ticker_interval)
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,7 @@ from freqtrade import exchange, optimize
|
||||||
from freqtrade.exchange import Bittrex
|
from freqtrade.exchange import Bittrex
|
||||||
from freqtrade.optimize.backtesting import backtest
|
from freqtrade.optimize.backtesting import backtest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
def test_backtest(default_conf, mocker):
|
def test_backtest(default_conf, mocker):
|
||||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||||
|
@ -14,3 +15,18 @@ def test_backtest(default_conf, mocker):
|
||||||
results = backtest(default_conf, optimize.preprocess(data), 10, True)
|
results = backtest(default_conf, optimize.preprocess(data), 10, True)
|
||||||
num_resutls = len(results)
|
num_resutls = len(results)
|
||||||
assert num_resutls > 0
|
assert num_resutls > 0
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
1
freqtrade/tests/testdata/BTC_UNITEST-1.json
vendored
Normal file
1
freqtrade/tests/testdata/BTC_UNITEST-1.json
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user