Update based on comments
This commit is contained in:
parent
57ff3ff450
commit
8c33e07dc6
@ -68,7 +68,7 @@ optional arguments:
|
||||
-i TICKER_INTERVAL, --ticker-interval TICKER_INTERVAL
|
||||
Specify ticker interval (`1m`, `5m`, `30m`, `1h`,
|
||||
`1d`).
|
||||
--skip-trades Skip using trades file from backtesting and DB.
|
||||
--no-trades Skip using trades from backtesting file and DB.
|
||||
|
||||
Common arguments:
|
||||
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
|
||||
|
@ -59,7 +59,7 @@ ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchang
|
||||
|
||||
ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit",
|
||||
"db_url", "trade_source", "export", "exportfilename",
|
||||
"timerange", "ticker_interval", "skip_trades"]
|
||||
"timerange", "ticker_interval", "no_trades"]
|
||||
|
||||
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
||||
"trade_source", "ticker_interval"]
|
||||
|
@ -413,9 +413,9 @@ AVAILABLE_CLI_OPTIONS = {
|
||||
metavar='INT',
|
||||
default=750,
|
||||
),
|
||||
"skip_trades": Arg(
|
||||
'--skip-trades',
|
||||
help='Skip using trades file from backtesting and DB.',
|
||||
"no_trades": Arg(
|
||||
'--no-trades',
|
||||
help='Skip using trades from backtesting file and DB.',
|
||||
action='store_true',
|
||||
),
|
||||
"trade_source": Arg(
|
||||
|
@ -129,7 +129,7 @@ def load_trades_from_db(db_url: str) -> pd.DataFrame:
|
||||
return trades
|
||||
|
||||
|
||||
def load_trades(source: str, db_url: str, exportfilename: Path, skip_trades: bool) -> pd.DataFrame:
|
||||
def load_trades(source: str, db_url: str, exportfilename: Path, no_trades: bool) -> pd.DataFrame:
|
||||
"""
|
||||
Based on configuration option "trade_source":
|
||||
* loads data from DB (using `db_url`)
|
||||
@ -137,10 +137,10 @@ def load_trades(source: str, db_url: str, exportfilename: Path, skip_trades: boo
|
||||
:param source: "DB" or "file" - specify source to load from
|
||||
:param db_url: sqlalchemy formatted url to a database
|
||||
:param exportfilename: Json file generated by backtesting
|
||||
:param skip_trades: Skip using trades, only return backtesting data columns
|
||||
:param no_trades: Skip using trades, only return backtesting data columns
|
||||
:return: DataFrame containing trades
|
||||
"""
|
||||
if skip_trades:
|
||||
if no_trades:
|
||||
df = pd.DataFrame(columns=BT_DATA_COLUMNS)
|
||||
return df
|
||||
|
||||
|
@ -3,7 +3,6 @@ from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import pandas as pd
|
||||
from os.path import isfile
|
||||
|
||||
from freqtrade.configuration import TimeRange
|
||||
from freqtrade.data.btanalysis import (calculate_max_drawdown,
|
||||
@ -49,18 +48,18 @@ def init_plotscript(config):
|
||||
data_format=config.get('dataformat_ohlcv', 'json'),
|
||||
)
|
||||
|
||||
skip_trades = False
|
||||
if not isfile(config.get('exportfilename')) and config['trade_source'] == 'file':
|
||||
no_trades = False
|
||||
if config.get('no_trades', False):
|
||||
no_trades = True
|
||||
elif not config['exportfilename'].is_file() and config['trade_source'] == 'file':
|
||||
logger.warning("Backtest file is missing skipping trades.")
|
||||
skip_trades = True
|
||||
elif config.get('skip_trades', False):
|
||||
skip_trades = True
|
||||
no_trades = True
|
||||
|
||||
trades = load_trades(
|
||||
config['trade_source'],
|
||||
db_url=config.get('db_url'),
|
||||
exportfilename=config.get('exportfilename'),
|
||||
skip_trades=skip_trades
|
||||
no_trades=no_trades
|
||||
)
|
||||
trades = trim_dataframe(trades, timerange, 'open_time')
|
||||
|
||||
|
@ -105,7 +105,7 @@ def test_load_trades(default_conf, mocker):
|
||||
load_trades("DB",
|
||||
db_url=default_conf.get('db_url'),
|
||||
exportfilename=default_conf.get('exportfilename'),
|
||||
skip_trades=False
|
||||
no_trades=False
|
||||
)
|
||||
|
||||
assert db_mock.call_count == 1
|
||||
@ -117,7 +117,7 @@ def test_load_trades(default_conf, mocker):
|
||||
load_trades("file",
|
||||
db_url=default_conf.get('db_url'),
|
||||
exportfilename=default_conf.get('exportfilename'),
|
||||
skip_trades=False
|
||||
no_trades=False
|
||||
)
|
||||
|
||||
assert db_mock.call_count == 0
|
||||
@ -129,7 +129,7 @@ def test_load_trades(default_conf, mocker):
|
||||
load_trades("file",
|
||||
db_url=default_conf.get('db_url'),
|
||||
exportfilename=default_conf.get('exportfilename'),
|
||||
skip_trades=True
|
||||
no_trades=True
|
||||
)
|
||||
|
||||
assert db_mock.call_count == 0
|
||||
|
Loading…
Reference in New Issue
Block a user