Price alert context.
Manages price alerts: add, list, enable, disable, and delete.
All functions accept a Longbridge.Config struct and return
{:ok, data} | {:error, reason} tuples.
Usage
config = Longbridge.Config.new(...)
{:ok, alert} = Longbridge.AlertContext.add_alert(config,
symbol: "AAPL.US",
price: "150.00",
direction: :above
)
Summary
Functions
Creates a new price alert.
Deletes one or more price alerts by ID.
Disables a price alert by alert_id.
Enables a price alert by alert_id.
Lists all active price alerts.
Updates a price alert — flips its enabled flag and re-sends all
required fields (indicator_id, frequency, scope, state,
value_map) so the server doesn't reject with
"invalid frequency" / "invalid indicator id".
Functions
@spec add_alert(Longbridge.Config.t(), keyword(), keyword()) :: {:ok, map()} | {:error, term()}
Creates a new price alert.
Options
:symbol— stock symbol (required):price— trigger price (required):direction—:aboveor:below(required):remark— optional note
@spec delete_alert(Longbridge.Config.t(), String.t() | [String.t()], keyword()) :: {:ok, map()} | {:error, term()}
Deletes one or more price alerts by ID.
Endpoint: DELETE /v1/notify/reminders
Accepts a single alert_id string or a list of alert_id strings.
Pass a list for batch delete (matches upstream 4.1.0+).
@spec disable_alert(Longbridge.Config.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}
Disables a price alert by alert_id.
Deprecated: use update/3 instead. See enable_alert/2 for the
upstream bug.
@spec enable_alert(Longbridge.Config.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}
Enables a price alert by alert_id.
Deprecated: use update/3 instead. The old enable/disable methods
send incomplete alert payloads, which the server now rejects with
"invalid frequency" / "invalid indicator id" for alerts created
through add_alert/2. update/3 re-sends the full item to avoid
the rejection.
@spec list_alerts( Longbridge.Config.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Lists all active price alerts.
Updates a price alert — flips its enabled flag and re-sends all
required fields (indicator_id, frequency, scope, state,
value_map) so the server doesn't reject with
"invalid frequency" / "invalid indicator id".
Pass the full alert item from list_alerts/1. The enabled key
on item is the only field consulted as input — all other fields
are forwarded verbatim to match upstream semantics.
Endpoint: POST /v1/notify/reminders
Added in longbridge/openapi 4.1.0 as a replacement for the old
enable/disable methods.