Repository navigation
fix(sdk): read a result whose numeric or boolean per-run params are echoed back - #8
Merged
Merged
Conversation
…choed back The generated client reads the number | string | boolean value of a strategy param by requiring exactly one member to accept the JSON scalar. Its mapper coerced scalars between JSON types, so every number matched two or three members and every boolean two: a backtest started with a numeric or boolean params value ran on the platform, but its result failed to deserialize with 'N classes match result, expected 1'. Only string values worked. Scalar coercion is turned off in the client that QTSurfer and authenticate() build. The mapper is installed with setObjectMapper before any API class is built, because getObjectMapper() returns a copy and the API classes take theirs from the client at construction.
This branch was previously deployed
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.
What
A backtest started with a numeric or boolean per-run
paramsvalue could not be read back. The platform ran the job and echoed the parameters in the result, but deserializing it failed:By the type of the value: an integer matched 3 members, a decimal or a boolean 2; only a string worked. Through the MCP server this showed up as a job that ended
FAILEDfor every numeric parameter.Cause
ScalarStrategyParamValueisoneOf: [number, string, boolean]. The generated client reads aoneOfby trying each member and requiring exactly one to accept the value, but Jackson's default scalar coercion also accepts a JSON number as a string and as a boolean (and, for the integer, as a decimal as well). WithALLOW_COERCION_OF_SCALARSoff,20,20.5,trueand"abc"each match exactly one member.Fix
ApiClients.create()builds the generated client with that feature off, andQTSurfer.builder().build()andauthenticate(...)use it. The mapper has to be installed withsetObjectMapper(...):getObjectMapper()hands out a copy on each call, so configuring what it returns changes nothing, and the API classes take their mapper from the client when they are built.Tests
ApiClientsTest: a whole number, a decimal, a boolean and a string (including strings that look like a number or a boolean), and aResultMapechoing mixed params.BacktestResultTestandAuthenticatedClientTest: a result with numeric, boolean and string params, read throughQTSurferand through the sessionauthenticate(...)returns. The first run of these failed on the version ofApiClientsthat configured the mapper in place, which is what led to thesetObjectMapperform.mvn verify: 157 tests pass (2 skipped, as before).Checked live
The built classes against the live API (OpenAPI 0.128.47): account and usage, exchanges (whose
segmentsandliveSegmentsare sets), instruments, pools, datasets, a klines dataset, a finished dataset import, strategies, live runs, a backtest withcycle.seconds=20(72 trades, the parameter echoed back), a backtest without params, and a four-point sweep. All read correctly; turning coercion off breaks none of them.Not in this PR
No version bump or release: the changelog entry sits under
[Unreleased]. The MCP server needs only a dependency bump once this is released.