Longbridge.CalendarContext (longbridge v0.1.0)

Copy Markdown View Source

Financial calendar context.

Provides earnings, dividends, splits, IPOs, macroeconomic events and market closures, all served from the upstream GET /v1/quote/finance_calendar endpoint.

The endpoint is paginated: when the response carries a non-empty next_date, pass it as start_date to fetch the next page.

All functions accept a Longbridge.Config struct and return {:ok, data} | {:error, reason} tuples.

Usage

config = Longbridge.Config.new(...)

{:ok, earnings} =
  Longbridge.CalendarContext.earnings(config, "2024-01-01", "2024-06-30", market: "US")

Summary

Functions

dividend_dates(config, start_date, end_date, opts \\ [], http_opts \\ [])

@spec dividend_dates(
  Longbridge.Config.t(),
  String.t(),
  String.t(),
  keyword(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Lists upcoming dividend dates.

earnings(config, start_date, end_date, opts \\ [], http_opts \\ [])

@spec earnings(Longbridge.Config.t(), String.t(), String.t(), keyword(), keyword()) ::
  {:ok, map()} | {:error, term()}

Lists earnings announcement dates.

start_date and end_date are "YYYY-MM-DD" strings.

Options

  • :market"US", "HK", "CN", "SG"

Trailing http_opts is forwarded to HTTPClient.request_json/5, so callers may override :http_url, :finch, etc. on a per-call basis.

ipo_calendar(config, start_date, end_date, opts \\ [], http_opts \\ [])

@spec ipo_calendar(
  Longbridge.Config.t(),
  String.t(),
  String.t(),
  keyword(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Lists IPO calendar entries.

macro_events(config, start_date, end_date, opts \\ [], http_opts \\ [])

@spec macro_events(
  Longbridge.Config.t(),
  String.t(),
  String.t(),
  keyword(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Lists macroeconomic event dates (CPI, GDP, Fed meetings, etc.).

market_closures(config, opts \\ [], http_opts \\ [])

@spec market_closures(Longbridge.Config.t(), keyword(), keyword()) ::
  {:ok, map()} | {:error, term()}

Lists market closure dates (holidays, half-days).

The upstream calendar endpoint does not accept a date range for closures; pass market to scope by region.

stock_splits(config, start_date, end_date, opts \\ [], http_opts \\ [])

@spec stock_splits(
  Longbridge.Config.t(),
  String.t(),
  String.t(),
  keyword(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Lists upcoming stock splits.