Skip to content

cli: Honor --count in rank - #336

Merged
hogan-yuan merged 1 commit into
mainfrom
fix/rank-count
Oct 12, 2026
Merged

hogan-yuan merged 1 commit into
mainfrom
fix/rank-count

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Problem

longbridge rank --key <key> --count N ignores --count (alias --limit, default 20) and always prints the whole board: rank --key hot_all-us --count 2 --format json returns 50 rows on 0.29.0, and the code on main is unchanged.

Root cause

GET /v1/quote/market/rank/list has no page-size parameter; it accepts only key and need_article (per the API reference; the Rust and Go SDKs' rank_list expose no size either). The size we forwarded was dropped, and the response was printed as-is.

Fix

Stop sending size; truncate lists to --count locally before rendering, so both --format json and the table honor it.

Verification

  • New unit test test_truncate_rank_lists.
  • Against production with a local build:
    • rank --key hot_all-us --count 2 --format json → 2 rows (was 50)
    • rank --key hot_all-us --format json → 20 rows (the documented default; was 50)
    • rank --key hot_all-us --count 3 → 3-row table
  • cargo clippy reports the same 49 pre-existing pedantic errors before and after this change (local clippy 0.1.99); none are in the changed lines.

Same issue was fixed in longbridge-mcp in longbridge/longbridge-mcp#169.

🤖 Generated with Claude Code

GET /v1/quote/market/rank/list takes no page-size parameter (only key and
need_article), so the `size` we forwarded was dropped and `rank --key`
always printed the whole board (typically 50 rows) regardless of --count.

Stop sending `size` and truncate `lists` to --count locally, for both the
JSON and table output.
@hogan-yuan
hogan-yuan merged commit 9120d0f into main Oct 12, 2026
1 check passed
@hogan-yuan
hogan-yuan deleted the fix/rank-count branch October 12, 2026 10:06
hogan-yuan added a commit that referenced this pull request Oct 26, 2026
Bump `0.30.0` → `0.31.0` for release.

## Included since v0.30.0
- **Longbridge US accounts** (#337): `assets`, `portfolio`, `positions`,
`cash-flow`, `exchange-rate`, `order` (today and `--history`) and `order
detail` call the US asset and order APIs for US accounts, built on
longbridge SDK 5.3.0. Their `--format json` output keeps the AP keys and
shape; US-only fields are marked `(US only)` in `--schema`, and `check
--format json` reports `dc_region`.
- **`order executions` on US accounts** (#337): history comes from
`/v1/trade/execution/history`, which is not filtered by execution time
and can lag across days; `side` is filled from the account's orders and
shows `Unknown` when it can't be resolved.
- **AP-only commands and `serve` methods** (#337): `fund-positions` and
`margin-ratio` on a US account fail before sending a request and name
the alternative; `serve` gains `trade.us_query_orders` and
`trade.us_order_detail`.
- **Safer US cancel / replace** (#337): the preview refuses to issue a
confirmation code when the order can't be fetched, and US order ids must
be digits.
- **`rank --count`** (#336) is honored.

Tag `v0.31.0` after merge to trigger the release build.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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