Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
**/*.env
go.work
go.work.sum
test_new_apis
cmd/test_new_apis
11 changes: 8 additions & 3 deletions calendar/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/longbridge/openapi-go/calendar/jsontypes"
"github.com/longbridge/openapi-go/config"
httplib "github.com/longbridge/openapi-go/http"
"github.com/longbridge/openapi-go/internal/counter"
)

// CalendarContext is a client for the Longbridge Financial Calendar OpenAPI.
Expand Down Expand Up @@ -49,6 +50,9 @@ func NewFromEnv() (*CalendarContext, error) {
// start and end are date strings in "YYYY-MM-DD" format.
// market is optional; pass nil or an empty string to retrieve all markets.
//
// The endpoint is paginated via NextDate. When the returned NextDate is
// non-empty, pass it as start (keeping the same end) to fetch the next page.
//
// Reference: GET /v1/quote/finance_calendar
func (c *CalendarContext) FinanceCalendar(
ctx context.Context,
Expand Down Expand Up @@ -77,8 +81,9 @@ func (c *CalendarContext) FinanceCalendar(

func convertCalendarEventsResponse(raw *jsontypes.CalendarEventsResponse) (*CalendarEventsResponse, error) {
resp := &CalendarEventsResponse{
Date: raw.Date,
List: make([]CalendarDateGroup, 0, len(raw.List)),
Date: raw.Date,
NextDate: raw.NextDate,
List: make([]CalendarDateGroup, 0, len(raw.List)),
}
for _, rg := range raw.List {
grp, err := convertCalendarDateGroup(&rg)
Expand Down Expand Up @@ -108,7 +113,7 @@ func convertCalendarDateGroup(raw *jsontypes.CalendarDateGroup) (*CalendarDateGr

func convertCalendarEventInfo(raw *jsontypes.CalendarEventInfo) (*CalendarEventInfo, error) {
info := &CalendarEventInfo{
Symbol: raw.Symbol,
Symbol: counter.IDToSymbol(raw.Symbol),
Market: raw.Market,
Content: raw.Content,
CounterName: raw.CounterName,
Expand Down
2 changes: 2 additions & 0 deletions calendar/jsontypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type CalendarEventsResponse struct {
Date string `json:"date"`
// Per-day event groups
List []CalendarDateGroup `json:"list"`
// Next page cursor; empty string means no more pages
NextDate string `json:"next_date"`
}

// CalendarDateGroup holds all events for a single calendar date.
Expand Down
2 changes: 2 additions & 0 deletions calendar/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type CalendarEventsResponse struct {
Date string
// Per-day event groups
List []CalendarDateGroup
// Pagination cursor; pass as start to fetch the next page, empty when there are no more pages
NextDate string
}

// CalendarDateGroup holds all events for a single calendar date.
Expand Down
Loading