Merge pull request #2655 from freqtrade/avoid_keyerror_backtest

Use first pair of pairlist to get fee
This commit is contained in:
hroff-1902 2019-12-14 23:10:40 +03:00 committed by GitHub
commit e26f563f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -80,7 +80,7 @@ class Edge:
if config.get('fee'): if config.get('fee'):
self.fee = config['fee'] self.fee = config['fee']
else: else:
self.fee = self.exchange.get_fee() self.fee = self.exchange.get_fee(symbol=self.config['exchange']['pair_whitelist'][0])
def calculate(self) -> bool: def calculate(self) -> bool:
pairs = self.config['exchange']['pair_whitelist'] pairs = self.config['exchange']['pair_whitelist']

View File

@ -921,7 +921,7 @@ class Exchange:
raise OperationalException(e) from e raise OperationalException(e) from e
@retrier @retrier
def get_fee(self, symbol='ETH/BTC', type='', side='', amount=1, def get_fee(self, symbol, type='', side='', amount=1,
price=1, taker_or_maker='maker') -> float: price=1, taker_or_maker='maker') -> float:
try: try:
# validate that markets are loaded before trying to get fee # validate that markets are loaded before trying to get fee

View File

@ -65,7 +65,7 @@ class Backtesting:
if config.get('fee'): if config.get('fee'):
self.fee = config['fee'] self.fee = config['fee']
else: else:
self.fee = self.exchange.get_fee() self.fee = self.exchange.get_fee(symbol=self.config['exchange']['pair_whitelist'][0])
if self.config.get('runmode') != RunMode.HYPEROPT: if self.config.get('runmode') != RunMode.HYPEROPT:
self.dataprovider = DataProvider(self.config, self.exchange) self.dataprovider = DataProvider(self.config, self.exchange)

View File

@ -334,7 +334,7 @@ def test_process_expectancy(mocker, edge_conf):
edge_conf['edge']['min_trade_number'] = 2 edge_conf['edge']['min_trade_number'] = 2
freqtrade = get_patched_freqtradebot(mocker, edge_conf) freqtrade = get_patched_freqtradebot(mocker, edge_conf)
def get_fee(): def get_fee(*args, **kwargs):
return 0.001 return 0.001
freqtrade.exchange.get_fee = get_fee freqtrade.exchange.get_fee = get_fee

View File

@ -1646,10 +1646,10 @@ def test_get_fee(default_conf, mocker, exchange_name):
}) })
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
assert exchange.get_fee() == 0.025 assert exchange.get_fee('ETH/BTC') == 0.025
ccxt_exceptionhandlers(mocker, default_conf, api_mock, exchange_name, ccxt_exceptionhandlers(mocker, default_conf, api_mock, exchange_name,
'get_fee', 'calculate_fee') 'get_fee', 'calculate_fee', symbol="ETH/BTC")
def test_stoploss_limit_order_unsupported_exchange(default_conf, mocker): def test_stoploss_limit_order_unsupported_exchange(default_conf, mocker):