Skip to content

Release: order convenience functions, vector backtest bundle fix, scenario CI optimizations#557

Merged
MDUYN merged 7 commits into
mainfrom
dev
May 22, 2026
Merged

Release: order convenience functions, vector backtest bundle fix, scenario CI optimizations#557
MDUYN merged 7 commits into
mainfrom
dev

Conversation

@MDUYN

@MDUYN MDUYN commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Promotes the following changes from dev to main:

Features

Fixes

Tests / CI

Follow-ups

Closes #386, #440 (already closed on dev merge; tracked here for release notes).

MDUYN added 7 commits May 20, 2026 11:40
- Shorten backtest date ranges from 99-100 days to 30 days so each
  scenario runs in well under 30s on Ubuntu CI runners.
- Remove @unittest.skip decorators that were guarding the slow tests
  and the known-failing exact-value assertions.
- Source all OHLCV inputs from tests/resources/test_data/ohlcv/ via
  DATA_DIRECTORY config (and a direct CSV path for the pandas data
  provider test), so tests no longer depend on files outside
  tests/resources/test_data/.
- Replace brittle exact-value growth/net-gain assertions with
  structural checks (initial balance, trading symbol, snapshot
  count/timestamps, growth/net-gain consistency) and an explicit
  per-test <30s runtime guard.
- Port the four previously commented-out scenarios
  (single strategy param, multiple strategies param,
  strategies attribute, algorithms param) to the current Backtest
  API (get_backtest_metrics / get_backtest_run).
…cktest-scenarios

test(scenarios): optimize event_backtests for CI (#385)
- _batch_save_and_checkpoint now merges new backtests with any existing
  bundle for the same algorithm_id before saving, so multi-range runs
  with backtest_storage_directory accumulate all date ranges' runs in
  one bundle (previously the per-iteration save overwrote the prior
  bundle, leaving only the last range's runs).
- Overlapping date-range runs in the existing bundle are dropped
  before combining so forced reruns don't produce duplicates.
- Un-skips the 5 tests that this limitation was masking:
  test_run_with_backtest_storage_directory
  test_run_backtests_with_storage_directory
  test_preexisting_backtests_not_included_in_new_run
  test_run_with_checkpoints_multiple_backtest_ranges
  test_run_with_checkpoints_multiple_backtest_ranges_without_existing
- Updates assertions in test_preexisting_backtests_not_included_in_new_run
  to count .iafbt bundle files (current default) instead of legacy
  per-backtest directories.
- Reduces param grids in the unskipped multi-range tests to keep each
  under 30s on CI (spawn-based n_workers=4 was net-negative for
  small grids on macOS).

Closes #386
…acktest-scenarios

test(scenarios): optimize vectorized_backtests for CI (#386)
Add five high-level ordering helpers on Context that simplify
portfolio management and rebalancing by removing manual amount
calculations:

- order_value(symbol, value, side, price): place a LIMIT order for
  a fixed currency amount (amount = value / price).
- order_percent(symbol, percent, side, price): place a LIMIT order
  for a percentage of the portfolio's net size.
- order_target(symbol, target_amount, price): adjust the position
  to exactly target_amount units; submits BUY/SELL for the
  difference, or no order when already on target.
- order_target_value(symbol, target_value, price): adjust the
  position so its market value at price equals target_value.
- order_target_percent(symbol, target_percent, price): adjust the
  position so its market value equals target_percent of the
  portfolio's net size (rebalancing).

All helpers produce LIMIT orders by default and validate inputs
(positive value/percent/price, non-negative targets). Implemented
as thin wrappers around create_limit_order; target_* helpers
compute the current position size and place a BUY or SELL for the
difference.

Tests: 14 new tests in test_order_convenience_functions.py covering
buy paths, target-down rebalancing, no-op when already on target,
and validation errors.

Closes #440
…e-functions

feat(context): order convenience functions (#440)
Add a 'Convenience Helpers' section to the Orders page covering
order_value, order_percent, order_target, order_target_value and
order_target_percent — including a comparison table, a rebalancing
example, validation rules, and a note pointing at the follow-up
issue for the MARKET / auto-price variant.
@MDUYN MDUYN merged commit 1664827 into main May 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize scenario tests: tests/scenarios/vectorized_backtests/

1 participant