sharelist

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: 12 Imported by: 0

Documentation

Overview

Package sharelist provides a client for the Longbridge community sharelist API. It covers listing, creating, deleting, and managing securities in sharelists.

Example:

cfg, err := config.NewFormEnv()
sctx, err := sharelist.NewFromCfg(cfg)
result, err := sctx.List(context.Background(), 20)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SharelistContext

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

SharelistContext is a client for the Longbridge Sharelist API.

func NewFromCfg

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

NewFromCfg creates a SharelistContext from a *config.Config.

func NewFromEnv

func NewFromEnv() (*SharelistContext, error)

NewFromEnv returns a SharelistContext configured from environment variables.

func (*SharelistContext) AddSecurities

func (c *SharelistContext) AddSecurities(ctx context.Context, id int64, symbols []string) error

AddSecurities adds one or more securities to a sharelist. Symbols should be in "CODE.MARKET" format, e.g. "TSLA.US" or "700.HK".

Path: POST /v1/sharelists/{id}/items

func (*SharelistContext) Create

func (c *SharelistContext) Create(ctx context.Context, name string, description string) error

Create creates a new sharelist with the given name and optional description. When description is empty the name is used as the description.

Path: POST /v1/sharelists

func (*SharelistContext) Delete

func (c *SharelistContext) Delete(ctx context.Context, id int64) error

Delete deletes a sharelist by ID.

Path: DELETE /v1/sharelists/{id}

func (*SharelistContext) Detail

func (c *SharelistContext) Detail(ctx context.Context, id int64) (*SharelistDetail, error)

Detail returns the full information for a sharelist, including constituents and quotes.

Path: GET /v1/sharelists/{id}

func (*SharelistContext) List

func (c *SharelistContext) List(ctx context.Context, count uint32) (*SharelistList, error)

List returns up to count of the user's own and subscribed sharelists.

Path: GET /v1/sharelists

func (*SharelistContext) Popular

func (c *SharelistContext) Popular(ctx context.Context, count uint32) (*SharelistList, error)

Popular returns up to count trending sharelists.

Path: GET /v1/sharelists/popular

func (*SharelistContext) RemoveSecurities

func (c *SharelistContext) RemoveSecurities(ctx context.Context, id int64, symbols []string) error

RemoveSecurities removes one or more securities from a sharelist. Symbols should be in "CODE.MARKET" format, e.g. "TSLA.US" or "700.HK".

Path: DELETE /v1/sharelists/{id}/items

func (*SharelistContext) SortSecurities

func (c *SharelistContext) SortSecurities(ctx context.Context, id int64, symbols []string) error

SortSecurities reorders the securities in a sharelist. The symbols slice defines the desired order; each symbol should be in "CODE.MARKET" format.

Path: POST /v1/sharelists/{id}/items/sort

type SharelistDetail

type SharelistDetail struct {
	// Sharelist holds the sharelist metadata and constituents.
	Sharelist SharelistInfo
	// Scopes holds subscription/ownership status for the authenticated user.
	Scopes SharelistScopes
}

SharelistDetail is the result of the Detail method.

type SharelistInfo

type SharelistInfo struct {
	// ID is the sharelist identifier.
	ID int64
	// Name is the display name of the sharelist.
	Name string
	// Description is a short description.
	Description string
	// Cover is the URL of the cover image.
	Cover string
	// SubscribersCount is the number of subscribers.
	SubscribersCount int64
	// CreatedAt is when the sharelist was created.
	CreatedAt time.Time
	// EditedAt is when the constituent list was last edited.
	EditedAt time.Time
	// ThisYearChg is the YTD change percentage; nil when not available.
	ThisYearChg *decimal.Decimal
	// Stocks holds the constituent securities.
	Stocks []SharelistStock
	// Subscribed is true when the authenticated user is subscribed.
	Subscribed bool
	// Chg is the day change percentage; nil when not available.
	Chg *decimal.Decimal
	// SharelistType classifies the sharelist (regular / official / industry).
	SharelistType SharelistType
	// IndustryCode is populated for industry-type sharelists.
	IndustryCode string
}

SharelistInfo holds metadata and constituent stocks for a sharelist.

type SharelistList

type SharelistList struct {
	// Sharelists contains the user's own sharelists (and, for Popular, the
	// trending sharelists).
	Sharelists []SharelistInfo
	// SubscribedSharelists contains sharelists the user is subscribed to.
	// This field may be empty when returned by Popular.
	SubscribedSharelists []SharelistInfo
	// TailMark is the pagination cursor for the subscribed list.
	TailMark string
}

SharelistList is the result of the List and Popular methods.

type SharelistScopes

type SharelistScopes struct {
	// Subscription is true when the authenticated user is subscribed.
	Subscription bool
	// IsSelf is true when the authenticated user is the creator.
	IsSelf bool
}

SharelistScopes holds subscription and ownership status for the current user.

type SharelistStock

type SharelistStock struct {
	// Symbol is the security identifier, e.g. "TSLA.US" or "700.HK".
	// It is converted from the wire-level counter_id field.
	Symbol string
	// Name is the display name of the security.
	Name string
	// Market is the exchange market code, e.g. "HK" or "US".
	Market string
	// Code is the ticker code.
	Code string
	// Intro is a brief description.
	Intro string
	// UnreadChangeLogCategory is the unread change log category.
	UnreadChangeLogCategory string
	// Change is the day change percentage; nil when not available.
	Change *decimal.Decimal
	// LastDone is the latest price; nil when not available.
	LastDone *decimal.Decimal
	// TradeStatus is the trade status code; nil when not available.
	TradeStatus *int32
	// Latency indicates a delayed quote when true; nil when not available.
	Latency *bool
}

SharelistStock describes a security within a sharelist.

type SharelistType

type SharelistType int32

SharelistType represents the kind of sharelist.

const (
	// SharelistTypeRegular is a regular user sharelist.
	SharelistTypeRegular SharelistType = 0
	// SharelistTypeOfficial is an officially curated sharelist.
	SharelistTypeOfficial SharelistType = 3
	// SharelistTypeIndustry is an industry-themed sharelist.
	SharelistTypeIndustry SharelistType = 4
)

Directories

Path Synopsis
Package jsontypes contains raw JSON response structs for the Longbridge Sharelist API.
Package jsontypes contains raw JSON response structs for the Longbridge Sharelist API.

Jump to

Keyboard shortcuts

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