Merge pull request #1473 from gianlup/fix_dburl
Fix custom db_url ignored if provided by conf.json
This commit is contained in:
commit
85bca58905
@ -223,7 +223,7 @@ creating trades.
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"dry_run": true,
|
"dry_run": true,
|
||||||
"db_url": "sqlite///tradesv3.dryrun.sqlite",
|
"db_url": "sqlite:///tradesv3.dryrun.sqlite",
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Remove your Exchange API key (change them by fake api credentials)
|
3. Remove your Exchange API key (change them by fake api credentials)
|
||||||
|
@ -124,9 +124,6 @@ class Configuration(object):
|
|||||||
if self.args.db_url and self.args.db_url != constants.DEFAULT_DB_PROD_URL:
|
if self.args.db_url and self.args.db_url != constants.DEFAULT_DB_PROD_URL:
|
||||||
config.update({'db_url': self.args.db_url})
|
config.update({'db_url': self.args.db_url})
|
||||||
logger.info('Parameter --db-url detected ...')
|
logger.info('Parameter --db-url detected ...')
|
||||||
else:
|
|
||||||
# Set default here
|
|
||||||
config.update({'db_url': constants.DEFAULT_DB_PROD_URL})
|
|
||||||
|
|
||||||
if config.get('dry_run', False):
|
if config.get('dry_run', False):
|
||||||
logger.info('Dry run is enabled')
|
logger.info('Dry run is enabled')
|
||||||
|
@ -59,7 +59,7 @@ class Edge():
|
|||||||
|
|
||||||
# checking max_open_trades. it should be -1 as with Edge
|
# checking max_open_trades. it should be -1 as with Edge
|
||||||
# the number of trades is determined by position size
|
# the number of trades is determined by position size
|
||||||
if self.config['max_open_trades'] != -1:
|
if self.config['max_open_trades'] != float('inf'):
|
||||||
logger.critical('max_open_trades should be -1 in config !')
|
logger.critical('max_open_trades should be -1 in config !')
|
||||||
|
|
||||||
if self.config['stake_amount'] != constants.UNLIMITED_STAKE_AMOUNT:
|
if self.config['stake_amount'] != constants.UNLIMITED_STAKE_AMOUNT:
|
||||||
|
@ -73,7 +73,6 @@ def test_load_config_max_open_trades_minus_one(default_conf, mocker, caplog) ->
|
|||||||
args = Arguments([], '').get_parsed_arg()
|
args = Arguments([], '').get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
print(validated_conf)
|
|
||||||
|
|
||||||
assert validated_conf['max_open_trades'] > 999999999
|
assert validated_conf['max_open_trades'] > 999999999
|
||||||
assert validated_conf['max_open_trades'] == float('inf')
|
assert validated_conf['max_open_trades'] == float('inf')
|
||||||
@ -125,6 +124,43 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
assert validated_conf.get('strategy_path') == '/some/path'
|
assert validated_conf.get('strategy_path') == '/some/path'
|
||||||
assert validated_conf.get('db_url') == 'sqlite:///someurl'
|
assert validated_conf.get('db_url') == 'sqlite:///someurl'
|
||||||
|
|
||||||
|
# Test conf provided db_url prod
|
||||||
|
conf = default_conf.copy()
|
||||||
|
conf["dry_run"] = False
|
||||||
|
conf["db_url"] = "sqlite:///path/to/db.sqlite"
|
||||||
|
mocker.patch('freqtrade.configuration.open', mocker.mock_open(
|
||||||
|
read_data=json.dumps(conf)
|
||||||
|
))
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
'--strategy', 'TestStrategy',
|
||||||
|
'--strategy-path', '/some/path'
|
||||||
|
]
|
||||||
|
args = Arguments(arglist, '').get_parsed_arg()
|
||||||
|
|
||||||
|
configuration = Configuration(args)
|
||||||
|
validated_conf = configuration.load_config()
|
||||||
|
assert validated_conf.get('db_url') == "sqlite:///path/to/db.sqlite"
|
||||||
|
|
||||||
|
# Test conf provided db_url dry_run
|
||||||
|
conf = default_conf.copy()
|
||||||
|
conf["dry_run"] = True
|
||||||
|
conf["db_url"] = "sqlite:///path/to/db.sqlite"
|
||||||
|
mocker.patch('freqtrade.configuration.open', mocker.mock_open(
|
||||||
|
read_data=json.dumps(conf)
|
||||||
|
))
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
'--strategy', 'TestStrategy',
|
||||||
|
'--strategy-path', '/some/path'
|
||||||
|
]
|
||||||
|
args = Arguments(arglist, '').get_parsed_arg()
|
||||||
|
|
||||||
|
configuration = Configuration(args)
|
||||||
|
validated_conf = configuration.load_config()
|
||||||
|
assert validated_conf.get('db_url') == "sqlite:///path/to/db.sqlite"
|
||||||
|
|
||||||
|
# Test args provided db_url prod
|
||||||
conf = default_conf.copy()
|
conf = default_conf.copy()
|
||||||
conf["dry_run"] = False
|
conf["dry_run"] = False
|
||||||
del conf["db_url"]
|
del conf["db_url"]
|
||||||
@ -142,7 +178,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
assert validated_conf.get('db_url') == DEFAULT_DB_PROD_URL
|
assert validated_conf.get('db_url') == DEFAULT_DB_PROD_URL
|
||||||
|
|
||||||
# Test dry=run with ProdURL
|
# Test args provided db_url dry_run
|
||||||
conf = default_conf.copy()
|
conf = default_conf.copy()
|
||||||
conf["dry_run"] = True
|
conf["dry_run"] = True
|
||||||
conf["db_url"] = DEFAULT_DB_PROD_URL
|
conf["db_url"] = DEFAULT_DB_PROD_URL
|
||||||
|
Loading…
Reference in New Issue
Block a user