Documentation
¶
Overview ¶
Package screener provides a client for the Longbridge Screener OpenAPI. It covers stock screener strategies, indicator search, and pre-defined recommendation strategies.
Package screener provides a client for the Longbridge Screener OpenAPI. It covers stock screener strategies, indicator search, and pre-defined recommendation strategies.
Index ¶
- type RecommendStrategiesResponse
- type ScreenerCondition
- type ScreenerContext
- func (c *ScreenerContext) ScreenerIndicators(ctx context.Context) (*ScreenerIndicatorsResponse, error)
- func (c *ScreenerContext) ScreenerRecommendStrategies(ctx context.Context, market string) (*RecommendStrategiesResponse, error)
- func (c *ScreenerContext) ScreenerSearch(ctx context.Context, market string, strategyID *int64, ...) (*ScreenerSearchResponse, error)
- func (c *ScreenerContext) ScreenerStrategy(ctx context.Context, id int64) (*StrategyResponse, error)
- func (c *ScreenerContext) ScreenerUserStrategies(ctx context.Context, market string) (*UserStrategiesResponse, error)
- type ScreenerIndicatorsResponse
- type ScreenerSearchResponse
- type StrategyResponse
- type UserStrategiesResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RecommendStrategiesResponse ¶
type RecommendStrategiesResponse struct {
Data json.RawMessage `json:"data"`
}
RecommendStrategiesResponse holds the raw data for recommended screener strategies from GET /v1/quote/ai/screener/strategies/recommend.
type ScreenerCondition ¶
type ScreenerCondition struct {
// Key is the indicator key without "filter_" prefix, e.g. "pettm", "roe", "macd_day".
Key string `json:"key"`
// Min is the lower bound (empty string = no lower bound).
Min string `json:"min"`
// Max is the upper bound (empty string = no upper bound).
Max string `json:"max"`
// TechValues holds technical indicator params (nil map for fundamental indicators).
// Example: {"category": "goldenfork", "period": "day"}
TechValues map[string]string `json:"tech_values,omitempty"`
}
ScreenerCondition is a filter condition for ScreenerSearch Mode B.
type ScreenerContext ¶
type ScreenerContext struct {
// contains filtered or unexported fields
}
ScreenerContext is a client for the Longbridge Screener OpenAPI.
Example:
conf, err := config.NewFromEnv() sctx, err := screener.NewFromCfg(conf) recs, err := sctx.ScreenerRecommendStrategies(context.Background(), "US")
func NewFromCfg ¶
func NewFromCfg(cfg *config.Config) (*ScreenerContext, error)
NewFromCfg creates a ScreenerContext from a *config.Config.
func NewFromEnv ¶
func NewFromEnv() (*ScreenerContext, error)
NewFromEnv returns a ScreenerContext configured from environment variables.
func (*ScreenerContext) ScreenerIndicators ¶
func (c *ScreenerContext) ScreenerIndicators(ctx context.Context) (*ScreenerIndicatorsResponse, error)
ScreenerIndicators fetches the list of available screener indicators.
Path: GET /v1/quote/ai/screener/indicators
Post-processing applied before returning:
- "filter_" prefix is stripped from every groups[].indicators[].key
- tech_values is built from tech_indicators: {tech_key: [{value, label}]}
func (*ScreenerContext) ScreenerRecommendStrategies ¶
func (c *ScreenerContext) ScreenerRecommendStrategies(ctx context.Context, market string) (*RecommendStrategiesResponse, error)
ScreenerRecommendStrategies fetches the list of recommended screener strategies.
Path: GET /v1/quote/ai/screener/strategies/recommend
func (*ScreenerContext) ScreenerSearch ¶
func (c *ScreenerContext) ScreenerSearch( ctx context.Context, market string, strategyID *int64, conditions []ScreenerCondition, show []string, page, size uint32, ) (*ScreenerSearchResponse, error)
ScreenerSearch executes a screener search.
Path: POST /v1/quote/ai/screener/search
market is the market code, e.g. "US" or "HK". strategyID is optional; pass nil to use custom conditions instead. conditions is a list of "KEY:MIN:MAX" strings used in Mode B (strategyID == nil). show is an optional list of extra return columns to include. page is 0-indexed; size is the page size.
Mode A (strategyID given): the strategy is fetched from GET /v1/quote/ai/screener/strategy/{id}, its filter.filters[] are forwarded to the search endpoint, and market is taken from the strategy response.
Mode B (strategyID nil): conditions drive the filters and the supplied market is used directly.
The "filter_" prefix is stripped from every items[].indicators[].key in the response before it is returned.
func (*ScreenerContext) ScreenerStrategy ¶
func (c *ScreenerContext) ScreenerStrategy(ctx context.Context, id int64) (*StrategyResponse, error)
ScreenerStrategy fetches a single screener strategy by ID.
Path: GET /v1/quote/ai/screener/strategy/{id}
The "filter_" prefix is stripped from every filters[].key before returning so callers see clean keys like "pettm" instead of "filter_pettm".
func (*ScreenerContext) ScreenerUserStrategies ¶
func (c *ScreenerContext) ScreenerUserStrategies(ctx context.Context, market string) (*UserStrategiesResponse, error)
ScreenerUserStrategies fetches the current user's saved screener strategies.
Path: GET /v1/quote/ai/screener/strategies/mine
type ScreenerIndicatorsResponse ¶
type ScreenerIndicatorsResponse struct {
Data json.RawMessage `json:"data"`
}
ScreenerIndicatorsResponse holds the raw list of screener indicators from GET /v1/quote/ai/screener/indicators.
type ScreenerSearchResponse ¶
type ScreenerSearchResponse struct {
Data json.RawMessage `json:"data"`
}
ScreenerSearchResponse holds the raw search results from POST /v1/quote/ai/screener/search.
type StrategyResponse ¶
type StrategyResponse struct {
Data json.RawMessage `json:"data"`
}
StrategyResponse holds the raw data for a single screener strategy from GET /v1/quote/ai/screener/strategy/{id}.
type UserStrategiesResponse ¶
type UserStrategiesResponse struct {
Data json.RawMessage `json:"data"`
}
UserStrategiesResponse holds the raw data for the current user's screener strategies from GET /v1/quote/ai/screener/strategies/mine.