Skip to content

Sync the api client with the OpenAPI spec - #9815

Open
jhonabreul wants to merge 23 commits into
QuantConnect:masterfrom
jhonabreul:feature-api-client-audit
Open

jhonabreul wants to merge 23 commits into
QuantConnect:masterfrom
jhonabreul:feature-api-client-audit

Conversation

@jhonabreul

Copy link
Copy Markdown
Collaborator

Description

Every endpoint of the QuantConnect OpenAPI spec was compared with Api and its models, and every difference fixed. Stacked on #9808, which should merge first.

New endpoint methods:

  • UpdateProject, PatchProjectFile and ReadBacktestLog, declared on IApi as well.

Missing members the client never sent or exposed:

  • Request: codeSourceId on the file methods, start/end on ListProjects, parameters on CreateBacktest, projectId on ListLiveAlgorithms, algorithmId on ReadLiveInsights, query and deploymentLogs on the log methods.
  • Response: Project.IsPinned/MaxFileSize/SharingTokenBacktest, Compile.Parameters, Backtest.Debugging, BacktestReport.Generating, ReadChartResponse.Status/Progress, OrdersResponseWrapper.Status/Progress, CreateLiveAlgorithmResponse.Live, LiveAlgorithmResults.Description/IsPublicStreaming, four fields on LiveAlgorithmSummary, BaseOptimization.Extremum, Optimization.TargetValue, ListObjectStoreResponse.Page/TotalPages.

Mismatches with the documented request or response:

  • ReadBacktestInsights posted to an undocumented path and never reached the endpoint; it now posts to the documented one.
  • Card.LastFourDigits was a decimal, dropping leading zeros; now a string.
  • UpdateProjectFileName and UpdateProjectFileContent discarded the returned files; they return ProjectFilesResponse.
  • ReadBacktestReport treated a report still generating as an empty success; it keeps polling while Generating is set.
  • SummaryObjectStore.IsFolder read isFolder and never populated; the API sends folder.
  • ReadLiveAlgorithm required a deployId the request does not; it is optional, and the results converter reads every field optionally and the errors from the errors array.
  • IApi defaults for ListBacktests and UpdateBacktest differed from the class, so calls through the interface sent different payloads; aligned.

Left out on purpose: the project collaboration, brokerage authorization and AI tool endpoints.

Spec discrepancies: reviewers must verify

  • account/read documents no request body, but the client sends organizationId to select an organization, and the spec has no organization endpoint at all. Kept.
  • Project.parameters is documented as a name to value map; the API returns a list of name and value objects. Client kept.
  • ReadBacktestChartRequest marks start and end required; the API treats them as optional and defaults to the full range. Client kept.
  • backtests/tags/update and Backtest.ServerStatistics are undocumented but served. Kept, not obsoleted.
  • BacktestSummary.SecurityTypes is a string in the client and an integer count in the spec. Kept.
  • object/list folder flag: the spec's folder was confirmed against the real API; the old isFolder was wrong.

Related Issue

#9798

Motivation and Context

The client had drifted from the documented API in ways that silently dropped data or never reached an endpoint.

Requires Documentation Change

Yes: the six items in the discrepancies section above are candidate spec fixes.

How Has This Been Tested?

All in the credentialed fixtures that the API tests workflow runs, for manual runs with api credentials:

  • ProjectTests: 13 tests, one per project, file, compile and backtest change, asserting the request sent or the documented member returned.
  • LiveTradingTests: the live create summary, reading a live algorithm without a deploy id, and the project filter on the live list.
  • OptimizationTests and ObjectStoreTests: one test each for the new optimization and listing members.
  • LiveAlgorithmResultsJsonConverterTests: 4 unit tests for the converter, 8 in the suite passing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

…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.
…offline api fixtures with online tests

Both order methods use the same 100 window cap and both log methods keep 200. The
query parameter of the log methods documents an example. The loopback stub server and
its offline fixtures are gone; the paged read guards, the default window and the log
query are now covered by tests in the credentialed fixtures that CI runs.
…ew overload

ReadLiveOrders(projectId, algorithmId, start, end) mirrors ReadBacktestOrders. The previous
signature stays as an obsolete forwarder so existing callers keep working.
@jhonabreul
jhonabreul force-pushed the feature-api-client-audit branch from 1bf71ca to 1a0afb8 Compare September 21, 2026 21:06
…orwarder, the return type already breaks callers
Adds the documented endpoints the client did not cover (file patch, project update, live
auth0 read, the ai tools), the request and response members it was missing, fixes the
mismatches with the documented request and response shapes, and aligns the IApi defaults
with the class. Tests in the credentialed fixtures are still to be written.
One test or case per audited change in ProjectTests, LiveTradingTests, OptimizationTests
and ObjectStoreTests, which CI runs with api credentials, plus unit tests for the rewritten
live results converter.
… new overload

ReadLiveInsights(projectId, algorithmId, start, end) mirrors ReadBacktestInsights. The
previous signature stays as an obsolete forwarder so existing callers keep working.
@jhonabreul
jhonabreul force-pushed the feature-api-client-audit branch from 1a0afb8 to 0017c64 Compare September 21, 2026 21:27
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.

1 participant