Skip to content

feat: add shareholders, screener, short-trades, rank, top-movers, valuation-comparison APIs#92

Merged
hogan-yuan merged 7 commits into
mainfrom
feat/shareholders-screener-short-trades-rank
May 22, 2026
Merged

feat: add shareholders, screener, short-trades, rank, top-movers, valuation-comparison APIs#92
hogan-yuan merged 7 commits into
mainfrom
feat/shareholders-screener-short-trades-rank

Conversation

@hogan-yuan
Copy link
Copy Markdown
Member

@hogan-yuan hogan-yuan commented May 20, 2026

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_id fields converted to symbol format (e.g. ST/US/TSLATSLA.US)
  • timestamp fields converted to RFC 3339 (e.g. "2026-05-19T14:48:17Z")
  • ShortPositions / ShortTrades use unified US+HK structs with market-specific optional fields

FundamentalContext (3 new methods)

Method Endpoint
ShareholderTop(ctx, symbol) GET /v1/quote/shareholders/top
ShareholderDetail(ctx, symbol, objectID) GET /v1/quote/shareholders/holding
ValuationComparison(ctx, symbol, currency, comparisonSymbols) GET /v1/quote/compare/valuation

QuoteContext (1 extended + 1 new)

Method Endpoint Notes
ShortPositions(ctx, symbol, count) GET /v1/quote/short-positions/hk or /us Extended: unified HK+US, typed struct, RFC 3339 timestamps
ShortTrades(ctx, symbol, count) GET /v1/quote/short-trades/hk or /us New; auto-detects market

MarketContext (3 new methods)

Method Endpoint Notes
TopMovers(ctx, markets, sort, date, limit) POST /v1/quote/market/stock-events Renamed from StockEvents
RankCategories(ctx) GET /v1/quote/market/rank/categories New
RankList(ctx, key, needArticle) GET /v1/quote/market/rank/list New

ScreenerContext (new package, 5 methods)

Method Endpoint
ScreenerRecommendStrategies(ctx) GET /v1/quote/screener/strategies/recommend
ScreenerUserStrategies(ctx) GET /v1/quote/screener/strategies/mine
ScreenerStrategy(ctx, id) GET /v1/quote/screener/strategy
ScreenerSearch(ctx, market, strategyID, page, size) POST /v1/quote/screener/search
ScreenerIndicators(ctx) GET /v1/quote/screener/indicators

Breaking changes

  • MarketContext.StockEvents renamed to TopMovers; StockEventsResponseTopMoversResponse
  • HkShortPositions removed; use ShortPositions(ctx, symbol, count) which auto-detects market
  • ShortPositionsResponse is now {Data []*ShortPositionsItem} (typed) instead of raw JSON

Test plan

  • go build ./...
  • go vet ./...
  • Go 7/7 typed struct live API tests pass ✅
  • Python 13/13 live API tests pass (via Rust SDK) ✅

🤖 Generated with Claude Code

hogan-yuan and others added 5 commits May 21, 2026 13:45
…ank APIs

- fundamental: ShareholderTop, ShareholderDetail, ValuationComparison (3 new methods)
- quote: HkShortPositions, ShortTrades with auto market detection (2 new methods)
- market: StockEvents (POST), RankCategories, RankList (3 new methods)
- screener: new package with ScreenerContext — RecommendStrategies,
  UserStrategies, Strategy, Search, Indicators (5 new methods)

All responses use json.RawMessage for forward-compatible raw data access.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…fied)

short_positions now auto-detects market from symbol suffix:
- .HK → GET /v1/quote/short-positions/hk (HKEX daily data)
- other → GET /v1/quote/short-positions/us (FINRA bi-monthly data)

Response is ShortPositionsResponse{Data json.RawMessage} since HK and US
have different shapes. HkShortPositions and ShortPositionStats removed.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ata APIs

The Go HTTP client already extracts the `data` field from the API envelope
before deserializing into the target struct. Wrapping in an intermediate
struct with `json:"data"` caused double-unwrapping, producing null Data.

Fix: use json.RawMessage directly as the deserialization target in
ShareholderTop, ShareholderDetail, ValuationComparison, StockEvents,
RankCategories, RankList, all screener methods.
Also add missing json:"data" tags to market/types.go and screener/types.go
response structs.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Renames method and response type:
- `StockEvents` → `TopMovers` (method on MarketContext)
- `StockEventsResponse` → `TopMoversResponse` (response type)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hogan-yuan hogan-yuan force-pushed the feat/shareholders-screener-short-trades-rank branch from 3f9e1b3 to a18b1ca Compare May 21, 2026 05:46
hogan-yuan and others added 2 commits May 21, 2026 15:24
Replace json.RawMessage returns with typed structs across 5 new APIs:
- ShortPositions/ShortTrades: []*ShortPositionsItem / []*ShortTradesItem
  with unified US+HK fields, timestamp → RFC 3339
- RankList: RankListResponse{Bmp, Lists []*RankListItem}, counter_id → symbol
- TopMovers: TopMoversResponse{Events []*TopMoversEvent, NextParams},
  counter_id → symbol, timestamp → RFC 3339
- ValuationComparison: ValuationComparisonResponse{List []*ValuationComparisonItem},
  counter_id → symbol, history date → RFC 3339

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 use an outer struct, then extract inner data.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hogan-yuan hogan-yuan changed the title feat: add shareholders, screener, short-trades, rank, stock-events, valuation-comparison APIs feat: add shareholders, screener, short-trades, rank, top-movers, valuation-comparison APIs May 21, 2026
@hogan-yuan hogan-yuan marked this pull request as ready for review May 21, 2026 12:05
@hogan-yuan hogan-yuan merged commit 7011d3e into main May 22, 2026
hogan-yuan added a commit to longbridge/developers that referenced this pull request May 22, 2026
…cs + CLI v0.22.0 release notes (#1013)

## Summary

SDK documentation and CLI release notes for 13 new APIs. Branch cut from
main.

Related SDK PRs: [openapi
#527](longbridge/openapi#527), [openapi-go
#92](longbridge/openapi-go#92)

### New SDK docs (3 locales: zh-CN, zh-HK, en)

**FundamentalContext:** `shareholder_top`, `shareholder_detail`,
`valuation_comparison`

**MarketContext:** `stock_events`, `rank_categories`, `rank_list`

**QuoteContext:** `short_positions` (updated to US+HK unified),
`short_trades` (new)

**New ScreenerContext:** `screener_recommend_strategies`,
`screener_user_strategies`, `screener_strategy`, `screener_search`,
`screener_indicators`

### CLI v0.22.0 release notes
`shareholder --top/--object-id`, `short-trades`, `compare`,
`top-movers`, `screener`, `rank`

## Test plan
- [ ] `autocorrect --lint docs/` — No issues ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

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