Thread executor's time_per_step into the trade Account freq (#1846)#2218
Open
genisis0x wants to merge 1 commit into
Open
Thread executor's time_per_step into the trade Account freq (#1846)#2218genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
`create_account_instance` always built the Account with the hardcoded default `freq="day"`. When the user only has intraday data and runs the backtest with a higher-frequency executor (e.g. 60min), the benchmark fetch at `Account.__init__` tries to read day-level data and crashes before the executor's `reset_common_infra` gets a chance to call `trade_account.reset(freq=time_per_step)`. Derive the account's freq from the executor's `time_per_step` in `get_strategy_executor` and pass it through. Falls back to "day" when the executor's freq cannot be determined (Path / opaque object). Fixes microsoft#1846
Author
|
@microsoft-github-policy-service agree |
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.
Summary
`create_account_instance` always built `Account` with the hardcoded default `freq="day"`. When the user only has intraday data and runs the backtest with a higher-frequency executor (e.g. `time_per_step="60min"`), the benchmark fetch at `Account.init` tries to read day-level data and raises `ValueError: The benchmark [...] does not exist. Please provide the right benchmark` before the executor's `reset_common_infra` gets a chance to call `trade_account.reset(freq=time_per_step)`.
The fix derives the account's freq from the executor's `time_per_step` at the entry point and threads it through:
No change to the default day-frequency path: callers that don't set `time_per_step`, or that pass a Path-style executor, still get `freq="day"`.
Test plan
Fixes #1846