fix(screen): fetch the full list before sorting performers screens

MSN orders screener lists by 1-year return, but top/worst-performers
re-sort by day change after truncating to --limit. So `--limit 3` sorted
an arbitrary 3 stocks (worst-performers returned -1.33%, +0.25%, +0.95%)
and gave different stocks than `--limit 25`. Fetch the whole list for
these filters, as high-volume and large-cap already do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ld3fDSDiBzAaQvgZJX5NKM
This commit is contained in:
Claude 2026-10-02 14:35:00 +00:00
commit 8a294d6728
No known key found for this signature in database

View file

@ -613,9 +613,13 @@ pub fn handle(
} => {
let filter_key = screener_filter_key(filter)?;
let region_key = screener_region_key(region)?;
// For filters that fall back to topperfs, fetch all stocks so
// client-side sorting picks the correct top N.
let needs_full_fetch = matches!(filter.as_str(), "high-volume" | "large-cap");
// Filters re-sorted client-side need the whole MSN list: MSN orders
// by 1-year return, so truncating first and then sorting by day
// change made `--limit 3` return different stocks than `--limit 25`.
let needs_full_fetch = matches!(
filter.as_str(),
"high-volume" | "large-cap" | "top-performers" | "worst-performers"
);
let fetch_limit = if needs_full_fetch { 500 } else { *limit };
let bucket = cache_bucket(provider.kind(), "screen");
let key = format!("{filter}:{region}:{fetch_limit}");