Remove .get calls for dry_run - it's a mandatory property
This commit is contained in:
parent
2f82122fc4
commit
1bf475fa1a
@ -63,8 +63,7 @@ class FreqtradeBot:
|
|||||||
|
|
||||||
self.exchange = ExchangeResolver.load_exchange(self.config['exchange']['name'], self.config)
|
self.exchange = ExchangeResolver.load_exchange(self.config['exchange']['name'], self.config)
|
||||||
|
|
||||||
persistence.init(self.config.get('db_url', None),
|
persistence.init(self.config.get('db_url', None), clean_open_orders=self.config['dry_run'])
|
||||||
clean_open_orders=self.config.get('dry_run', False))
|
|
||||||
|
|
||||||
self.wallets = Wallets(self.config, self.exchange)
|
self.wallets = Wallets(self.config, self.exchange)
|
||||||
|
|
||||||
@ -930,7 +929,7 @@ class FreqtradeBot:
|
|||||||
|
|
||||||
# if stoploss is on exchange and we are on dry_run mode,
|
# if stoploss is on exchange and we are on dry_run mode,
|
||||||
# we consider the sell price stop price
|
# we consider the sell price stop price
|
||||||
if self.config.get('dry_run', False) and sell_type == 'stoploss' \
|
if self.config['dry_run'] and sell_type == 'stoploss' \
|
||||||
and self.strategy.order_types['stoploss_on_exchange']:
|
and self.strategy.order_types['stoploss_on_exchange']:
|
||||||
limit = trade.stop_loss
|
limit = trade.stop_loss
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class RPC:
|
|||||||
"""
|
"""
|
||||||
config = self._freqtrade.config
|
config = self._freqtrade.config
|
||||||
val = {
|
val = {
|
||||||
'dry_run': config.get('dry_run', False),
|
'dry_run': config['dry_run'],
|
||||||
'stake_currency': config['stake_currency'],
|
'stake_currency': config['stake_currency'],
|
||||||
'stake_amount': config['stake_amount'],
|
'stake_amount': config['stake_amount'],
|
||||||
'minimal_roi': config['minimal_roi'].copy(),
|
'minimal_roi': config['minimal_roi'].copy(),
|
||||||
@ -337,7 +337,7 @@ class RPC:
|
|||||||
'stake': stake_currency,
|
'stake': stake_currency,
|
||||||
})
|
})
|
||||||
if total == 0.0:
|
if total == 0.0:
|
||||||
if self._freqtrade.config.get('dry_run', False):
|
if self._freqtrade.config['dry_run']:
|
||||||
raise RPCException('Running in Dry Run, balances are not available.')
|
raise RPCException('Running in Dry Run, balances are not available.')
|
||||||
else:
|
else:
|
||||||
raise RPCException('All balances are zero.')
|
raise RPCException('All balances are zero.')
|
||||||
@ -351,7 +351,7 @@ class RPC:
|
|||||||
'symbol': symbol,
|
'symbol': symbol,
|
||||||
'value': value,
|
'value': value,
|
||||||
'stake': stake_currency,
|
'stake': stake_currency,
|
||||||
'note': 'Simulated balances' if self._freqtrade.config.get('dry_run', False) else ''
|
'note': 'Simulated balances' if self._freqtrade.config['dry_run'] else ''
|
||||||
}
|
}
|
||||||
|
|
||||||
def _rpc_start(self) -> Dict[str, str]:
|
def _rpc_start(self) -> Dict[str, str]:
|
||||||
|
@ -62,7 +62,7 @@ class RPCManager:
|
|||||||
logger.error(f"Message type {msg['type']} not implemented by handler {mod.name}.")
|
logger.error(f"Message type {msg['type']} not implemented by handler {mod.name}.")
|
||||||
|
|
||||||
def startup_messages(self, config, pairlist) -> None:
|
def startup_messages(self, config, pairlist) -> None:
|
||||||
if config.get('dry_run', False):
|
if config['dry_run']:
|
||||||
self.send_msg({
|
self.send_msg({
|
||||||
'type': RPCMessageType.WARNING_NOTIFICATION,
|
'type': RPCMessageType.WARNING_NOTIFICATION,
|
||||||
'status': 'Dry run is enabled. All trades are simulated.'
|
'status': 'Dry run is enabled. All trades are simulated.'
|
||||||
|
@ -323,7 +323,7 @@ def test_load_dry_run(default_conf, mocker, config_value, expected, arglist) ->
|
|||||||
configuration = Configuration(Arguments(arglist).get_parsed_arg())
|
configuration = Configuration(Arguments(arglist).get_parsed_arg())
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
assert validated_conf.get('dry_run') is expected
|
assert validated_conf['dry_run'] is expected
|
||||||
|
|
||||||
|
|
||||||
def test_load_custom_strategy(default_conf, mocker) -> None:
|
def test_load_custom_strategy(default_conf, mocker) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user