mergefix
This commit is contained in:
commit
f57f963c35
@ -128,9 +128,9 @@ def load_pair_history(pair: str,
|
|||||||
drop_incomplete=drop_incomplete)
|
drop_incomplete=drop_incomplete)
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f'No history data for pair: "{pair}", interval: {ticker_interval}. '
|
f'No history data for pair: "{pair}", interval: {ticker_interval}, in {datadir}. '
|
||||||
'Use --refresh-pairs-cached option or `freqtrade download-data` '
|
'Provide the correct path to datadir in config.json, or download data with '
|
||||||
'script to download the data'
|
'--refresh-pairs-cached option or `freqtrade download-data`. '
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ def start_plot_dataframe(args: Namespace) -> None:
|
|||||||
Entrypoint for dataframe plotting
|
Entrypoint for dataframe plotting
|
||||||
"""
|
"""
|
||||||
# Import here to avoid errors if plot-dependencies are not installed.
|
# Import here to avoid errors if plot-dependencies are not installed.
|
||||||
from freqtrade.plot.plotting import analyse_and_plot_pairs
|
from freqtrade.plot.plotting import load_and_plot_trades
|
||||||
config = setup_utils_configuration(args, RunMode.PLOT)
|
config = setup_utils_configuration(args, RunMode.PLOT)
|
||||||
|
|
||||||
analyse_and_plot_pairs(config)
|
load_and_plot_trades(config)
|
||||||
|
|
||||||
|
|
||||||
def start_plot_profit(args: Namespace) -> None:
|
def start_plot_profit(args: Namespace) -> None:
|
||||||
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from freqtrade import OperationalException
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.btanalysis import (combine_tickers_with_mean,
|
from freqtrade.data.btanalysis import (combine_tickers_with_mean,
|
||||||
@ -33,9 +33,13 @@ def init_plotscript(config):
|
|||||||
pairs = config["pairs"]
|
pairs = config["pairs"]
|
||||||
else:
|
else:
|
||||||
pairs = config["exchange"]["pair_whitelist"]
|
pairs = config["exchange"]["pair_whitelist"]
|
||||||
|
if pairs is None:
|
||||||
|
raise OperationalException('No pairs available in config.')
|
||||||
|
|
||||||
# Set timerange to use
|
# Set timerange to use
|
||||||
timerange = TimeRange.parse_timerange(config.get("timerange"))
|
timerange = TimeRange.parse_timerange(config.get("timerange"))
|
||||||
|
if timerange is None:
|
||||||
|
raise OperationalException('Could not parse timerange in config.')
|
||||||
|
|
||||||
tickers = history.load_data(
|
tickers = history.load_data(
|
||||||
datadir=Path(str(config.get("datadir"))),
|
datadir=Path(str(config.get("datadir"))),
|
||||||
@ -43,11 +47,15 @@ def init_plotscript(config):
|
|||||||
ticker_interval=config.get('ticker_interval', '5m'),
|
ticker_interval=config.get('ticker_interval', '5m'),
|
||||||
timerange=timerange,
|
timerange=timerange,
|
||||||
)
|
)
|
||||||
|
if tickers is None:
|
||||||
|
raise OperationalException('No ticker data available as specified in config.')
|
||||||
|
|
||||||
trades = load_trades(config['trade_source'],
|
trades = load_trades(config['trade_source'],
|
||||||
db_url=config.get('db_url'),
|
db_url=config.get('db_url'),
|
||||||
exportfilename=config.get('exportfilename'),
|
exportfilename=config.get('exportfilename'),
|
||||||
)
|
)
|
||||||
|
if trades is None:
|
||||||
|
raise OperationalException('No trades available as specified in config.')
|
||||||
|
|
||||||
return {"tickers": tickers,
|
return {"tickers": tickers,
|
||||||
"trades": trades,
|
"trades": trades,
|
||||||
@ -324,7 +332,7 @@ def store_plot_file(fig, filename: str, directory: Path, auto_open: bool = False
|
|||||||
logger.info(f"Stored plot as {_filename}")
|
logger.info(f"Stored plot as {_filename}")
|
||||||
|
|
||||||
|
|
||||||
def analyse_and_plot_pairs(config: Dict[str, Any]):
|
def load_and_plot_trades(config: Dict[str, Any]):
|
||||||
"""
|
"""
|
||||||
From configuration provided
|
From configuration provided
|
||||||
- Initializes plot-script
|
- Initializes plot-script
|
||||||
@ -339,7 +347,7 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
|
|||||||
|
|
||||||
plot_elements = init_plotscript(config)
|
plot_elements = init_plotscript(config)
|
||||||
trades = plot_elements['trades']
|
trades = plot_elements['trades']
|
||||||
|
|
||||||
pair_counter = 0
|
pair_counter = 0
|
||||||
for pair, data in plot_elements["tickers"].items():
|
for pair, data in plot_elements["tickers"].items():
|
||||||
pair_counter += 1
|
pair_counter += 1
|
||||||
|
@ -24,8 +24,6 @@ class StrategyResolver(IResolver):
|
|||||||
This class contains all the logic to load custom strategy class
|
This class contains all the logic to load custom strategy class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ['strategy']
|
|
||||||
|
|
||||||
def __init__(self, config: Optional[Dict] = None) -> None:
|
def __init__(self, config: Optional[Dict] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Load the custom class from config parameter
|
Load the custom class from config parameter
|
||||||
|
@ -30,7 +30,7 @@ def find_trace_in_fig_data(data, search_string: str):
|
|||||||
return next(matches)
|
return next(matches)
|
||||||
|
|
||||||
|
|
||||||
def generage_empty_figure():
|
def generate_empty_figure():
|
||||||
return make_subplots(
|
return make_subplots(
|
||||||
rows=3,
|
rows=3,
|
||||||
cols=1,
|
cols=1,
|
||||||
@ -71,7 +71,7 @@ def test_add_indicators(default_conf, caplog):
|
|||||||
# Generate buy/sell signals and indicators
|
# Generate buy/sell signals and indicators
|
||||||
strat = DefaultStrategy(default_conf)
|
strat = DefaultStrategy(default_conf)
|
||||||
data = strat.analyze_ticker(data, {'pair': pair})
|
data = strat.analyze_ticker(data, {'pair': pair})
|
||||||
fig = generage_empty_figure()
|
fig = generate_empty_figure()
|
||||||
|
|
||||||
# Row 1
|
# Row 1
|
||||||
fig1 = add_indicators(fig=deepcopy(fig), row=1, indicators=indicators1, data=data)
|
fig1 = add_indicators(fig=deepcopy(fig), row=1, indicators=indicators1, data=data)
|
||||||
@ -93,7 +93,7 @@ def test_add_indicators(default_conf, caplog):
|
|||||||
|
|
||||||
|
|
||||||
def test_plot_trades(caplog):
|
def test_plot_trades(caplog):
|
||||||
fig1 = generage_empty_figure()
|
fig1 = generate_empty_figure()
|
||||||
# nothing happens when no trades are available
|
# nothing happens when no trades are available
|
||||||
fig = plot_trades(fig1, None)
|
fig = plot_trades(fig1, None)
|
||||||
assert fig == fig1
|
assert fig == fig1
|
||||||
@ -209,7 +209,7 @@ def test_generate_Plot_filename():
|
|||||||
|
|
||||||
|
|
||||||
def test_generate_plot_file(mocker, caplog):
|
def test_generate_plot_file(mocker, caplog):
|
||||||
fig = generage_empty_figure()
|
fig = generate_empty_figure()
|
||||||
plot_mock = mocker.patch("freqtrade.plot.plotting.plot", MagicMock())
|
plot_mock = mocker.patch("freqtrade.plot.plotting.plot", MagicMock())
|
||||||
store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html",
|
store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html",
|
||||||
directory=Path("user_data/plots"))
|
directory=Path("user_data/plots"))
|
||||||
@ -229,7 +229,7 @@ def test_add_profit():
|
|||||||
|
|
||||||
df = history.load_pair_history(pair="POWR/BTC", ticker_interval='5m',
|
df = history.load_pair_history(pair="POWR/BTC", ticker_interval='5m',
|
||||||
datadir=None, timerange=timerange)
|
datadir=None, timerange=timerange)
|
||||||
fig = generage_empty_figure()
|
fig = generate_empty_figure()
|
||||||
|
|
||||||
cum_profits = create_cum_profit(df.set_index('date'),
|
cum_profits = create_cum_profit(df.set_index('date'),
|
||||||
bt_data[bt_data["pair"] == 'POWR/BTC'],
|
bt_data[bt_data["pair"] == 'POWR/BTC'],
|
||||||
|
Loading…
Reference in New Issue
Block a user