Skip to content

feat: add shareholders, screener, short-trades, rank, stock-events, valuation-comparison APIs#527

Draft
hogan-yuan wants to merge 4 commits into
mainfrom
feat/shareholders-screener-short-trades-rank
Draft

feat: add shareholders, screener, short-trades, rank, stock-events, valuation-comparison APIs#527
hogan-yuan wants to merge 4 commits into
mainfrom
feat/shareholders-screener-short-trades-rank

Conversation

@hogan-yuan
Copy link
Copy Markdown
Member

Summary

Ports 13 new APIs from longbridge-mcp PR #49 and longbridge-terminal PR #209.

FundamentalContext (3 new methods)

  • shareholder_top(symbol) — GET /v1/quote/shareholders/top
  • shareholder_detail(symbol, object_id) — GET /v1/quote/shareholders/holding
  • valuation_comparison(symbol, currency, comparison_symbols) — GET /v1/quote/compare/valuation

QuoteContext (2 new methods)

  • hk_short_positions(symbol, count) — GET /v1/quote/short-positions/hk
  • short_trades(symbol, count) — GET /v1/quote/short-trades/hk or /us (auto-detected)

MarketContext (3 new methods)

  • stock_events(markets, sort, date, limit) — POST /v1/quote/market/stock-events
  • rank_categories() — GET /v1/quote/market/rank/categories
  • rank_list(key, need_article) — GET /v1/quote/market/rank/list

New ScreenerContext (5 methods)

  • screener_recommend_strategies() — GET /v1/quote/screener/strategies/recommend
  • screener_user_strategies() — GET /v1/quote/screener/strategies/mine
  • screener_strategy(id) — GET /v1/quote/screener/strategy
  • screener_search(market, strategy_id, page, size) — POST /v1/quote/screener/search
  • screener_indicators() — GET /v1/quote/screener/indicators

Test plan

  • cargo clippy --all --all-features
  • cargo +nightly fmt --all
  • Runtime tests against production API

🤖 Generated with Claude Code

- 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>
hogan-yuan and others added 2 commits May 20, 2026 15:51
… 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>
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