From bc6a10353bf4c704003a319fd953026896c33533 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Sat, 4 Jan 2020 05:07:51 +0300 Subject: [PATCH] Introduce pair_to_filename() --- freqtrade/misc.py | 6 ++++++ freqtrade/plot/plotting.py | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/freqtrade/misc.py b/freqtrade/misc.py index ed37ace3a..e6ebc8d65 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -92,6 +92,12 @@ def file_load_json(file): return pairdata +def pair_to_filename(pair: str) -> str: + for ch in ['/', ' ', '.']: + pair = pair.replace(ch, '_') + return pair + + def format_ms_time(date: int) -> str: """ convert MS date to readable format. diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index 6b2d426e7..7c9c9f985 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -3,12 +3,14 @@ from pathlib import Path from typing import Any, Dict, List import pandas as pd + from freqtrade.configuration import TimeRange -from freqtrade.data import history -from freqtrade.data.converter import trim_dataframe from freqtrade.data.btanalysis import (combine_tickers_with_mean, create_cum_profit, extract_trades_of_period, load_trades) +from freqtrade.data.converter import trim_dataframe +from freqtrade.data.history import load_data +from freqtrade.misc import pair_to_filename from freqtrade.resolvers import StrategyResolver logger = logging.getLogger(__name__) @@ -37,7 +39,7 @@ def init_plotscript(config): # Set timerange to use timerange = TimeRange.parse_timerange(config.get("timerange")) - tickers = history.load_data( + tickers = load_data( datadir=config.get("datadir"), pairs=pairs, timeframe=config.get('ticker_interval', '5m'), @@ -306,8 +308,8 @@ def generate_plot_filename(pair, timeframe) -> str: """ Generate filenames per pair/timeframe to be used for storing plots """ - pair_name = pair.replace("/", "_") - file_name = 'freqtrade-plot-' + pair_name + '-' + timeframe + '.html' + pair_s = pair_to_filename(pair) + file_name = 'freqtrade-plot-' + pair_s + '-' + timeframe + '.html' logger.info('Generate plot file for %s', pair)