Skip to content

Document serverStatistics and the closed trades endpoints - #2630

Merged
AlexCatarino merged 1 commit into
QuantConnect:masterfrom
AlexCatarino:document-server-statistics
Aug 19, 2026
Merged

Document serverStatistics and the closed trades endpoints#2630
AlexCatarino merged 1 commit into
QuantConnect:masterfrom
AlexCatarino:document-server-statistics

Conversation

@AlexCatarino

Copy link
Copy Markdown
Member

Summary

LEAN #9720 reports serverStatistics for backtests and live deployments, and the cloud API returns it, but nothing documented it. This adds it, together with two undocumented endpoints found while verifying the payloads.

  • serverStatistics — new ServerStatistics schema and an optional property on BacktestResult and LiveAlgorithmResults. It is optional because results produced before LEAN reported it don't carry it, and the live one is absent once the deployment stops.
  • /backtests/trades/read and /live/trades/read — neither was in the spec. Both are documented as Trades sections placed after Orders, which renumbers the Insights and Logs folders (page URLs use the slug, so no link changes).
  • Trade -> ClosedTrade — the old Trade schema claimed a singular symbol and no id, isWin or orderIds. The real AlgorithmPerformance.closedTrades payload has all of them, so the schema is replaced. The trades endpoints also return the orders that opened and closed each trade, so they use ClosedTradeWithOrders.
  • Generator — a request or response declared with oneOf produced a header and nothing else, which is why the live orders page has been empty; it now renders every variant. An array example that is already a list also closed its brackets twice, which made the Object Store request example invalid JSON.
  • Server Statistics section — new section under Writing Algorithms / Statistics, linked from the shared runtime statistics table.

Test plan

  • vacuum lint QuantConnect-Platform-2.0.0.yaml --fail-severity error passes with no errors.
  • python code-generators/API-Reference-Code-Generator.py is idempotent: a second run leaves no changes.
  • Every documented key was read from the API, not inferred: /backtests/read and /live/read for serverStatistics, /backtests/trades/read and /live/trades/read for the trade objects, and AlgorithmPerformance.closedTrades for the schema replacement.
  • Every JSON example on the regenerated pages parses, except the pre-existing empty "timeInForce": that the committed backtest orders page already shows.

Notes

  • The commit includes 14 Agent Management/03 Deployments/07 Read Conversation/02 Request.html. That page was stale against the spec, and running the generator picks it up.
  • Two items found while verifying /live/orders/read need the platform team rather than a docs change: algorithmId is accepted but ignored, so deployId is the parameter that scopes the read, and an unscoped trades read returns a single trade while reporting the full count.

Add the serverStatistics block that LEAN now reports for backtests and
live deployments to the OpenAPI spec, together with the undocumented
/backtests/trades/read and /live/trades/read endpoints, ordered after
Orders.

Replace the stale Trade schema with ClosedTrade, which matches what
AlgorithmPerformance.closedTrades returns, and give the trades endpoints
a ClosedTradeWithOrders schema for the orders they also return.

Render the models of a response or request that accepts one of several
schemas, which the generator used to skip, and stop it from closing an
array example twice when the example is a list.

Add a Server Statistics section to the Writing Algorithms statistics
documentation and link it from the runtime statistics table.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@AlexCatarino
AlexCatarino merged commit c40823b into QuantConnect:master Aug 19, 2026
1 check passed
@AlexCatarino
AlexCatarino deleted the document-server-statistics branch August 25, 2026 17:24
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