Skip to content

fix(calendar): expose next_date cursor and fix counter_id → symbol conversion#95

Merged
hogan-yuan merged 9 commits into
mainfrom
fix/finance-calendar-pagination
Jun 2, 2026
Merged

fix(calendar): expose next_date cursor and fix counter_id → symbol conversion#95
hogan-yuan merged 9 commits into
mainfrom
fix/finance-calendar-pagination

Conversation

@hogan-yuan
Copy link
Copy Markdown
Member

@hogan-yuan hogan-yuan commented Jun 2, 2026

Summary

Fix 1 — CalendarEventsResponse.NextDate

The /v1/quote/finance_calendar endpoint paginates via a next_date cursor, but the SDK was silently dropping it. A multi-day range query returns only the first page, causing events on later pages (e.g. CRM.US, PDD.US, MRVL.US for a 2026-05-23→05-30 range) to be missing.

NextDate is now returned as-is in CalendarEventsResponse. When non-empty, pass it as start (keeping the same end) to fetch the next page.

Fix 2 — counter_id → symbol conversion

Two fields were returning raw counter_id format (e.g. ST/US/CRM) instead of the standard symbol format (CRM.US):

  • calendar.CalendarEventInfo.Symbol
  • quote.DailyOptionVolume.Symbol (from underlying_counter_id)

A shared internal/counter.IDToSymbol helper is introduced; sharelist is migrated to use it instead of its local copy.

Changes

File Change
calendar/jsontypes/types.go Add NextDate to raw response type
calendar/types.go Add NextDate to public CalendarEventsResponse
calendar/context.go Pass NextDate through; convert Symbol via counter.IDToSymbol
quote/context.go Convert DailyOptionVolume.Symbol via counter.IDToSymbol
internal/counter/counter.go New shared IDToSymbol helper
internal/counter/counter_test.go Unit tests for US/HK/SH/SZ/index formats
sharelist/context.go Migrate to shared counter.IDToSymbol

Related

hogan-yuan and others added 9 commits June 2, 2026 09:50
… results

The /v1/quote/finance_calendar endpoint paginates via a next_date cursor.
Previously only the first page was returned, causing events on later pages
(e.g. CRM.US, PDD.US, MRVL.US for a 2026-05-23→05-30 range) to be silently
dropped.

- Add next_date to jsontypes.CalendarEventsResponse
- Loop in FinanceCalendar until next_date is empty, merging all pages
- Deduplicate events by ID across pages

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The /v1/quote/finance_calendar endpoint paginates via a next_date cursor.
Previously next_date was silently dropped, making it impossible for callers
to fetch subsequent pages. Now NextDate is returned as-is so callers can
follow the cursor themselves.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CalendarEventInfo.Symbol was returned as raw counter_id (e.g. ST/US/CRM)
instead of the standard symbol format (CRM.US). Added a shared
internal/counter package with IDToSymbol and updated the calendar converter
to apply it. sharelist was also updated to use the shared helper instead of
its local copy.

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

Three fields were returning raw counter_id format (e.g. ST/US/CRM) instead
of symbol format (CRM.US):

- quote.DailyOptionVolume.Symbol (from underlying_counter_id)
- fundamental.IndustryRankItem.CounterID
- fundamental.IndustryPeerNode.CounterID

Also migrate fundamental/context.go off its local counterIDToSymbol to the
shared internal/counter.IDToSymbol helper.

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

These are industry-level counter IDs, not stock symbols, so conversion
to symbol format is not appropriate.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Clarify FinanceCalendar pagination doc: "keeping the same end"
- Remove fmt import from internal/counter, use string concat
- Add unit tests for counter.IDToSymbol

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hogan-yuan hogan-yuan merged commit 4cc028a into main Jun 2, 2026
@hogan-yuan hogan-yuan changed the title fix(calendar): expose next_date cursor in FinanceCalendar response fix(calendar): expose next_date cursor and fix counter_id → symbol conversion Jun 2, 2026
@hogan-yuan hogan-yuan mentioned this pull request Jun 2, 2026
hogan-yuan added a commit that referenced this pull request Jun 2, 2026
## Summary

Add CHANGELOG entry for v0.24.2.

## Changes in v0.24.2

### Fixed

- `calendar.CalendarEventsResponse`: expose `NextDate` cursor so callers
can follow pagination (`/v1/quote/finance_calendar` returns results
across multiple pages via `next_date`)
- `calendar.CalendarEventInfo.Symbol`: convert raw `counter_id` (e.g.
`ST/US/CRM`) to standard symbol format (`CRM.US`)
- `quote.DailyOptionVolume.Symbol`: convert `underlying_counter_id` to
symbol format

### Changed

- Add `internal/counter.IDToSymbol` as shared `counter_id` → symbol
conversion helper; `sharelist` migrated to use it

## Related

- #95
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