Fix filename handling with --strategy-list
This commit is contained in:
parent
2915917680
commit
cf6e6488c7
@ -24,13 +24,14 @@ def store_backtest_result(recordfilename: Path, all_results: Dict[str, DataFrame
|
|||||||
for index, t in results.iterrows()]
|
for index, t in results.iterrows()]
|
||||||
|
|
||||||
if records:
|
if records:
|
||||||
|
filename = recordfilename
|
||||||
if len(all_results) > 1:
|
if len(all_results) > 1:
|
||||||
# Inject strategy to filename
|
# Inject strategy to filename
|
||||||
recordfilename = Path.joinpath(
|
filename = Path.joinpath(
|
||||||
recordfilename.parent,
|
recordfilename.parent,
|
||||||
f'{recordfilename.stem}-{strategy}').with_suffix(recordfilename.suffix)
|
f'{recordfilename.stem}-{strategy}').with_suffix(recordfilename.suffix)
|
||||||
logger.info(f'Dumping backtest results to {recordfilename}')
|
logger.info(f'Dumping backtest results to {filename}')
|
||||||
file_dump_json(recordfilename, records)
|
file_dump_json(filename, records)
|
||||||
|
|
||||||
|
|
||||||
def generate_text_table(data: Dict[str, Dict], stake_currency: str, max_open_trades: int,
|
def generate_text_table(data: Dict[str, Dict], stake_currency: str, max_open_trades: int,
|
||||||
|
@ -160,10 +160,15 @@ def test_backtest_record(default_conf, fee, mocker):
|
|||||||
# reset test to test with strategy name
|
# reset test to test with strategy name
|
||||||
names = []
|
names = []
|
||||||
records = []
|
records = []
|
||||||
results['Strat'] = pd.DataFrame()
|
results['Strat'] = results['DefStrat']
|
||||||
|
results['Strat2'] = results['DefStrat']
|
||||||
store_backtest_result(Path("backtest-result.json"), results)
|
store_backtest_result(Path("backtest-result.json"), results)
|
||||||
# Assert file_dump_json was only called once
|
# Assert file_dump_json was only called once
|
||||||
assert names == [Path('backtest-result-DefStrat.json')]
|
assert names == [
|
||||||
|
Path('backtest-result-DefStrat.json'),
|
||||||
|
Path('backtest-result-Strat.json'),
|
||||||
|
Path('backtest-result-Strat2.json'),
|
||||||
|
]
|
||||||
records = records[0]
|
records = records[0]
|
||||||
# Ensure records are of correct type
|
# Ensure records are of correct type
|
||||||
assert len(records) == 4
|
assert len(records) == 4
|
||||||
|
Loading…
Reference in New Issue
Block a user