feat: add shareholders, screener, short-trades, rank, top-movers, valuation-comparison APIs#527
Open
hogan-yuan wants to merge 12 commits into
Open
feat: add shareholders, screener, short-trades, rank, top-movers, valuation-comparison APIs#527hogan-yuan wants to merge 12 commits into
hogan-yuan wants to merge 12 commits into
Conversation
- FundamentalContext: shareholder_top, shareholder_detail, valuation_comparison - QuoteContext: hk_short_positions, short_trades (auto-detects HK vs US endpoint) - MarketContext: stock_events (POST), rank_categories, rank_list - New ScreenerContext: screener_recommend_strategies, screener_user_strategies, screener_strategy, screener_search (POST), screener_indicators - All methods have matching blocking (sync) wrappers - All new response types use serde_json::Value for flexible raw-JSON payloads Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… APIs to all language SDKs
Rust SDK:
- `short_positions(symbol, count)` now auto-detects market from symbol suffix
(.HK → GET /v1/quote/short-positions/hk, else → /v1/quote/short-positions/us).
`ShortPositionsResponse` is now a raw JSON wrapper (`data: serde_json::Value`).
`hk_short_positions` and `ShortPosition` struct are removed.
Python / Node.js / Java / C / C++ SDKs:
- Port all 13 new Rust APIs added in the previous commit:
- FundamentalContext: shareholder_top, shareholder_detail, valuation_comparison
- QuoteContext: updated short_positions (HK+US, count param), short_trades
- MarketContext: stock_events, rank_categories, rank_list
- ScreenerContext (new): screener_recommend_strategies, screener_user_strategies,
screener_strategy, screener_search, screener_indicators
- All new "raw JSON" responses expose data as a string (Java/C/C++/Node.js)
or a Python object (Python, via pythonize).
- Updated openapi.pyi type stubs for all new types and methods.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ank_categories/rank_list These were already declared in longbridge.h (via cbindgen); the manual forward declarations in market_context.cpp had mismatched types (const char** vs const char* const*, size_t vs uintptr_t). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…lization The HTTP client extracts the `data` field from the API envelope before deserializing into the target struct. Response structs with `data: serde_json::Value` caused a double-unwrap — the inner JSON has no `data` key, so deserialization failed with "missing field `data`". Fix: deserialize to `serde_json::Value` first, then construct the response struct explicitly. Affects 13 new methods across FundamentalContext, QuoteContext, MarketContext, and ScreenerContext. Verified against production API: Python SDK 17/17 pass. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Renames method, response type, C function, and C type across Rust, Python, Node.js, Java, C, and C++ SDKs: - `stock_events` → `top_movers` (Rust/Python/Node.js/Java/C/C++ method) - `StockEventsResponse` → `TopMoversResponse` (Rust/Python/Node.js type) - `CStockEventsResponse` → `CTopMoversResponse` (C Rust type) - `lb_market_context_stock_events` → `lb_market_context_top_movers` (C extern fn) - `lb_stock_events_response_t` → `lb_top_movers_response_t` (C header type) C header (`longbridge.h`) regenerated via `cargo build -p longbridge-c`. Node.js type definitions regenerated via `npm run build:debug`. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Previously only TopMovers was wired up. Now all missing pieces are in place: SdkNative.java: - Added native declarations for: marketContextRankCategories, marketContextRankList, newScreenerContext, freeScreenerContext, screenerContextRecommendStrategies/UserStrategies/Strategy/Search/Indicators, fundamentalContextShareholderTop/Detail/ValuationComparison, quoteContextShortTrades New Java source files: - fundamental/: ShareholderTopResponse, ShareholderDetailResponse, ValuationComparisonResponse, ShareholderDetailOptions, ValuationComparisonOptions - market/: RankCategoriesResponse, RankListResponse, RankListOptions - quote/: ShortTradesResponse, ShortTradesOptions - screener/: ScreenerContext (new package), ScreenerRecommendStrategiesResponse, ScreenerUserStrategiesResponse, ScreenerStrategyResponse, ScreenerStrategyOptions, ScreenerSearchResponse, ScreenerSearchOptions, ScreenerIndicatorsResponse Updated Java context classes: - FundamentalContext.java: getShareholderTop, getShareholderDetail, getValuationComparison - MarketContext.java: getRankCategories, getRankList - QuoteContext.java: getShortTrades Rust side (java/src/): - types/classes.rs: impl_java_class! entries for all new response types - init.rs: registered all new Rust types Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
5cdec48 to
f18a5ae
Compare
Replace serde_json::Value payloads in short_positions, short_trades, rank_list, top_movers, and valuation_comparison with typed structs. Unix-second timestamps are converted to RFC 3339 strings; counter_id values are converted to dotted symbol notation (e.g. TSLA.US). Python, Node.js, Java, and C bindings updated accordingly. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
API wraps the array in {"counter_id":"...","data":[...]} object.
Changed both methods to deserialize the outer object first, then
extract the inner data array.
Verified: Go 7/7 tests pass, Python short_positions/trades all RFC3339.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace raw-JSON stub structs with fully typed structs in Java, C, and C++ SDKs for five APIs: short_positions, short_trades (QuoteContext); top_movers, rank_list (MarketContext); valuation_comparison (FundamentalContext). Java: add ShortPositionsItem, ShortTradesItem, TopMoversStock, TopMoversEvent, TopMoversResponse, RankListItem, RankListResponse, ValuationComparisonItem, ValuationHistoryPoint, ValuationComparisonResponse. C: add CShortPositionsItem, CShortTradesItem, CTopMoversStock, CTopMoversEvent, CTopMoversResponse, CRankListItem, CRankListResponse, CValuationHistoryPoint, CValuationComparisonItem, CValuationComparisonResponse; rebuild longbridge.h. C++: add matching structs to types.hpp and convert functions to convert.hpp; update market_context and fundamental_context to return typed responses. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… institution_rating_views, industry_rank, industry_peers, financial_report_snapshot) Implements the 6 missing C extern functions and corresponding C FFI types that were preventing the C++ SDK from building. The `longbridge.h` header is regenerated with all new `lb_*` type definitions and function declarations. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…xt.hpp Methods business_segments, business_segments_history, institution_rating_views, industry_rank, industry_peers, financial_report_snapshot were implemented in fundamental_context.cpp but missing from the header, causing C++ CI failures. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…l_report_snapshot The C function takes fiscal_year as const char*, not int32_t. Convert to string before passing; treat 0 as nullptr (omitted). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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
Adds 13 new APIs across 4 contexts, ported from longbridge-mcp PR #49 and longbridge-terminal PR #209.
All responses use typed structs — not raw JSON:
counter_idfields are converted to symbol format (e.g.ST/US/TSLA→TSLA.US)timestampfields are converted to RFC 3339 (e.g."1779202097"→"2026-05-19T14:48:17Z")short_positionsandshort_tradesuse unified US+HK structs with market-specific optional fieldsFundamentalContext (3 new methods)
shareholder_top(symbol)/v1/quote/shareholders/topshareholder_detail(symbol, object_id)/v1/quote/shareholders/holdingvaluation_comparison(symbol, currency, comparison_symbols?)/v1/quote/compare/valuationQuoteContext (1 extended + 1 new)
short_positions(symbol, count)/v1/quote/short-positions/hkor/usshort_trades(symbol, count)/v1/quote/short-trades/hkor/usMarketContext (3 new methods)
top_movers(markets, sort, date, limit)/v1/quote/market/stock-eventsstock_eventsrank_categories()/v1/quote/market/rank/categoriesrank_list(key, need_article)/v1/quote/market/rank/listScreenerContext (new context, 5 methods)
screener_recommend_strategies()/v1/quote/screener/strategies/recommendscreener_user_strategies()/v1/quote/screener/strategies/minescreener_strategy(id)/v1/quote/screener/strategyscreener_search(market, strategy_id?, page, size)/v1/quote/screener/searchscreener_indicators()/v1/quote/screener/indicatorsBreaking changes
MarketContext::stock_eventsrenamed totop_movers;StockEventsResponse→TopMoversResponseQuoteContext::hk_short_positionsremoved; useshort_positions(symbol, count)which auto-detects marketShortPositionsResponseis now typed (data: Vec<ShortPositionsItem>) instead of raw JSONLanguages
All 13 APIs implemented across Rust / Python / Node.js / Java / C / C++ with:
counter_id→ symbol conversionTest plan
cargo clippy --all --all-features✅cargo +nightly fmt --all✅npm run build:debug✅cargo build -p longbridge-c✅🤖 Generated with Claude Code