refactor get_timeframe out of backtesting class

This commit is contained in:
Matthias
2018-10-17 19:59:33 +02:00
parent 8a3272e7c5
commit d7459bbbf3
4 changed files with 41 additions and 39 deletions

View File

@@ -11,7 +11,10 @@ except ImportError:
import logging
import os
from typing import Optional, List, Dict, Tuple, Any
import operator
import arrow
from pandas import DataFrame
from freqtrade import misc, constants, OperationalException
from freqtrade.exchange import Exchange
@@ -59,6 +62,20 @@ def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]:
return tickerlist[start_index:stop_index]
def get_timeframe(data: Dict[str, DataFrame]) -> Tuple[arrow.Arrow, arrow.Arrow]:
"""
Get the maximum timeframe for the given backtest data
:param data: dictionary with preprocessed backtesting data
:return: tuple containing min_date, max_date
"""
timeframe = [
(arrow.get(frame['date'].min()), arrow.get(frame['date'].max()))
for frame in data.values()
]
return min(timeframe, key=operator.itemgetter(0))[0], \
max(timeframe, key=operator.itemgetter(1))[1]
def load_tickerdata_file(
datadir: str, pair: str,
ticker_interval: str,