mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-05-04 23:52:14 +00:00
Merge pull request #11758 from mrpabloyeah/add-max-trade-duration-to-backtest-results
Add min/max trade duration to backtest results
This commit is contained in:
@@ -40,7 +40,7 @@ from freqtrade.optimize.optimize_reports.optimize_reports import (
|
||||
generate_tag_metrics,
|
||||
)
|
||||
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||
from freqtrade.util import dt_ts
|
||||
from freqtrade.util import dt_ts, format_duration
|
||||
from freqtrade.util.datetime_helpers import dt_from_ts, dt_utc
|
||||
from tests.conftest import CURRENT_TEST_STRATEGY, log_has_re
|
||||
from tests.data.test_history import _clean_test_file
|
||||
@@ -482,8 +482,8 @@ def test_generate_trading_stats(testdatadir):
|
||||
bt_data = load_backtest_data(filename)
|
||||
res = generate_trading_stats(bt_data)
|
||||
assert isinstance(res, dict)
|
||||
assert res["winner_holding_avg"] == timedelta(seconds=1440)
|
||||
assert res["loser_holding_avg"] == timedelta(days=1, seconds=21420)
|
||||
assert res["winner_holding_avg"] == format_duration(timedelta(seconds=1440))
|
||||
assert res["loser_holding_avg"] == format_duration(timedelta(days=1, seconds=21420))
|
||||
assert "wins" in res
|
||||
assert "losses" in res
|
||||
assert "draws" in res
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from freqtrade.util import decimals_per_coin, fmt_coin, round_value
|
||||
from freqtrade.util.formatters import fmt_coin2
|
||||
from datetime import timedelta
|
||||
|
||||
from freqtrade.util import decimals_per_coin, fmt_coin, fmt_coin2, format_duration, round_value
|
||||
|
||||
|
||||
def test_decimals_per_coin():
|
||||
@@ -45,3 +46,12 @@ def test_round_value():
|
||||
assert round_value(0.1274512123, 5) == "0.12745"
|
||||
assert round_value(222.2, 3, True) == "222.200"
|
||||
assert round_value(222.2, 0, True) == "222"
|
||||
|
||||
|
||||
def test_format_duration():
|
||||
assert format_duration(timedelta(minutes=5)) == "0d 00:05"
|
||||
assert format_duration(timedelta(minutes=75)) == "0d 01:15"
|
||||
assert format_duration(timedelta(minutes=1440)) == "1d 00:00"
|
||||
assert format_duration(timedelta(minutes=1445)) == "1d 00:05"
|
||||
assert format_duration(timedelta(minutes=11445)) == "7d 22:45"
|
||||
assert format_duration(timedelta(minutes=101445)) == "70d 10:45"
|
||||
|
||||
Reference in New Issue
Block a user