Change persistence.init parameter

It should describe what it does
This commit is contained in:
Matthias 2019-05-30 06:31:34 +02:00
parent d6cf314481
commit b6e8fecbf5
3 changed files with 8 additions and 5 deletions

View File

@ -73,7 +73,8 @@ class FreqtradeBot(object):
self.active_pair_whitelist: List[str] = self.config['exchange']['pair_whitelist']
persistence.init(self.config.get('db_url', None), self.config.get('dry_run'))
persistence.init(self.config.get('db_url', None),
clean_open_orders=self.config.get('dry_run', False))
# Set initial bot state from config
initial_state = self.config.get('initial_state')

View File

@ -25,12 +25,14 @@ _DECL_BASE: Any = declarative_base()
_SQL_DOCS_URL = 'http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls'
def init(db_url: str, dry_run: bool = False) -> None:
def init(db_url: str, clean_open_orders: bool = False) -> None:
"""
Initializes this module with the given config,
registers all known command handlers
and starts polling for message updates
:param config: config to use
:param db_url: Database to use
:param clean_open_orders: Remove open orders from the database.
Useful for dry-run or if all orders have been reset on the exchange.
:return: None
"""
kwargs = {}
@ -56,7 +58,7 @@ def init(db_url: str, dry_run: bool = False) -> None:
check_migrate(engine)
# Clean dry_run DB if the db is not in-memory
if dry_run and db_url != 'sqlite://':
if clean_open_orders and db_url != 'sqlite://':
clean_dry_run_db()

View File

@ -55,7 +55,7 @@ timeZone = pytz.UTC
def load_trades(args: Namespace, pair: str, timerange: TimeRange) -> pd.DataFrame:
trades: pd.DataFrame = pd.DataFrame()
if args.db_url:
persistence.init(args.db_url, True)
persistence.init(args.db_url, False)
columns = ["pair", "profit", "open_time", "close_time",
"open_rate", "close_rate", "duration"]