Longbridge.ContentContext (longbridge v0.1.0)

Copy Markdown View Source

Content context.

Provides access to community topics, replies, and per-symbol news. The per-symbol endpoints (news/3, topics/3) take a stock symbol; the topic-management endpoints (my_topics/2, create_topic/2, topic_detail/2, list_topic_replies/3, create_topic_reply/3) operate on the current authenticated user.

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

Usage

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

{:ok, news} = Longbridge.ContentContext.news(config, "AAPL.US")
{:ok, mine} = Longbridge.ContentContext.my_topics(config, page: 1)
{:ok, id}   = Longbridge.ContentContext.create_topic(config, title: "...", body: "...")
{:ok, replies} = Longbridge.ContentContext.list_topic_replies(config, "topic-id", page: 1)

Summary

Functions

Lists company announcements for a symbol.

Creates a new community topic.

Lists topics created by the current authenticated user.

Lists news articles for a symbol.

Returns details for a single topic by ID.

Lists community topics for a symbol.

Functions

announcements(config, symbol)

@spec announcements(Longbridge.Config.t(), String.t()) :: {:error, :not_implemented}

Lists company announcements for a symbol.

The upstream OpenAPI does not currently expose announcements as a REST endpoint; the topic listing (topics/2) is the closest equivalent.

Returns {:error, :not_implemented} to make the absence explicit.

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

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

Creates a new community topic.

Endpoint: POST /v1/content/topics

Returns {:ok, topic_id} on success.

Required options

  • :title — topic title string.
  • :body — topic body in Markdown.

Optional

  • :topic_type"article" (long-form) or "post" (default short).
  • :tickers — list of related symbols, max 10.
  • :hashtags — list of hashtag names, max 5.

create_topic_reply(config, topic_id, opts, http_opts \\ [])

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

Posts a reply to a topic.

Endpoint: POST /v1/content/topics/{topic_id}/comments

Required options

  • :body — reply text (plain text only, Markdown not rendered).

Optional

  • :reply_to_id — ID of a reply to respond to (omit for top-level reply).

list_topic_replies(config, topic_id, opts \\ [], http_opts \\ [])

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

Lists replies on a topic.

Endpoint: GET /v1/content/topics/{topic_id}/comments

Options

  • :page — integer page number, default 1.
  • :size — integer records per page, range 1..50, default 20.

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

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

Lists topics created by the current authenticated user.

Endpoint: GET /v1/content/topics/mine

Options

  • :page — integer page number, default 1.
  • :size — integer records per page, range 1..500, default 50.
  • :topic_type"article" | "post", optional filter.

news(config, symbol, opts \\ [], http_opts \\ [])

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

Lists news articles for a symbol.

symbol is required (e.g. "AAPL.US", "700.HK").

Options

  • :lang — language ("zh-CN", "zh-HK", "en")

topic_detail(config, id, opts \\ [])

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

Returns details for a single topic by ID.

Endpoint: GET /v1/content/topics/{id}

topics(config, symbol, opts \\ [], http_opts \\ [])

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

Lists community topics for a symbol.

symbol is required.

Options

  • :page — page cursor
  • :page_size — results per page