Longbridge Developers
立即开始

获取股价提醒列表

获取当前用户的所有股价提醒,支持按标的筛选。

>_ CLI
longbridge alert
longbridge alert TSLA.US

Parameters

SDK 方法参数。

NameTypeRequiredDescription
symbolstring否按证券代码筛选,例如 TSLA.US

Request Example

from longbridge.openapi import AlertContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = AlertContext(config)

resp = ctx.list_alerts()
print(resp)
import asyncio
from longbridge.openapi import AsyncAlertContext, Config, OAuthBuilder

async def main() -> None:
    oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncAlertContext.create(config)

    resp = await ctx.list_alerts()
    print(resp)

if __name__ == "__main__":
    asyncio.run(main())
const { Config, AlertContext, OAuth } = require('longbridge')

async function main() {
  const oauth = await OAuth.build('your-client-id', (_, url) => {
    console.log('Open this URL to authorize: ' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = AlertContext.new(config)
  const resp = await ctx.list_alerts()
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.alert.*;

class Main {
    public static void main(String[] args) throws Exception {
        try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
             Config config = Config.fromOAuth(oauth);
             AlertContext ctx = AlertContext.create(config)) {
            var resp = ctx.getListAlerts().get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, alert::AlertContext, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = AlertContext::new(config);
    let resp = ctx.list_alerts().await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::alert;

int main() {
    OAuthBuilder("your-client-id").build(
        [](const std::string& url) { std::cout << "Open: " << url << std::endl; },
        [](auto res) {
            if (!res) return;
            Config config = Config::from_oauth(*res);
            AlertContext ctx = AlertContext::create(config);
            ctx.list_alerts([](auto resp) {
                if (resp) std::cout << "OK" << std::endl;
            });
        });
    std::cin.get();
}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/openapi-go/alert"
)

func main() {
	o := oauth.New("your-client-id").
		OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
	if err := o.Build(context.Background()); err != nil {
		log.Fatal(err)
	}
	conf, err := config.New(config.WithOAuthClient(o))
	if err != nil {
		log.Fatal(err)
	}
	c, err := alert.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	resp, err := c.ListAlerts(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "lists": [
      {
        "symbol": "AAPL.US",
        "code": "AAPL",
        "market": "US",
        "name": "Apple",
        "price": "298.87",
        "chg": "4.07",
        "p_chg": "1.38",
        "product": "stock",
        "indicators": [
          {
            "id": "514050",
            "indicator_id": "1",
            "enabled": true,
            "frequency": 2,
            "scope": 0,
            "text": "价格涨到 400",
            "state": [
              1
            ],
            "value_map": {
              "price": "400"
            }
          }
        ]
      }
    ]
  }
}

Response Status

StatusDescriptionSchema
200成功AlertListResponse
400请求错误None

Schemas

AlertListResponse

NameTypeRequiredDescription
listsobject[]true按标的分组的提醒列表,见 AlertSymbolGroup

AlertSymbolGroup

NameTypeRequiredDescription
symbolstringtrue证券代码
codestringfalse股票代码
marketstringfalse市场
namestringfalse证券名称
pricestringfalse最新价
chgstringfalse当日涨跌额
p_chgstringfalse当日涨跌幅
productstringfalse产品类型
indicatorsobject[]false股价提醒列表,见 AlertItem

AlertItem

NameTypeRequiredDescription
idstringtrue提醒 ID
indicator_idstringfalse条件:1=价格上涨,2=价格下跌,3=涨幅,4=跌幅
enabledbooleanfalse是否启用
frequencyintegerfalse触发频率:1=每日,2=每次,3=一次
scopeintegerfalse范围
textstringfalse显示文本
stateinteger[]false触发状态标志
value_mapobjectfalse触发值(如 {"price":"400"} 或 {"chg":"5"})