Refactor init_plotscript a bit (strategy is not needed for plot_profit)
This commit is contained in:
parent
9f29ad77bd
commit
395414ccde
@ -35,9 +35,10 @@ ARGS_CREATE_USERDIR = ["user_data_dir"]
|
|||||||
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "exchange", "timeframes", "erase"]
|
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "exchange", "timeframes", "erase"]
|
||||||
|
|
||||||
ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", "db_url",
|
ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", "db_url",
|
||||||
"trade_source", "export", "exportfilename", "timerange"]
|
"trade_source", "export", "exportfilename", "timerange", "ticker_interval"]
|
||||||
|
|
||||||
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source"]
|
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
||||||
|
"trade_source", "ticker_interval"]
|
||||||
|
|
||||||
NO_CONF_REQURIED = ["start_download_data"]
|
NO_CONF_REQURIED = ["start_download_data"]
|
||||||
|
|
||||||
|
@ -26,10 +26,9 @@ except ImportError:
|
|||||||
def init_plotscript(config):
|
def init_plotscript(config):
|
||||||
"""
|
"""
|
||||||
Initialize objects needed for plotting
|
Initialize objects needed for plotting
|
||||||
:return: Dict with tickers, trades, pairs and strategy
|
:return: Dict with tickers, trades and pairs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
strategy = StrategyResolver(config).strategy
|
|
||||||
if "pairs" in config:
|
if "pairs" in config:
|
||||||
pairs = config["pairs"]
|
pairs = config["pairs"]
|
||||||
else:
|
else:
|
||||||
@ -41,7 +40,7 @@ def init_plotscript(config):
|
|||||||
tickers = history.load_data(
|
tickers = history.load_data(
|
||||||
datadir=Path(str(config.get("datadir"))),
|
datadir=Path(str(config.get("datadir"))),
|
||||||
pairs=pairs,
|
pairs=pairs,
|
||||||
ticker_interval=config['ticker_interval'],
|
ticker_interval=config.get('ticker_interval', '5m'),
|
||||||
timerange=timerange,
|
timerange=timerange,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,10 +48,10 @@ def init_plotscript(config):
|
|||||||
db_url=config.get('db_url'),
|
db_url=config.get('db_url'),
|
||||||
exportfilename=config.get('exportfilename'),
|
exportfilename=config.get('exportfilename'),
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"tickers": tickers,
|
return {"tickers": tickers,
|
||||||
"trades": trades,
|
"trades": trades,
|
||||||
"pairs": pairs,
|
"pairs": pairs,
|
||||||
"strategy": strategy,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -329,9 +328,10 @@ def analyse_and_plot_pairs(config: Dict[str, Any]):
|
|||||||
- Generate plot files
|
- Generate plot files
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
strategy = StrategyResolver(config).strategy
|
||||||
|
|
||||||
plot_elements = init_plotscript(config)
|
plot_elements = init_plotscript(config)
|
||||||
trades = plot_elements['trades']
|
trades = plot_elements['trades']
|
||||||
strategy = plot_elements["strategy"]
|
|
||||||
|
|
||||||
pair_counter = 0
|
pair_counter = 0
|
||||||
for pair, data in plot_elements["tickers"].items():
|
for pair, data in plot_elements["tickers"].items():
|
||||||
@ -367,7 +367,10 @@ def plot_profit(config: Dict[str, Any]) -> None:
|
|||||||
in helping out to find a good algorithm.
|
in helping out to find a good algorithm.
|
||||||
"""
|
"""
|
||||||
plot_elements = init_plotscript(config)
|
plot_elements = init_plotscript(config)
|
||||||
trades = plot_elements['trades']
|
trades = load_trades(config['trade_source'],
|
||||||
|
db_url=config.get('db_url'),
|
||||||
|
exportfilename=config.get('exportfilename'),
|
||||||
|
)
|
||||||
# Filter trades to relevant pairs
|
# Filter trades to relevant pairs
|
||||||
trades = trades[trades['pair'].isin(plot_elements["pairs"])]
|
trades = trades[trades['pair'].isin(plot_elements["pairs"])]
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ def test_init_plotscript(default_conf, mocker):
|
|||||||
assert "tickers" in ret
|
assert "tickers" in ret
|
||||||
assert "trades" in ret
|
assert "trades" in ret
|
||||||
assert "pairs" in ret
|
assert "pairs" in ret
|
||||||
assert "strategy" in ret
|
|
||||||
|
|
||||||
default_conf['pairs'] = ["POWR/BTC", "XLM/BTC"]
|
default_conf['pairs'] = ["POWR/BTC", "XLM/BTC"]
|
||||||
ret = init_plotscript(default_conf)
|
ret = init_plotscript(default_conf)
|
||||||
|
Loading…
Reference in New Issue
Block a user