Backtest-reports should calculate total gains based on starting capital

This commit is contained in:
Matthias
2021-02-13 09:01:05 +01:00
parent 8d61a26382
commit 35e6a9ab3a
4 changed files with 44 additions and 17 deletions

View File

@@ -261,6 +261,7 @@ def get_default_conf(testdatadir):
"20": 0.02,
"0": 0.04
},
"dry_run_wallet": 1000,
"stoploss": -0.10,
"unfilledtimeout": {
"buy": 10,

View File

@@ -48,7 +48,7 @@ def test_text_table_bt_results():
)
pair_results = generate_pair_metrics(data={'ETH/BTC': {}}, stake_currency='BTC',
max_open_trades=2, results=results)
starting_balance=4, results=results)
assert text_table_bt_results(pair_results, stake_currency='BTC') == result_str
@@ -78,6 +78,7 @@ def test_generate_backtest_stats(default_conf, testdatadir):
}),
'config': default_conf,
'locks': [],
'final_balance': 1000.02,
'backtest_start_time': Arrow.utcnow().int_timestamp,
'backtest_end_time': Arrow.utcnow().int_timestamp,
}
@@ -189,7 +190,7 @@ def test_generate_pair_metrics():
)
pair_results = generate_pair_metrics(data={'ETH/BTC': {}}, stake_currency='BTC',
max_open_trades=2, results=results)
starting_balance=2, results=results)
assert isinstance(pair_results, list)
assert len(pair_results) == 2
assert pair_results[-1]['key'] == 'TOTAL'
@@ -291,6 +292,7 @@ def test_generate_sell_reason_stats():
def test_text_table_strategy(default_conf):
default_conf['max_open_trades'] = 2
default_conf['dry_run_wallet'] = 3
results = {}
results['TestStrategy1'] = {'results': pd.DataFrame(
{
@@ -323,9 +325,9 @@ def test_text_table_strategy(default_conf):
'|---------------+--------+----------------+----------------+------------------+'
'----------------+----------------+--------+---------+----------|\n'
'| TestStrategy1 | 3 | 20.00 | 60.00 | 1.10000000 |'
' 30.00 | 0:17:00 | 3 | 0 | 0 |\n'
' 36.67 | 0:17:00 | 3 | 0 | 0 |\n'
'| TestStrategy2 | 3 | 30.00 | 90.00 | 1.30000000 |'
' 45.00 | 0:20:00 | 3 | 0 | 0 |'
' 43.33 | 0:20:00 | 3 | 0 | 0 |'
)
strategy_results = generate_strategy_metrics(all_results=results)