define constants.DEFAULT_DB_DRYRUN_URL and fix StaticPool conditions
This commit is contained in:
parent
c3d0980763
commit
5b1ff6675f
@ -108,7 +108,7 @@ class Arguments(object):
|
|||||||
help='Override trades database URL, this is useful if dry_run is enabled'
|
help='Override trades database URL, this is useful if dry_run is enabled'
|
||||||
' or in custom deployments (default: %(default)s)',
|
' or in custom deployments (default: %(default)s)',
|
||||||
dest='db_url',
|
dest='db_url',
|
||||||
default=constants.DEFAULT_DB_URL,
|
default=constants.DEFAULT_DB_PROD_URL,
|
||||||
type=str,
|
type=str,
|
||||||
metavar='PATH',
|
metavar='PATH',
|
||||||
)
|
)
|
||||||
|
@ -103,12 +103,12 @@ class Configuration(object):
|
|||||||
|
|
||||||
if config.get('dry_run', False):
|
if config.get('dry_run', False):
|
||||||
logger.info('Dry run is enabled')
|
logger.info('Dry run is enabled')
|
||||||
if config.get('db_url') in [None, constants.DEFAULT_DB_URL]:
|
if config.get('db_url') in [None, constants.DEFAULT_DB_PROD_URL]:
|
||||||
# Default to in-memory db for dry_run if not specified
|
# Default to in-memory db for dry_run if not specified
|
||||||
config['db_url'] = 'sqlite://'
|
config['db_url'] = constants.DEFAULT_DB_DRYRUN_URL
|
||||||
else:
|
else:
|
||||||
if not config.get('db_url', None):
|
if not config.get('db_url', None):
|
||||||
config['db_url'] = constants.DEFAULT_DB_URL
|
config['db_url'] = constants.DEFAULT_DB_PROD_URL
|
||||||
logger.info('Dry run is disabled')
|
logger.info('Dry run is disabled')
|
||||||
|
|
||||||
logger.info('Using DB: "{}"'.format(config['db_url']))
|
logger.info('Using DB: "{}"'.format(config['db_url']))
|
||||||
|
@ -9,7 +9,8 @@ TICKER_INTERVAL = 5 # min
|
|||||||
HYPEROPT_EPOCH = 100 # epochs
|
HYPEROPT_EPOCH = 100 # epochs
|
||||||
RETRY_TIMEOUT = 30 # sec
|
RETRY_TIMEOUT = 30 # sec
|
||||||
DEFAULT_STRATEGY = 'DefaultStrategy'
|
DEFAULT_STRATEGY = 'DefaultStrategy'
|
||||||
DEFAULT_DB_URL = 'sqlite:///tradesv3.sqlite'
|
DEFAULT_DB_PROD_URL = 'sqlite:///tradesv3.sqlite'
|
||||||
|
DEFAULT_DB_DRYRUN_URL = 'sqlite://'
|
||||||
|
|
||||||
TICKER_INTERVAL_MINUTES = {
|
TICKER_INTERVAL_MINUTES = {
|
||||||
'1m': 1,
|
'1m': 1,
|
||||||
|
@ -16,6 +16,8 @@ from sqlalchemy.orm.scoping import scoped_session
|
|||||||
from sqlalchemy.orm.session import sessionmaker
|
from sqlalchemy.orm.session import sessionmaker
|
||||||
from sqlalchemy.pool import StaticPool
|
from sqlalchemy.pool import StaticPool
|
||||||
|
|
||||||
|
from freqtrade import constants
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
_CONF = {}
|
_CONF = {}
|
||||||
@ -35,10 +37,8 @@ def init(config: Dict) -> None:
|
|||||||
db_url = _CONF.get('db_url', None)
|
db_url = _CONF.get('db_url', None)
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
||||||
if not db_url and _CONF.get('dry_run', False):
|
if db_url == constants.DEFAULT_DB_DRYRUN_URL:
|
||||||
# Default to in-memory db if not specified
|
# Take care of thread ownership if in-memory db
|
||||||
# and take care of thread ownership if in-memory db
|
|
||||||
db_url = 'sqlite://'
|
|
||||||
kwargs.update({
|
kwargs.update({
|
||||||
'connect_args': {'check_same_thread': False},
|
'connect_args': {'check_same_thread': False},
|
||||||
'poolclass': StaticPool,
|
'poolclass': StaticPool,
|
||||||
@ -53,7 +53,7 @@ def init(config: Dict) -> None:
|
|||||||
check_migrate(engine)
|
check_migrate(engine)
|
||||||
|
|
||||||
# Clean dry_run DB
|
# Clean dry_run DB
|
||||||
if _CONF.get('dry_run', False) and db_url != 'sqlite://':
|
if _CONF.get('dry_run', False) and db_url != constants.DEFAULT_DB_DRYRUN_URL:
|
||||||
clean_dry_run_db()
|
clean_dry_run_db()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user