Add name getting

This commit is contained in:
Matthias 2019-11-09 09:07:46 +01:00
parent 31c7189b8b
commit bf69b055eb
7 changed files with 28 additions and 16 deletions

View File

@ -57,7 +57,7 @@ class IPairList(ABC):
"""
@staticmethod
def verify_blacklist(self, pairlist: List[str], blacklist: List[str]) -> List[str]:
def verify_blacklist(pairlist: List[str], blacklist: List[str]) -> List[str]:
"""
Verify and remove items from pairlist - returning a filtered pairlist.
"""

View File

@ -9,8 +9,8 @@ logger = logging.getLogger(__name__)
class LowPriceFilter(IPairList):
def __init__(self, exchange, config, pairlistconfig: dict) -> None:
super().__init__(exchange, config, pairlistconfig)
def __init__(self, exchange, pairlistmanager, config, pairlistconfig: dict) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig)
self._low_price_percent = pairlistconfig.get('low_price_percent', 0)

View File

@ -33,11 +33,10 @@ class PrecisionFilter(IPairList):
(already cleaned to be 1 - stoploss)
:return: True if the pair can stay, false if it should be removed
"""
stop_price = self._freqtrade.get_target_bid(ticker["symbol"], ticker) * stoploss
stop_price = ticker['ask'] * stoploss
# Adjust stop-prices to precision
sp = self._freqtrade.exchange.symbol_price_prec(ticker["symbol"], stop_price)
stop_gap_price = self._freqtrade.exchange.symbol_price_prec(ticker["symbol"],
stop_price * 0.99)
sp = self._exchange.symbol_price_prec(ticker["symbol"], stop_price)
stop_gap_price = self._exchange.symbol_price_prec(ticker["symbol"], stop_price * 0.99)
logger.debug(f"{ticker['symbol']} - {sp} : {stop_gap_price}")
if sp <= stop_gap_price:
logger.info(f"Removed {ticker['symbol']} from whitelist, "
@ -49,9 +48,9 @@ class PrecisionFilter(IPairList):
"""
Filters and sorts pairlists and assigns and returns them again.
"""
if self._freqtrade.strategy.stoploss is not None:
if self._config.get('stoploss') is not None:
# Precalculate sanitized stoploss value to avoid recalculation for every pair
stoploss = 1 - abs(self._freqtrade.strategy.stoploss)
stoploss = 1 - abs(self._config.get('stoploss'))
# Copy list since we're modifying this list
for p in deepcopy(pairlist):
ticker = [t for t in tickers if t['symbol'] == p][0]

View File

@ -14,8 +14,8 @@ logger = logging.getLogger(__name__)
class StaticPairList(IPairList):
def __init__(self, exchange, config, pairlistconfig: dict) -> None:
super().__init__(exchange, config, pairlistconfig)
def __init__(self, exchange, pairlistmanager, config, pairlistconfig: dict) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig)
@property
def needstickers(self) -> bool:

View File

@ -19,8 +19,8 @@ SORT_VALUES = ['askVolume', 'bidVolume', 'quoteVolume']
class VolumePairList(IPairList):
def __init__(self, exchange, config, pairlistconfig: dict) -> None:
super().__init__(exchange, config, pairlistconfig)
def __init__(self, exchange, pairlistmanager, config, pairlistconfig: dict) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig)
if 'number_assets' not in self._pairlistconfig:
raise OperationalException(

View File

@ -5,7 +5,7 @@ Provides lists as configured in config.json
"""
import logging
from typing import List
from typing import Dict, List
from freqtrade.pairlist.IPairList import IPairList
from freqtrade.resolvers import PairListResolver
@ -44,6 +44,18 @@ class PairListManager():
"""
return self._blacklist
@property
def name(self) -> str:
"""
"""
return str([p.name for p in self._pairlists])
def short_desc(self) -> List[Dict]:
"""
List of short_desc for each pairlist
"""
return [{p.name: p.short_desc()} for p in self._pairlists]
def refresh_pairlist(self) -> None:
"""
Run pairlist through all pairlists.
@ -52,7 +64,7 @@ class PairListManager():
pairlist = self._whitelist.copy()
# tickers should be cached to avoid calling the exchange on each call.
tickers = []
tickers: List[Dict] = []
if self._tickers_needed:
tickers = self._exchange.get_tickers()

View File

@ -20,7 +20,8 @@ class PairListResolver(IResolver):
__slots__ = ['pairlist']
def __init__(self, pairlist_name: str, exchange, pairlistmanager, config: dict, pairlistconfig) -> None:
def __init__(self, pairlist_name: str, exchange, pairlistmanager,
config: dict, pairlistconfig) -> None:
"""
Load the custom class from config parameter
:param config: configuration dictionary or None