mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 16:43:06 +00:00
update sell_reason to exit_reason
This commit is contained in:
@@ -15,9 +15,8 @@ from freqtrade.edge import PairInfo
|
||||
from freqtrade.enums import ExitType
|
||||
from freqtrade.optimize.optimize_reports import (_get_resample_from_period, generate_backtest_stats,
|
||||
generate_daily_stats, generate_edge_table,
|
||||
generate_pair_metrics,
|
||||
generate_exit_reason_stats, generate_pair_metrics,
|
||||
generate_periodic_breakdown_stats,
|
||||
generate_sell_reason_stats,
|
||||
generate_strategy_comparison,
|
||||
generate_trading_stats, show_sorted_pairlist,
|
||||
store_backtest_stats, text_table_bt_results,
|
||||
@@ -77,7 +76,7 @@ def test_generate_backtest_stats(default_conf, testdatadir, tmpdir):
|
||||
"is_open": [False, False, False, True],
|
||||
"is_short": [False, False, False, False],
|
||||
"stake_amount": [0.01, 0.01, 0.01, 0.01],
|
||||
"sell_reason": [ExitType.ROI, ExitType.STOP_LOSS,
|
||||
"exit_reason": [ExitType.ROI, ExitType.STOP_LOSS,
|
||||
ExitType.ROI, ExitType.FORCE_SELL]
|
||||
}),
|
||||
'config': default_conf,
|
||||
@@ -129,7 +128,7 @@ def test_generate_backtest_stats(default_conf, testdatadir, tmpdir):
|
||||
"is_open": [False, False, False, True],
|
||||
"is_short": [False, False, False, False],
|
||||
"stake_amount": [0.01, 0.01, 0.01, 0.01],
|
||||
"sell_reason": [ExitType.ROI, ExitType.ROI,
|
||||
"exit_reason": [ExitType.ROI, ExitType.ROI,
|
||||
ExitType.STOP_LOSS, ExitType.FORCE_SELL]
|
||||
}),
|
||||
'config': default_conf,
|
||||
@@ -265,7 +264,7 @@ def test_generate_trading_stats(testdatadir):
|
||||
assert res['losses'] == 0
|
||||
|
||||
|
||||
def test_text_table_sell_reason():
|
||||
def test_text_table_exit_reason():
|
||||
|
||||
results = pd.DataFrame(
|
||||
{
|
||||
@@ -276,7 +275,7 @@ def test_text_table_sell_reason():
|
||||
'wins': [2, 0, 0],
|
||||
'draws': [0, 0, 0],
|
||||
'losses': [0, 0, 1],
|
||||
'sell_reason': [ExitType.ROI, ExitType.ROI, ExitType.STOP_LOSS]
|
||||
'exit_reason': [ExitType.ROI, ExitType.ROI, ExitType.STOP_LOSS]
|
||||
}
|
||||
)
|
||||
|
||||
@@ -291,9 +290,9 @@ def test_text_table_sell_reason():
|
||||
' -0.2 | -5 |'
|
||||
)
|
||||
|
||||
sell_reason_stats = generate_sell_reason_stats(max_open_trades=2,
|
||||
exit_reason_stats = generate_exit_reason_stats(max_open_trades=2,
|
||||
results=results)
|
||||
assert text_table_exit_reason(sell_reason_stats=sell_reason_stats,
|
||||
assert text_table_exit_reason(exit_reason_stats=exit_reason_stats,
|
||||
stake_currency='BTC') == result_str
|
||||
|
||||
|
||||
@@ -308,23 +307,23 @@ def test_generate_sell_reason_stats():
|
||||
'wins': [2, 0, 0],
|
||||
'draws': [0, 0, 0],
|
||||
'losses': [0, 0, 1],
|
||||
'sell_reason': [ExitType.ROI.value, ExitType.ROI.value, ExitType.STOP_LOSS.value]
|
||||
'exit_reason': [ExitType.ROI.value, ExitType.ROI.value, ExitType.STOP_LOSS.value]
|
||||
}
|
||||
)
|
||||
|
||||
sell_reason_stats = generate_sell_reason_stats(max_open_trades=2,
|
||||
exit_reason_stats = generate_exit_reason_stats(max_open_trades=2,
|
||||
results=results)
|
||||
roi_result = sell_reason_stats[0]
|
||||
assert roi_result['sell_reason'] == 'roi'
|
||||
roi_result = exit_reason_stats[0]
|
||||
assert roi_result['exit_reason'] == 'roi'
|
||||
assert roi_result['trades'] == 2
|
||||
assert pytest.approx(roi_result['profit_mean']) == 0.15
|
||||
assert roi_result['profit_mean_pct'] == round(roi_result['profit_mean'] * 100, 2)
|
||||
assert pytest.approx(roi_result['profit_mean']) == 0.15
|
||||
assert roi_result['profit_mean_pct'] == round(roi_result['profit_mean'] * 100, 2)
|
||||
|
||||
stop_result = sell_reason_stats[1]
|
||||
stop_result = exit_reason_stats[1]
|
||||
|
||||
assert stop_result['sell_reason'] == 'stop_loss'
|
||||
assert stop_result['exit_reason'] == 'stop_loss'
|
||||
assert stop_result['trades'] == 1
|
||||
assert pytest.approx(stop_result['profit_mean']) == -0.1
|
||||
assert stop_result['profit_mean_pct'] == round(stop_result['profit_mean'] * 100, 2)
|
||||
|
||||
Reference in New Issue
Block a user