Satisfy linter.

This commit is contained in:
Leif Segen 2020-11-28 01:34:18 -06:00
parent 1f7d681ddb
commit 966c6b308f
2 changed files with 30 additions and 27 deletions

View File

@ -12,6 +12,7 @@ from freqtrade.persistence import Trade
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class PerformanceFilter(IPairList): class PerformanceFilter(IPairList):
def __init__(self, exchange, pairlistmanager, def __init__(self, exchange, pairlistmanager,
@ -19,7 +20,6 @@ class PerformanceFilter(IPairList):
pairlist_pos: int) -> None: pairlist_pos: int) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
@property @property
def needstickers(self) -> bool: def needstickers(self) -> bool:
""" """
@ -46,7 +46,7 @@ class PerformanceFilter(IPairList):
# Get the trading performance for pairs from database # Get the trading performance for pairs from database
perf = pd.DataFrame(Trade.get_overall_performance()) perf = pd.DataFrame(Trade.get_overall_performance())
# get pairlist from performance dataframe values # get pairlist from performance dataframe values
list_df = pd.DataFrame({'pair':pairlist}) list_df = pd.DataFrame({'pair': pairlist})
# set initial value for pairs with no trades to 0 # set initial value for pairs with no trades to 0
# and sort the list using performance and count # and sort the list using performance and count
sorted_df = list_df.join(perf.set_index('pair'), on='pair')\ sorted_df = list_df.join(perf.set_index('pair'), on='pair')\

View File

@ -729,27 +729,32 @@ def test_pairlistmanager_no_pairlist(mocker, whitelist_conf):
@pytest.mark.parametrize("pairlists,pair_allowlist,overall_performance,allowlist_result", [ @pytest.mark.parametrize("pairlists,pair_allowlist,overall_performance,allowlist_result", [
# Happy path, descending order, all values filled # Happy path, descending order, all values filled
([{"method": "StaticPairList"},{"method": "PerformanceFilter"}], ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}],
['ETH/BTC','TKN/BTC'], ['ETH/BTC', 'TKN/BTC'],
[{'pair':'TKN/BTC','profit':5,'count':3}, {'pair':'ETH/BTC','profit':4,'count':2}], [{'pair': 'TKN/BTC', 'profit': 5, 'count': 3}, {'pair': 'ETH/BTC', 'profit': 4, 'count': 2}],
['TKN/BTC','ETH/BTC']), ['TKN/BTC', 'ETH/BTC']),
# Performance data outside allow list ignored # Performance data outside allow list ignored
([{"method": "StaticPairList"},{"method": "PerformanceFilter"}], ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}],
['ETH/BTC','TKN/BTC'], ['ETH/BTC', 'TKN/BTC'],
[{'pair':'OTHER/BTC','profit':5,'count':3}, {'pair':'ETH/BTC','profit':4,'count':2}], [{'pair': 'OTHER/BTC', 'profit': 5, 'count': 3},
['ETH/BTC','TKN/BTC']), {'pair': 'ETH/BTC', 'profit': 4, 'count': 2}],
['ETH/BTC', 'TKN/BTC']),
# Partial performance data missing and sorted between positive and negative profit # Partial performance data missing and sorted between positive and negative profit
([{"method": "StaticPairList"},{"method": "PerformanceFilter"}], ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}],
['ETH/BTC','TKN/BTC','LTC/BTC'], ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'],
[{'pair':'ETH/BTC','profit':-5,'count':100}, {'pair':'TKN/BTC','profit':4,'count':2}], [{'pair': 'ETH/BTC', 'profit': -5, 'count': 100},
['TKN/BTC','LTC/BTC','ETH/BTC']), {'pair': 'TKN/BTC', 'profit': 4, 'count': 2}],
['TKN/BTC', 'LTC/BTC', 'ETH/BTC']),
# Tie in performance data broken by count # Tie in performance data broken by count
([{"method": "StaticPairList"},{"method": "PerformanceFilter"}], ([{"method": "StaticPairList"}, {"method": "PerformanceFilter"}],
['ETH/BTC','TKN/BTC','LTC/BTC'], ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'],
[{'pair':'LTC/BTC','profit':-5,'count':101}, {'pair':'TKN/BTC','profit':-5,'count':2}, {'pair':'ETH/BTC','profit':-5,'count':100}, ], [{'pair': 'LTC/BTC', 'profit': -5, 'count': 101},
['LTC/BTC','ETH/BTC','TKN/BTC']), {'pair': 'TKN/BTC', 'profit': -5, 'count': 2},
{'pair': 'ETH/BTC', 'profit': -5, 'count': 100}],
['LTC/BTC', 'ETH/BTC', 'TKN/BTC']),
]) ])
def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, overall_performance, allowlist_result, tickers, markets, ohlcv_history_list): def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, overall_performance,
allowlist_result, tickers, markets, ohlcv_history_list):
allowlist_conf = whitelist_conf allowlist_conf = whitelist_conf
allowlist_conf['pairlists'] = pairlists allowlist_conf['pairlists'] = pairlists
allowlist_conf['exchange']['pair_whitelist'] = pair_allowlist allowlist_conf['exchange']['pair_whitelist'] = pair_allowlist
@ -761,11 +766,9 @@ def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, o
get_tickers=tickers, get_tickers=tickers,
markets=PropertyMock(return_value=markets) markets=PropertyMock(return_value=markets)
) )
mocker.patch.multiple( mocker.patch.multiple('freqtrade.exchange.Exchange',
'freqtrade.exchange.Exchange',
get_historic_ohlcv=MagicMock(return_value=ohlcv_history_list), get_historic_ohlcv=MagicMock(return_value=ohlcv_history_list),
) )
mocker.patch.multiple('freqtrade.persistence.Trade', mocker.patch.multiple('freqtrade.persistence.Trade',
get_overall_performance=MagicMock(return_value=overall_performance), get_overall_performance=MagicMock(return_value=overall_performance),
) )