Repository navigation
feat(fundamental): expose what BusinessV4 returns for business_segments - #632
Merged
Merged
Conversation
The gateway behind this endpoint moved to BusinessV4 and now returns considerably more than the SDK models. Nothing broke -- serde ignores the new fields -- but a caller gets a name and a percentage per segment and nothing else, which means the amounts are unreachable and the regional breakdown is invisible. Measured against production, the response carries: report_txt, fp_start, fp_end, yoy and regionals at the top level, and value, id and yoy on each segment item. The history variant of this API already exposed regionals and value, so the latest-snapshot type was the odd one out. The two that matter most: - `value` -- without it a caller has to multiply the percentage back out against `total` to recover an amount the server already sent. - `regionals` -- an entire dimension that was simply unreachable. Every new field is `#[serde(default)]`. An issuer with no coverage comes back with every field empty and an empty `business` array, and that still decodes; verified against 600519.SH, which is such a case. `rpt_date` is deliberately left out. The gateway returns it here, but compared with `business-segments/history` for the same symbol and the same fiscal period the two disagree -- history gives 2026.08.12 for Tencent's 2026.Q2 where this endpoint gives 2025.08.13, a year and a day apart. Six of six symbols showed the same skew. Exposing it as a field would put a wrong value behind a name callers would reasonably trust. Node.js and Python do not expose this API at all, so the fan-out is Rust core, C, C++ and Java. The C header is regenerated by cbindgen. Verified end to end against production: 700.HK returns report_txt=2026.Q2, fp_start/fp_end 2026.03.30~2026.06.30, and per-segment values and ids (Value-Added Services 48.06%, 98414000000, id 119683).
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.
The gateway behind
business_segmentsmoved to BusinessV4 and now returns considerably more than the SDK models. Nothing is broken — serde ignores the new fields, and the call keeps working — but a caller gets a name and a percentage per segment and nothing else.What the gateway actually sends
Measured against production (
700.HK):{ "total": "204785000000", "currency": "CNY", "date": "20260630", "report_txt": "2026.Q2", "fp_start": "2026.03.30", "fp_end": "2026.06.30", "yoy": "", "rpt_date": "2025.08.13", "business": [ {"name": "增值服务", "percent": "48.06", "value": "98414000000", "id": "119683", "yoy": "7.711671"} ], "regionals": [] }The SDK modelled
date,total,currencyandbusiness[{name, percent}]. Everything else was dropped on the floor.The two that matter
valuetotalto recover an amount the server already sentregionalsAlso added:
report_txt,fp_start,fp_end,yoyat the top level;idandyoyper item.rpt_dateis deliberately left outThe gateway returns it. I did not expose it, because it disagrees with the
business-segments/historyendpoint for the same symbol and the same fiscal period:rpt_datebusiness-segments/historybusiness-segmentsSix of six symbols showed the same skew (700.HK, AAPL.US, 9988.HK, MSFT.US, TSLA.US, BABA.US) — a year off, and in this case a day off too, so it is not a clean year-offset. The history endpoint's 38 records are internally consistent, including the cross-year case of an annual report filed the following March, so the fault is on this endpoint rather than a difference in meaning.
Putting a wrong value behind a field name callers would reasonably trust is worse than not having the field. It can be added once the data is right.
Robustness
Every new field is
#[serde(default)]. An issuer with no coverage comes back with every field empty and an emptybusinessarray:Verified against
600519.SH, which is such a case — A-shares returncode: 0with everything blank.Scope
Four layers, not six.
business_segmentsis not exposed in Node.js or Python at all, so the fan-out is Rust core → C → C++ → Java. The C header is regenerated by cbindgen.A note for review: these are deserialize-only response types, but adding public fields to a non-
#[non_exhaustive]struct is technically breaking for Rust code that constructs or exhaustively destructures one. Nobody constructs a response type, and the repo has added fields to response types in minor releases before, so I treated it as additive — say the word if you would rather it waited for a major.Verified end to end
Against production, through the SDK:
cargo check --allclean across all four layers.cargo test -p longbridge: 88 + 57 pass.cargo clippy --all --all-features: diffed againstmain, zero new warnings.Not in this PR
--format jsonalready carries everything new).rpt_datediscrepancy itself — that is a data issue for the fundamentals team, not something the SDK can fix.🤖 Generated with Claude Code