Skip to content

Commit

Permalink
Don't escape ticks where it's not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 25, 2019
1 parent 626b9bb commit 513e848
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions freqtrade/freqtradebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _get_trade_stake_amount(self, pair) -> Optional[float]:
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
open_trades = len(Trade.get_open_trades())
if open_trades >= self.config['max_open_trades']:
logger.warning('Can\'t open a new trade: max number of trades is reached')
logger.warning("Can't open a new trade: max number of trades is reached")
return None
return available_amount / (self.config['max_open_trades'] - open_trades)

Expand Down Expand Up @@ -351,8 +351,8 @@ def execute_buy(self, pair: str, stake_amount: float, price: Optional[float] = N
min_stake_amount = self._get_min_pair_stake_amount(pair_s, buy_limit_requested)
if min_stake_amount is not None and min_stake_amount > stake_amount:
logger.warning(
f'Can\'t open a new trade for {pair_s}: stake amount '
f'is too small ({stake_amount} < {min_stake_amount})'
f"Can't open a new trade for {pair_s}: stake amount "
f"is too small ({stake_amount} < {min_stake_amount})"
)
return False

Expand Down
6 changes: 3 additions & 3 deletions freqtrade/optimize/hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ def save_trials(self) -> None:
Save hyperopt trials to file
"""
if self.trials:
logger.info('Saving %d evaluations to \'%s\'', len(self.trials), self.trials_file)
logger.info("Saving %d evaluations to '%s'", len(self.trials), self.trials_file)
dump(self.trials, self.trials_file)

def read_trials(self) -> List:
"""
Read hyperopt trials file
"""
logger.info('Reading Trials from \'%s\'', self.trials_file)
logger.info("Reading Trials from '%s'", self.trials_file)
trials = load(self.trials_file)
self.trials_file.unlink()
return trials
Expand Down Expand Up @@ -379,7 +379,7 @@ def start(self) -> None:
self.load_previous_results()

cpus = cpu_count()
logger.info(f'Found {cpus} CPU cores. Let\'s make them scream!')
logger.info(f"Found {cpus} CPU cores. Let's make them scream!")
config_jobs = self.config.get('hyperopt_jobs', -1)
logger.info(f'Number of parallel jobs set as: {config_jobs}')

Expand Down
4 changes: 2 additions & 2 deletions freqtrade/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def init(db_url: str, clean_open_orders: bool = False) -> None:
try:
engine = create_engine(db_url, **kwargs)
except NoSuchModuleError:
raise OperationalException(f'Given value for db_url: \'{db_url}\' '
f'is no valid database URL! (See {_SQL_DOCS_URL})')
raise OperationalException(f"Given value for db_url: '{db_url}' "
f"is no valid database URL! (See {_SQL_DOCS_URL})")

session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
Trade.session = session()
Expand Down
4 changes: 2 additions & 2 deletions freqtrade/tests/optimize/test_hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def test_save_trials_saves_trials(mocker, hyperopt, caplog) -> None:
hyperopt.save_trials()

trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle')
assert log_has('Saving 1 evaluations to \'{}\''.format(trials_file), caplog)
assert log_has("Saving 1 evaluations to '{}'".format(trials_file), caplog)
mock_dump.assert_called_once()


Expand All @@ -390,7 +390,7 @@ def test_read_trials_returns_trials_file(mocker, hyperopt, caplog) -> None:
mock_load = mocker.patch('freqtrade.optimize.hyperopt.load', return_value=trials)
hyperopt_trial = hyperopt.read_trials()
trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle')
assert log_has('Reading Trials from \'{}\''.format(trials_file), caplog)
assert log_has("Reading Trials from '{}'".format(trials_file), caplog)
assert hyperopt_trial == trials
mock_load.assert_called_once()

Expand Down
10 changes: 5 additions & 5 deletions freqtrade/tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_load_config_invalid_pair(default_conf) -> None:
def test_load_config_missing_attributes(default_conf) -> None:
default_conf.pop('exchange')

with pytest.raises(ValidationError, match=r'.*\'exchange\' is a required property.*'):
with pytest.raises(ValidationError, match=r".*'exchange' is a required property.*"):
validate_config_schema(default_conf)


def test_load_config_incorrect_stake_amount(default_conf) -> None:
default_conf['stake_amount'] = 'fake'

with pytest.raises(ValidationError, match=r'.*\'fake\' does not match \'unlimited\'.*'):
with pytest.raises(ValidationError, match=r".*'fake' does not match 'unlimited'.*"):
validate_config_schema(default_conf)


Expand Down Expand Up @@ -472,7 +472,7 @@ def test_hyperopt_with_arguments(mocker, default_conf, caplog) -> None:

assert 'spaces' in config
assert config['spaces'] == ['all']
assert log_has('Parameter -s/--spaces detected: [\'all\']', caplog)
assert log_has("Parameter -s/--spaces detected: ['all']", caplog)
assert "runmode" in config
assert config['runmode'] == RunMode.HYPEROPT

Expand Down Expand Up @@ -722,7 +722,7 @@ def test_load_config_default_exchange(all_conf) -> None:
assert 'exchange' not in all_conf

with pytest.raises(ValidationError,
match=r'\'exchange\' is a required property'):
match=r"'exchange' is a required property"):
validate_config_schema(all_conf)


Expand All @@ -736,7 +736,7 @@ def test_load_config_default_exchange_name(all_conf) -> None:
assert 'name' not in all_conf['exchange']

with pytest.raises(ValidationError,
match=r'\'name\' is a required property'):
match=r"'name' is a required property"):
validate_config_schema(all_conf)


Expand Down

0 comments on commit 513e848

Please sign in to comment.