Merge pull request #315 from kryofly/tests_jan05
tests cover more backtesting
This commit is contained in:
@@ -12,6 +12,27 @@ from freqtrade.analyze import populate_indicators, parse_ticker_dataframe
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def load_tickerdata_file(pair, ticker_interval):
|
||||
"""
|
||||
Load a pair from file,
|
||||
:return dict OR empty if unsuccesful
|
||||
"""
|
||||
path = testdata_path()
|
||||
file = '{abspath}/{pair}-{ticker_interval}.json'.format(
|
||||
abspath=path,
|
||||
pair=pair,
|
||||
ticker_interval=ticker_interval,
|
||||
)
|
||||
# The file does not exist we download it
|
||||
if not os.path.isfile(file):
|
||||
return None
|
||||
|
||||
# Read the file, load the json
|
||||
with open(file) as tickerdata:
|
||||
pairdata = json.load(tickerdata)
|
||||
return pairdata
|
||||
|
||||
|
||||
def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None,
|
||||
refresh_pairs: Optional[bool] = False) -> Dict[str, List]:
|
||||
"""
|
||||
@@ -20,7 +41,6 @@ def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None,
|
||||
:param pairs: list of pairs
|
||||
:return: dict
|
||||
"""
|
||||
path = testdata_path()
|
||||
result = {}
|
||||
|
||||
_pairs = pairs or hyperopt_optimize_conf()['exchange']['pair_whitelist']
|
||||
@@ -31,18 +51,13 @@ def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None,
|
||||
download_pairs(_pairs)
|
||||
|
||||
for pair in _pairs:
|
||||
file = '{abspath}/{pair}-{ticker_interval}.json'.format(
|
||||
abspath=path,
|
||||
pair=pair,
|
||||
ticker_interval=ticker_interval,
|
||||
)
|
||||
# The file does not exist we download it
|
||||
if not os.path.isfile(file):
|
||||
pairdata = load_tickerdata_file(pair, ticker_interval)
|
||||
if not pairdata:
|
||||
# download the tickerdata from exchange
|
||||
download_backtesting_testdata(pair=pair, interval=ticker_interval)
|
||||
|
||||
# Read the file, load the json
|
||||
with open(file) as tickerdata:
|
||||
result[pair] = json.load(tickerdata)
|
||||
# and retry reading the pair
|
||||
pairdata = load_tickerdata_file(pair, ticker_interval)
|
||||
result[pair] = pairdata
|
||||
return result
|
||||
|
||||
|
||||
|
@@ -12,8 +12,9 @@ from freqtrade import exchange
|
||||
from freqtrade.analyze import populate_buy_trend, populate_sell_trend
|
||||
from freqtrade.exchange import Bittrex
|
||||
from freqtrade.main import min_roi_reached
|
||||
from freqtrade.misc import load_config
|
||||
from freqtrade.optimize import load_data, preprocess
|
||||
import freqtrade.misc as misc
|
||||
from freqtrade.optimize import preprocess
|
||||
import freqtrade.optimize as optimize
|
||||
from freqtrade.persistence import Trade
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -149,7 +150,7 @@ def start(args):
|
||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||
|
||||
logger.info('Using config: %s ...', args.config)
|
||||
config = load_config(args.config)
|
||||
config = misc.load_config(args.config)
|
||||
|
||||
logger.info('Using ticker_interval: %s ...', args.ticker_interval)
|
||||
|
||||
@@ -161,8 +162,8 @@ def start(args):
|
||||
data[pair] = exchange.get_ticker_history(pair, args.ticker_interval)
|
||||
else:
|
||||
logger.info('Using local backtesting data (using whitelist in given config) ...')
|
||||
data = load_data(pairs=pairs, ticker_interval=args.ticker_interval,
|
||||
refresh_pairs=args.refresh_pairs)
|
||||
data = optimize.load_data(pairs=pairs, ticker_interval=args.ticker_interval,
|
||||
refresh_pairs=args.refresh_pairs)
|
||||
|
||||
logger.info('Using stake_currency: %s ...', config['stake_currency'])
|
||||
logger.info('Using stake_amount: %s ...', config['stake_amount'])
|
||||
|
Reference in New Issue
Block a user