Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes the following changes from
devtomain:Features
order_value,order_percent,order_target,order_target_value,order_target_percenton the strategy context. Includes unit tests and documentation indocusaurus/docs/Getting Started/orders.md.Fixes
_batch_save_and_checkpointnow merges multi-range bundles instead of overwriting per iteration. Stale skipped test removed.Tests / CI
Follow-ups
Closes #386, #440 (already closed on dev merge; tracked here for release notes).