Skip to content

Commit

Permalink
adapt scripts/plot_dataframe to use freqtrade db_url
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarq committed Jun 7, 2018
1 parent 17742df commit 01675f5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions scripts/plot_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
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__)
Expand All @@ -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
Expand All @@ -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"',
Expand All @@ -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
)

Expand All @@ -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)
Expand Down

0 comments on commit 01675f5

Please sign in to comment.