alert

package
v0.24.1 Latest Latest
Warning

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

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

Documentation

Overview

Package alert provides a client for the Longbridge Price Alert OpenAPI. It covers listing, creating, updating, and deleting price alerts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertCondition

type AlertCondition int

AlertCondition represents the trigger condition for a price alert.

const (
	// AlertConditionPriceRise triggers when the price rises to a given value.
	AlertConditionPriceRise AlertCondition = 1
	// AlertConditionPriceFall triggers when the price falls to a given value.
	AlertConditionPriceFall AlertCondition = 2
	// AlertConditionPercentRise triggers when the percentage change rises to a given value.
	AlertConditionPercentRise AlertCondition = 3
	// AlertConditionPercentFall triggers when the percentage change falls to a given value.
	AlertConditionPercentFall AlertCondition = 4
)

type AlertContext

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

AlertContext is a client for the Longbridge Price Alert OpenAPI.

Example:

conf, err := config.NewFormEnv()
actx, err := alert.NewFromCfg(conf)
list, err := actx.List(context.Background())

func NewFromCfg

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

NewFromCfg creates an AlertContext from a *config.Config.

func NewFromEnv

func NewFromEnv() (*AlertContext, error)

NewFromEnv returns an AlertContext configured from environment variables.

func (*AlertContext) Add

func (c *AlertContext) Add(
	ctx context.Context,
	symbol string,
	condition AlertCondition,
	triggerValue string,
	frequency AlertFrequency,
) error

Add creates a new price alert.

Path: POST /v1/notify/reminders

func (*AlertContext) Delete

func (c *AlertContext) Delete(ctx context.Context, alertIDs []string) error

Delete removes one or more price alerts by their IDs.

Path: DELETE /v1/notify/reminders

func (*AlertContext) List

func (c *AlertContext) List(ctx context.Context) (*AlertList, error)

List returns all price alerts for the authenticated user.

Path: GET /v1/notify/reminders

func (*AlertContext) Update

func (c *AlertContext) Update(ctx context.Context, item *AlertItem) error

Update modifies an existing price alert in-place.

Requires the AlertItem obtained from List. Set item.Enabled to true to re-enable or false to disable. All required fields are taken directly from the item — no extra round-trip needed.

Path: POST /v1/notify/reminders

type AlertFrequency

type AlertFrequency int

AlertFrequency controls how often a triggered alert fires.

const (
	// AlertFrequencyDaily fires at most once per day.
	AlertFrequencyDaily AlertFrequency = 1
	// AlertFrequencyEveryTime fires every time the condition is met.
	AlertFrequencyEveryTime AlertFrequency = 2
	// AlertFrequencyOnce fires exactly once.
	AlertFrequencyOnce AlertFrequency = 3
)

type AlertItem

type AlertItem struct {
	// ID is the unique identifier for this alert.
	ID string
	// IndicatorID is the condition type code (matches AlertCondition values).
	IndicatorID string
	// Enabled indicates whether the alert is currently active.
	Enabled bool
	// Frequency controls how often the alert fires.
	Frequency int
	// Scope is an internal scope value.
	Scope int
	// Text is the human-readable description of the alert trigger (e.g. "价格涨到 600").
	Text string
	// State tracks the current trigger state.
	State []int
	// ValueMap holds the threshold values as raw JSON (e.g. {"price":"600"}).
	ValueMap json.RawMessage
}

AlertItem is a single price-alert configuration.

type AlertList

type AlertList struct {
	// Lists holds alert groups, one per security.
	Lists []*AlertSymbolGroup
}

AlertList is the top-level response containing groups of alerts per security.

type AlertSymbolGroup

type AlertSymbolGroup struct {
	// Symbol is the security identifier (e.g. "700.HK").
	Symbol string
	// Code is the short code of the security.
	Code string
	// Market is the market identifier (e.g. "HK").
	Market string
	// Name is the display name of the security.
	Name string
	// Price is the current price, if available.
	Price *decimal.Decimal
	// Chg is the price change, if available.
	Chg *decimal.Decimal
	// PChg is the percentage change, if available.
	PChg *decimal.Decimal
	// Product is the product type string (may be empty).
	Product string
	// Indicators is the list of individual alert items for this security.
	Indicators []*AlertItem
}

AlertSymbolGroup holds all price alerts for a single security.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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