更新置頂
在自選股分組中置頂或取消置頂指定證券,以控制顯示順序。
SDK Links
Python |
Rust |
Go |
Node.js |
Java |
C++ |
Request
| HTTP Method | PUT |
| HTTP URL | /watchlist/groups |
Parameters
Content-Type: application/json; charset=utf-8
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | YES | Watchlist group ID |
| symbol | string | YES | Security symbol to pin or unpin, e.g. AAPL.US |
| is_pinned | bool | YES | Set to true to pin the security, false to unpin it |
Request Example
from longbridge.openapi import QuoteContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = QuoteContext(config)
ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True)import asyncio
from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config)
await ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True)
if __name__ == "__main__":
asyncio.run(main())const { Config, QuoteContext, 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 = QuoteContext.new(config)
await ctx.updatePinned('2630', 'AAPL.US', true)
}
main().catch(console.error)import com.longbridge.*;
import com.longbridge.quote.*;
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);
QuoteContext ctx = QuoteContext.create(config)) {
ctx.updatePinned("2630", "AAPL.US", true).get();
}
}
}use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config);
ctx.update_pinned("2630", "AAPL.US", true).await?;
Ok(())
}#include <iostream>
#include <longbridge.hpp>
using namespace longbridge;
using namespace longbridge::quote;
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);
QuoteContext ctx = QuoteContext::create(config);
ctx.update_pinned("2630", "AAPL.US", true, [](auto) {});
});
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/quote"
)
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)
}
qctx, err := quote.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer qctx.Close()
if err := qctx.UpdatePinned(context.Background(), "2630", "AAPL.US", true); err != nil {
log.Fatal(err)
}
fmt.Println("OK")
}Response
Response Headers
- Content-Type: application/json
Response Example
{
"code": 0,
"message": "success",
"data": {}
}
Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | Success | None |
| 400 | Bad request | None |
Schemas
No response schemas. The endpoint returns an empty data object on success.