From 01675f50bff286a17d4d0dd67153c47ea634a8d0 Mon Sep 17 00:00:00 2001 From: gcarq Date: Thu, 7 Jun 2018 18:06:27 +0200 Subject: [PATCH] adapt scripts/plot_dataframe to use freqtrade db_url --- scripts/plot_dataframe.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index e7737a5c7..122c002a8 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -29,16 +29,17 @@ import os import sys from argparse import Namespace from typing import Dict, List, Any -from sqlalchemy import create_engine + +import plotly.graph_objs as go from plotly import tools from plotly.offline import plot -import plotly.graph_objs as go -from freqtrade.arguments import Arguments -from freqtrade.analyze import Analyze -from freqtrade.optimize.backtesting import setup_configuration -from freqtrade import exchange + import freqtrade.optimize as optimize +from freqtrade import exchange from freqtrade import persistence +from freqtrade.analyze import Analyze +from freqtrade.arguments import Arguments +from freqtrade.optimize.backtesting import setup_configuration from freqtrade.persistence import Trade logger = logging.getLogger(__name__) @@ -50,9 +51,10 @@ def plot_analyzed_dataframe(args: Namespace) -> None: Calls analyze() and plots the returned dataframe :return: None """ + global _CONF # Load the configuration - config = setup_configuration(args) + _CONF.update(setup_configuration(args)) # Set the pair to audit pair = args.pair @@ -65,14 +67,13 @@ def plot_analyzed_dataframe(args: Namespace) -> None: logger.critical('--pair format must be XXX/YYY') exit() - # Set timerange to use timerange = Arguments.parse_timerange(args.timerange) # Load the strategy try: - analyze = Analyze(config) - exchange.init(config) + analyze = Analyze(_CONF) + exchange.init(_CONF) except AttributeError: logger.critical( 'Impossible to load the strategy. Please check the file "user_data/strategies/%s.py"', @@ -93,7 +94,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None: datadir=args.datadir, pairs=[pair], ticker_interval=tick_interval, - refresh_pairs=config.get('refresh_pairs', False), + refresh_pairs=_CONF.get('refresh_pairs', False), timerange=timerange ) @@ -102,10 +103,9 @@ def plot_analyzed_dataframe(args: Namespace) -> None: exit() # Get trades already made from the DB - trades = [] + trades: List[Trade] = [] if args.db_url: - engine = create_engine('sqlite:///' + args.db_url) - persistence.init(_CONF, engine) + persistence.init(_CONF) trades = Trade.query.filter(Trade.pair.is_(pair)).all() dataframes = analyze.tickerdata_to_dataframe(tickers)