Remove hardcoded exchange while backtesting

This commit is contained in:
enenn 2018-03-11 21:26:53 +01:00
parent 685ee42fbc
commit 251c86197a
2 changed files with 5 additions and 4 deletions

View File

@ -3,7 +3,6 @@
import logging import logging
from typing import Dict, Tuple from typing import Dict, Tuple
import ccxt
import arrow import arrow
from pandas import DataFrame, Series from pandas import DataFrame, Series
from tabulate import tabulate from tabulate import tabulate
@ -114,7 +113,7 @@ def backtest(args) -> DataFrame:
records = [] records = []
trades = [] trades = []
trade_count_lock: dict = {} trade_count_lock: dict = {}
exchange._API = ccxt.binance()
for pair, pair_data in processed.items(): for pair, pair_data in processed.items():
pair_data['buy'], pair_data['sell'] = 0, 0 pair_data['buy'], pair_data['sell'] = 0, 0
ticker = populate_sell_trend(populate_buy_trend(pair_data)) ticker = populate_sell_trend(populate_buy_trend(pair_data))
@ -165,13 +164,13 @@ def start(args):
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
) )
exchange._API = ccxt.binance()
logger.info('Using config: %s ...', args.config) logger.info('Using config: %s ...', args.config)
config = misc.load_config(args.config) config = misc.load_config(args.config)
ticker_interval = config.get('ticker_interval', args.ticker_interval) ticker_interval = config.get('ticker_interval', args.ticker_interval)
logger.info('Using ticker_interval: %s ...', ticker_interval) logger.info('Using ticker_interval: %s ...', ticker_interval)
exchange.init(config)
data = {} data = {}
pairs = config['exchange']['pair_whitelist'] pairs = config['exchange']['pair_whitelist']
if args.live: if args.live:

View File

@ -162,6 +162,8 @@ def test_backtest_start(default_conf, mocker, caplog):
mocker.patch('freqtrade.misc.load_config', new=lambda s: default_conf) mocker.patch('freqtrade.misc.load_config', new=lambda s: default_conf)
mocker.patch.multiple('freqtrade.optimize', mocker.patch.multiple('freqtrade.optimize',
load_data=mocked_load_data) load_data=mocked_load_data)
# patch validate_pairs to do nothing since UNITTEST/BTC pair doesn't exist
mocker.patch('freqtrade.exchange.validate_pairs', new=lambda s: None)
args = MagicMock() args = MagicMock()
args.ticker_interval = '1m' args.ticker_interval = '1m'
args.level = 10 args.level = 10