calendar

package
v0.24.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Overview

Package calendar provides a client for the Longbridge Financial Calendar OpenAPI. It covers earnings reports, dividends, stock splits, IPOs, macro data releases, market closures, shareholder meetings, and stock mergers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalendarCategory

type CalendarCategory int

CalendarCategory identifies the type of financial calendar event to query.

const (
	// CalendarCategoryReport represents earnings report events.
	CalendarCategoryReport CalendarCategory = iota
	// CalendarCategoryDividend represents dividend distribution events.
	CalendarCategoryDividend
	// CalendarCategorySplit represents stock split events.
	CalendarCategorySplit
	// CalendarCategoryIpo represents initial public offering events.
	CalendarCategoryIpo
	// CalendarCategoryMacroData represents macro-economic data releases.
	CalendarCategoryMacroData
	// CalendarCategoryClosed represents market closure days.
	CalendarCategoryClosed
	// CalendarCategoryMeeting represents shareholder or analyst meeting events.
	CalendarCategoryMeeting
	// CalendarCategoryMerge represents stock consolidation or merger events.
	CalendarCategoryMerge
)

func (CalendarCategory) String

func (c CalendarCategory) String() string

String returns the API wire string for a CalendarCategory.

type CalendarContext

type CalendarContext struct {
	// contains filtered or unexported fields
}

CalendarContext is a client for the Longbridge Financial Calendar OpenAPI.

Example:

conf, err := config.NewFromEnv()
cctx, err := calendar.NewFromCfg(conf)
resp, err := cctx.FinanceCalendar(ctx, calendar.CalendarCategoryReport, "2025-05-01", "2025-05-31", nil)

func NewFromCfg

func NewFromCfg(cfg *config.Config) (*CalendarContext, error)

NewFromCfg creates a CalendarContext from a *config.Config.

func NewFromEnv

func NewFromEnv() (*CalendarContext, error)

NewFromEnv returns a CalendarContext configured from environment variables.

func (*CalendarContext) FinanceCalendar

func (c *CalendarContext) FinanceCalendar(
	ctx context.Context,
	category CalendarCategory,
	start string,
	end string,
	market *string,
) (*CalendarEventsResponse, error)

FinanceCalendar retrieves financial calendar events for a date range.

category selects the event type (earnings, dividend, split, IPO, etc.). 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

type CalendarDataKv

type CalendarDataKv struct {
	// Key label (may be empty)
	Key string
	// Formatted display value string
	Value string
	// Value type code, e.g. "estimate_eps"
	ValueType string
	// Raw numeric value; nil when the field is absent or non-numeric
	ValueRaw *decimal.Decimal
}

CalendarDataKv is one key-value data pair within a calendar event.

type CalendarDateGroup

type CalendarDateGroup struct {
	// Date string, e.g. "2025-05-02"
	Date string
	// Total event count for this date
	Count int32
	// Individual event records
	Infos []CalendarEventInfo
}

CalendarDateGroup holds all events for a single calendar date.

type CalendarEventInfo

type CalendarEventInfo struct {
	// Security symbol (converted from counter_id)
	Symbol string
	// Market identifier, e.g. "HK"
	Market string
	// Human-readable event content description
	Content string
	// Security name
	CounterName string
	// Date type label, e.g. "盘前" (pre-market)
	DateType string
	// Event date string, e.g. "2025.05.02"
	Date string
	// Chart UID (may be empty)
	ChartUID string
	// Structured key-value data attached to the event
	DataKV []CalendarDataKv
	// Event type code, e.g. "financial"
	EventType string
	// Event datetime as unix timestamp string
	Datetime string
	// Icon URL
	Icon string
	// Importance star rating, 0–3
	Star int32
	// Raw live stream JSON (usually nil)
	Live *json.RawMessage
	// Internal event ID
	ID string
	// Financial market session time string
	FinancialMarketTime string
	// Currency
	Currency string
	// Extended data (structure varies by event type; nil when absent)
	Ext *json.RawMessage
	// Activity type code
	ActivityType string
}

CalendarEventInfo represents one financial calendar event.

type CalendarEventsResponse

type CalendarEventsResponse struct {
	// Start date of the query window, e.g. "2025-05-01"
	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
}

CalendarEventsResponse is the top-level response from the finance_calendar endpoint.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL