mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
adapt scripts/plot_dataframe to use freqtrade db_url
This commit is contained in:
parent
17742df591
commit
01675f50bf
|
@ -29,16 +29,17 @@ import os
|
||||||
import sys
|
import sys
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from typing import Dict, List, Any
|
from typing import Dict, List, Any
|
||||||
from sqlalchemy import create_engine
|
|
||||||
|
import plotly.graph_objs as go
|
||||||
from plotly import tools
|
from plotly import tools
|
||||||
from plotly.offline import plot
|
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
|
import freqtrade.optimize as optimize
|
||||||
|
from freqtrade import exchange
|
||||||
from freqtrade import persistence
|
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
|
from freqtrade.persistence import Trade
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -50,9 +51,10 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
||||||
Calls analyze() and plots the returned dataframe
|
Calls analyze() and plots the returned dataframe
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
global _CONF
|
||||||
|
|
||||||
# Load the configuration
|
# Load the configuration
|
||||||
config = setup_configuration(args)
|
_CONF.update(setup_configuration(args))
|
||||||
|
|
||||||
# Set the pair to audit
|
# Set the pair to audit
|
||||||
pair = args.pair
|
pair = args.pair
|
||||||
|
@ -65,14 +67,13 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
||||||
logger.critical('--pair format must be XXX/YYY')
|
logger.critical('--pair format must be XXX/YYY')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
# Set timerange to use
|
# Set timerange to use
|
||||||
timerange = Arguments.parse_timerange(args.timerange)
|
timerange = Arguments.parse_timerange(args.timerange)
|
||||||
|
|
||||||
# Load the strategy
|
# Load the strategy
|
||||||
try:
|
try:
|
||||||
analyze = Analyze(config)
|
analyze = Analyze(_CONF)
|
||||||
exchange.init(config)
|
exchange.init(_CONF)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.critical(
|
logger.critical(
|
||||||
'Impossible to load the strategy. Please check the file "user_data/strategies/%s.py"',
|
'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,
|
datadir=args.datadir,
|
||||||
pairs=[pair],
|
pairs=[pair],
|
||||||
ticker_interval=tick_interval,
|
ticker_interval=tick_interval,
|
||||||
refresh_pairs=config.get('refresh_pairs', False),
|
refresh_pairs=_CONF.get('refresh_pairs', False),
|
||||||
timerange=timerange
|
timerange=timerange
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,10 +103,9 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
# Get trades already made from the DB
|
# Get trades already made from the DB
|
||||||
trades = []
|
trades: List[Trade] = []
|
||||||
if args.db_url:
|
if args.db_url:
|
||||||
engine = create_engine('sqlite:///' + args.db_url)
|
persistence.init(_CONF)
|
||||||
persistence.init(_CONF, engine)
|
|
||||||
trades = Trade.query.filter(Trade.pair.is_(pair)).all()
|
trades = Trade.query.filter(Trade.pair.is_(pair)).all()
|
||||||
|
|
||||||
dataframes = analyze.tickerdata_to_dataframe(tickers)
|
dataframes = analyze.tickerdata_to_dataframe(tickers)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user