Make Pylint Happy chapter 1

This commit is contained in:
Gerald Lonlas
2018-03-02 23:22:00 +08:00
parent d274f13480
commit 390501bac0
13 changed files with 161 additions and 147 deletions

View File

@@ -97,10 +97,11 @@ def download_pairs(datadir, pairs: List[str], ticker_interval: int) -> bool:
try:
download_backtesting_testdata(datadir, pair=pair, interval=ticker_interval)
except BaseException:
logger.info('Failed to download the pair: "{pair}", Interval: {interval} min'.format(
pair=pair,
interval=ticker_interval,
))
logger.info(
'Failed to download the pair: "%s", Interval: %s min',
pair,
ticker_interval
)
return False
return True
@@ -115,10 +116,11 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
"""
path = make_testdata_path(datadir)
logger.info('Download the pair: "{pair}", Interval: {interval} min'.format(
pair=pair,
interval=interval,
))
logger.info(
'Download the pair: "%s", Interval: %s min',
pair,
interval
)
filepair = pair.replace("-", "_")
filename = os.path.join(path, '{pair}-{interval}.json'.format(
@@ -129,8 +131,8 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
if os.path.isfile(filename):
with open(filename, "rt") as file:
data = json.load(file)
logger.debug("Current Start: {}".format(data[1]['T']))
logger.debug("Current End: {}".format(data[-1:][0]['T']))
logger.debug("Current Start: %s", data[1]['T'])
logger.debug("Current End: %s", data[-1:][0]['T'])
else:
data = []
logger.debug("Current Start: None")
@@ -140,8 +142,8 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
for row in new_data:
if row not in data:
data.append(row)
logger.debug("New Start: {}".format(data[1]['T']))
logger.debug("New End: {}".format(data[-1:][0]['T']))
logger.debug("New Start: %s", data[1]['T'])
logger.debug("New End: %s", data[-1:][0]['T'])
data = sorted(data, key=lambda data: data['T'])
misc.file_dump_json(filename, data)

View File

@@ -25,7 +25,7 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
from freqtrade.configuration import Configuration
from freqtrade.optimize import load_data
from freqtrade.arguments import Arguments
from freqtrade.optimize.backtesting import Backtesting, setup_configuration
from freqtrade.optimize.backtesting import Backtesting
from freqtrade.logger import Logger
from user_data.hyperopt_conf import hyperopt_optimize_conf
@@ -46,7 +46,6 @@ class Hyperopt(Backtesting):
self.logging = Logger(name=__name__, level=config['loglevel'])
self.logger = self.logging.get_logger()
# set TARGET_TRADES to suit your number concurrent trades so its realistic
# to the number of days
self.target_trades = 600
@@ -353,6 +352,9 @@ class Hyperopt(Backtesting):
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
"""
Buy strategy Hyperopt will build and use
"""
conditions = []
# GUARDS AND TRENDS
if 'uptrend_long_ema' in params and params['uptrend_long_ema']['enabled']:
@@ -513,8 +515,9 @@ class Hyperopt(Backtesting):
self.current_tries = len(self.trials.results)
self.total_tries += self.current_tries
self.logger.info(
'Continuing with trials. Current: {}, Total: {}'
.format(self.current_tries, self.total_tries)
'Continuing with trials. Current: %d, Total: %d',
self.current_tries,
self.total_tries
)
try:
@@ -557,7 +560,10 @@ class Hyperopt(Backtesting):
"""
Hyperopt SIGINT handler
"""
self.logger.info('Hyperopt received {}'.format(signal.Signals(sig).name))
self.logger.info(
'Hyperopt received %s',
signal.Signals(sig).name
)
self.save_trials()
self.log_trials_result()
@@ -580,9 +586,7 @@ def start(args) -> None:
logger.info('Starting freqtrade in Hyperopt mode')
# Initialize configuration
#config = setup_configuration(args)
# Monkey patch of the configuration with hyperopt_conf.py
# Monkey patch the configuration with hyperopt_conf.py
configuration = Configuration(args)
optimize_config = hyperopt_optimize_conf()
config = configuration._load_backtesting_config(optimize_config)