Repository navigation
feat(tools)!: sync longbridge SDK 5.1 additions - #157
Merged
Merged
Conversation
Pick up the SDK surface that landed in openapi between 5.0 and 5.1 but
was never wired through here. The dependency moves from a pinned git rev
back to crates.io: `1df0f560` predated the option-chain rewrite, and the
branch note it carried (the symbol-based request contract) is now in a
release.
BREAKING CHANGE: `option_chain_info_by_date` now returns one entry per
contract instead of strikes paired by price. The endpoint moved to
`GET /v1/gemini/option/option_chain_list`, so `strikePrices[]{strike_price,
call{...}, put{...}}` is replaced by a flat list of `{symbol, expiry_date,
strike_price, direction, option_type, standard_attr, days_to_expiry}`.
Callers that read `call.symbol`/`put.symbol` must filter on `direction`
instead, and the response no longer carries prices or Greeks — those come
from `option_quote`. The tool also gains `standard_only`, which drops the
legacy contracts left over from a corporate action.
Also:
- `submit_multileg_order` documents `CalendarCallSpread` /
`CalendarPutSpread`. The value is parsed via `FromStr`, so only the
prose gated them.
- `submit_order` and `submit_multileg_order` gain `client_request_id`,
the exchange-side idempotency key, so a retry after a timeout cannot
double-fill. It is deliberately left out of `dry_run::Scope`: it does
not change the order the user approved, and a caller that regenerates
one between preview and execute must not be told its code is wrong. It
is echoed in the preview.
- `OPTION_PRE_MARKET` is documented on the three outside-RTH fields. The
SDK already parsed it; being absent from the schema made it
unreachable.
- `create_config` honours an `x-papertrading` request header.
`create_http_client` already forwarded it with the rest of
`extra_headers`, but `Config` forwards none of them, so the SDK
contexts — trade above all — quietly ran against real money for a
caller who asked for paper trading. Trusting the header is safe in the
one direction that matters: it only narrows what a token may do, and
upstream rejects a paper-trading request made with a real-money token.
The zh-CN and zh-HK tool locales are updated to match, including the two
new parameters. `locales_match_live_tool_schema` only checks that locale
keys exist in the live schema, not the reverse, so a missing translation
would not have failed the build.
sunli829
marked this pull request as draft
September 21, 2026 04:47
sunli829
marked this pull request as ready for review
September 22, 2026 01:42
Merged
hogan-yuan
added a commit
that referenced
this pull request
Oct 8, 2026
Cut **v0.13.0**. Bumps `0.12.0` → `0.13.0` and pins the openapi dependency to the published crates.io release. ## Included since v0.12.0 - **Fund channel tools** (#161): 28 mutual-fund tools (25 read + `fund_validate_order` + 2 gated writes) — catalog & market data, user positions, orders/trading. Funds are addressed by `counter_id`. Writes (`fund_submit_order` / `fund_cancel_order`) are behind the two-step dry-run confirmation; reads are in the v2 allowlist. - **SDK 5.1 sync** (#157): ports the longbridge SDK 5.1 additions. ## Dependency - `longbridge` switched from the temporary git rev (`e0df4c1e8`) to the published crates.io release **`5.2.0`** (the fund channel shipped in openapi v5.2.0). `cargo build` + `cargo clippy --all-targets` clean.
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
An audit of what the openapi SDK gained between
5.0and5.1turned upseveral additions that were never wired through here. This picks up five of
them.
The dependency moves from a pinned git rev back to crates.io.
1df0f560predated the option-chain rewrite, and the branch note it carried (the
symbol-based, counter-id-free request contract) has since shipped in a
release — so the
TODOgoes away with it.Breaking: the option chain moved to an OpenAPI endpoint
option_chain_info_by_dateis now backed byGET /v1/gemini/option/option_chain_listinstead of quote socket command21(openapi#588). This is not a URL swap — the response shape changed.strikePrices[]{strike_price, call{symbol, last_done, iv, delta, gamma}, put{...}}{symbol, expiry_date, strike_price, direction, option_type, standard_attr, days_to_expiry}call_symbol/put_symbolsymboltooption_quoteCallers that read
call.symbol/put.symbolmust filter ondirectioninstead. The tool also gains
standard_only, which drops the legacycontracts left over from a corporate action (
standard_attr: "Old").Three stale cross-references are fixed along with it:
option_quoteandoption_chain_expiry_date_listboth pointed at the old paired shape, and thelatter promised "strikes and Greeks" that this endpoint never returns.
option_chain_expiry_date_listis unchanged and still uses socket command20— deliberately out of scope upstream, since the new endpoint requires anexpiry_dateand so cannot enumerate them.Calendar spreads
submit_multileg_ordernow documentsCalendarCallSpreadandCalendarPutSpread(openapi#590). The value is parsed viaFromStr, so theprose was the only thing gating them.
client_request_idsubmit_orderandsubmit_multileg_ordergain the exchange-side idempotencykey. Two requests carrying the same value place one order, and the second
returns the original
order_id— so a retry after a timeout or a droppedconnection cannot double-fill.
It is deliberately not part of
dry_run::Scope. An idempotency key doesnot change the order the user approved, and a caller that regenerates one
between the preview and the execute must not be told its confirmation code is
wrong. It is echoed in the preview, so the user can see a retry is guarded.
The existing
executegate and this key solve different halves of the sameproblem:
executestops a second intended order,client_request_idstopsa second delivery of the first one.
OPTION_PRE_MARKETDocumented on
outside_rthand on both attached-leg variants. The SDK hasparsed it since
fc617e5ea; being absent from the schema made it unreachablein practice.
Paper trading on the context path
create_confignow honours anx-papertrading: true(or1) requestheader.
This one was a real gap rather than a missing feature.
create_http_clientalready forwarded the header with the rest of
extra_headers, butConfigforwards none of them — so the SDK contexts, trade above all, quietly ran
against real money for a caller who had asked for paper trading.
Trusting a client header is safe in the one direction that matters: the flag
only ever narrows what a token may do, and upstream rejects a paper-trading
request made with a real-money token. A spurious header fails the call rather
than routing it somewhere unexpected.
LONGBRIDGE_PAPERTRADING=true(read bythe SDK) still covers a whole deployment; the header covers one request.
Documented in the README's authentication section and covered by a unit test.
Locales
locales/zh-CNandlocales/zh-HKare updated for all six affected tools,including the two new parameters. Worth noting for future changes:
locales_match_live_tool_schemaonly asserts that locale keys exist in thelive schema, not the reverse — a missing translation would not have failed
the build.
Verification
cargo clippy --all-features --all-targets— cleancargo test --all-features— 312 passed, 3 ignoredcargo +nightly fmtNot run: the three
#[ignore]d tests, and no live call against the newoption-chain endpoint from this machine.
🤖 Generated with Claude Code