Expose the total order count and share the paging window guard across the api read methods - #9808
Open
jhonabreul wants to merge 10 commits into
Open
jhonabreul wants to merge 10 commits into
jhonabreul wants to merge 10 commits into
Conversation
…alidate the paging window ReadBacktestOrders and ReadLiveOrders now return the OrdersResponseWrapper, whose Length holds the total order count, instead of only the page of orders, so callers can page through the whole collection. Both methods share the insights methods' window guard: a window larger than 100 throws and an end of 0 defaults to start + 100. Part of QuantConnect#9798
…ing window guard across the api methods ReadLiveOrders takes an optional algorithmId, documented in the API spec. The window guard used by the orders, insights and logs methods is now a single helper with a per-endpoint cap, the log line range defaults to a full window like its siblings, and the order json converter reads the documented stopTriggered, triggerTouched and trailingPercentage fields. Part of QuantConnect#9798
…nt filters to the live logs method ReadBacktestLog posts to backtests/read/log with the optional query keyword filter and the shared paging window guard. ReadLiveLogs now sends the documented query and deploymentLogs fields. The loopback stub server moves out of the orders test fixture so the new logs fixture can share it.
Adds ReadBacktestOrders, ReadLiveOrders, ReadBacktestLog, UpdateBacktestTags, CreateLiveCommand and ListObjectStore to the interface, widens ReadLiveLogs to the query and deploymentLogs arguments, and drops the explicit forwarding implementation that kept the old arity.
…and search the backtest log The backtest log endpoint accepts windows of up to 200 lines, unlike the live logs endpoint's 250, so it gets its own cap. The new credentialed tests run an algorithm that logs a numbered line per bar, page through the whole log with different window sizes, and search it with the query filter.
…share the same argument order
…alias no longer needs
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.
Description
Api.ReadBacktestOrdersandApi.ReadLiveOrdersdeserialized the total order count the API returns and then discarded it, so a caller could not page. Their default window also sentstart=500, end=100when onlystartwas given.The fix:
ReadBacktestOrdersandReadLiveOrdersreturn theOrdersResponseWrapper, exposingLengthnext to the page of orders.Api.ResolveWindowEndhelper validates the window and defaults an unsetendto a full page, used by the orders, insights and logs methods with a cap per endpoint.ReadLiveOrderstakes the documented optionalalgorithmId, placed afterprojectIdlike its siblings.Api.ReadBacktestLogforbacktests/read/log, with thequeryfilter;ReadLiveLogssends the documentedqueryanddeploymentLogs.Apiare now declared onIApi.OrderJsonConverterreads the documentedtriggerTouchedfield of limit-if-touched orders, which was never deserialized.Related Issue
#9798
Motivation and Context
Paging through an algorithm's orders is the only way to reconcile fills from research, and the total count is required to do it correctly.
Requires Documentation Change
Yes. The spec should document a 200-line window for both log endpoints (it says 250 for live logs and nothing for backtest logs), and name the trailing stop flag
trailingAsPercentage, which is what the API sends, instead oftrailingPercentage.How Has This Been Tested?
OrdersTests: offline fixture against a loopback stub asserting the request bodies, the exposedLength, the window guard and thealgorithmIdhandling. 22 passed.LogsTests: same pattern for both log endpoints, including thequeryanddeploymentLogsfields and the 200-line cap. 12 passed.ProjectTests.ReadBacktestOrdersPaginatesThroughAllOrders: pages a real backtest's orders with windows of 20, 50 and 100 and checks every order arrives once. Manual run with api credentials.ProjectTests.ReadBacktestLogPaginatesThroughAllLinesandReadBacktestLogFiltersLinesByQuery: same for the backtest log, with and without a query. Manual run with api credentials.OrderJsonConverterTests: existing suite, 55 passed.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>