Skip to content

Commit 323b9f8

Browse files
committed
fix(api): only write export when backtest happened
closes freqtrade/frequi#2282
1 parent 2bfd66d commit 323b9f8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

freqtrade/rpc/api_server/api_backtest.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,18 @@ def __run_backtest_bg(btconfig: Config):
9999
ApiBG.bt["data"], ApiBG.bt["bt"].all_results, min_date=min_date, max_date=max_date
100100
)
101101

102-
if btconfig.get("export", "none") == "trades":
103-
combined_res = combined_dataframes_with_rel_mean(ApiBG.bt["data"], min_date, max_date)
104-
fn = store_backtest_results(
105-
btconfig,
106-
ApiBG.bt["bt"].results,
107-
datetime.now().strftime("%Y-%m-%d_%H-%M-%S"),
108-
market_change_data=combined_res,
109-
)
110-
ApiBG.bt["bt"].results["metadata"][strategy_name]["filename"] = str(fn.stem)
111-
ApiBG.bt["bt"].results["metadata"][strategy_name]["strategy"] = strategy_name
102+
if btconfig.get("export", "none") == "trades":
103+
combined_res = combined_dataframes_with_rel_mean(
104+
ApiBG.bt["data"], min_date, max_date
105+
)
106+
fn = store_backtest_results(
107+
btconfig,
108+
ApiBG.bt["bt"].results,
109+
datetime.now().strftime("%Y-%m-%d_%H-%M-%S"),
110+
market_change_data=combined_res,
111+
)
112+
ApiBG.bt["bt"].results["metadata"][strategy_name]["filename"] = str(fn.stem)
113+
ApiBG.bt["bt"].results["metadata"][strategy_name]["strategy"] = strategy_name
112114

113115
logger.info("Backtest finished.")
114116

0 commit comments

Comments
 (0)