Skip to content

Commit

Permalink
test: speed up detail test
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 15, 2024
1 parent f341edb commit e26ac6e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/optimize/test_backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,15 +1607,15 @@ def _trend_alternate_hold(dataframe=None, metadata=None):
mocker.patch(f"{EXMS}.get_fee", fee)
patch_exchange(mocker)

raw_candles_1m = generate_test_data("1m", 2500, "2022-01-03 12:00:00+00:00")
raw_candles_1m = generate_test_data("1m", 1000, "2022-01-03 12:00:00+00:00")
raw_candles = ohlcv_fill_up_missing_data(raw_candles_1m, "5m", "dummy")

pairs = ["ADA/USDT", "DASH/USDT", "ETH/USDT", "LTC/USDT", "NXT/USDT"]
data = {pair: raw_candles for pair in pairs}
detail_data = {pair: raw_candles_1m for pair in pairs}

# Only use 500 lines to increase performance
data = trim_dictlist(data, -500)
data = trim_dictlist(data, -200)

# Remove data for one pair from the beginning of the data
if tres > 0:
Expand Down Expand Up @@ -1644,17 +1644,17 @@ def _trend_alternate_hold(dataframe=None, metadata=None):
results = backtesting.backtest(**backtest_conf)

# bot_loop_start is called once per candle.
assert backtesting.strategy.bot_loop_start.call_count == 499
assert backtesting.strategy.bot_loop_start.call_count == 199
# Validated row once per candle and pair
assert vr_spy.call_count == 2495
assert vr_spy.call_count == 995

if use_detail:
# Backtest loop is called once per candle per pair
# Exact numbers depend on trade state - but should be around 3_800
assert bl_spy.call_count > 3_800
assert bl_spy.call_count < 3_900
assert bl_spy.call_count > 1_350
assert bl_spy.call_count < 1_500
else:
assert bl_spy.call_count < 2495
assert bl_spy.call_count < 995

# Make sure we have parallel trades
assert len(evaluate_result_multi(results["results"], "5m", 2)) > 0
Expand Down

0 comments on commit e26ac6e

Please sign in to comment.