---
slug: update-pinned
title: 更新置顶证券
sidebar_position: 5
language_tabs: false
toc_footers: []
includes: []
search: true
highlight_theme: ''
headingLevel: 2
---

在自选股分组中置顶或取消置顶指定证券，以控制显示顺序。


## SDK

| 语言 | 链接 |
|---|---|
| Python | [longbridge.openapi.quote._quote_context](https://longbridge.github.io/openapi/python/reference_all/#longbridge.openapi.quote._quote_context) |
| Rust | [longbridge::<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />::quote#_quote_context](https://longbridge.github.io/openapi/rust/longbridge/<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />/struct.quote.html#method._quote_context) |
| Go | [quote.update_pinned](https://pkg.go.dev/github.com/longbridge/openapi-go/<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />#quote.update_pinned) |
| Node.js | [quote#QuoteContext](https://longbridge.github.io/openapi/nodejs/classes/quote.html#quotecontext) |
| Java | [quote.getQuoteContext](https://longbridge.github.io/openapi/java/com/longbridge/<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />/quote.html#getQuoteContext) |
| C++ | [longbridge::<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />::quote::_quote_context](https://longbridge.github.io/openapi/cpp/classlongbridge_1_1<SDKLinks module="quote" klass="QuoteContext" method="update_pinned" />_1_1_quote.html) |

## Request

<table className="http-basic">
<tbody>
<tr><td className="http-basic-key">HTTP Method</td><td>PUT</td></tr>
<tr><td className="http-basic-key">HTTP URL</td><td>/watchlist/groups</td></tr>
</tbody>
</table>

### 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

<Tabs groupId="request-example">
  <TabItem value="python" label="Python" default>

```python
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)
```

  </TabItem>
  <TabItem value="python-async" label="Python (async)">

```python
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())
```

  </TabItem>
  <TabItem value="nodejs" label="Node.js">

```javascript
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)
```

  </TabItem>
  <TabItem value="java" label="Java">

```java
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();
        }
    }
}
```

  </TabItem>
  <TabItem value="rust" label="Rust">

```rust
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(())
}
```

  </TabItem>
  <TabItem value="cpp" label="C++">

```cpp
#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();
}
```

  </TabItem>
  <TabItem value="go" label="Go">

```go
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")
}
```

  </TabItem>
</Tabs>

## Response

### Response Headers

- Content-Type: application/json

### Response Example

```json
{
  "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.
