經紀商持倉
Longbridge US 賬戶不支援
此方法需要 AP 數據中心賬戶(香港/新加坡)。美股數據中心賬戶將收到區域限制錯誤。AP 賬戶可查詢任意標的,包括美股。
查看港股券商持倉情況,包含主要買賣方和詳細持倉列表。
SDK Links
Python |
Rust |
Go |
Node.js |
Java |
C++ |
Parameters
SDK 方法參數。
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | 是 | 港股證券代碼,例如 700.HK |
Request Example
from longbridge.openapi import MarketContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = MarketContext(config)
resp = ctx.broker_positions("AAPL.US")
print(resp)import asyncio
from longbridge.openapi import AsyncMarketContext, 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 = AsyncMarketContext.create(config)
resp = await ctx.broker_positions("AAPL.US")
print(resp)
if __name__ == "__main__":
asyncio.run(main())const { Config, MarketContext, 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 = MarketContext.new(config)
const resp = await ctx.broker_positions('AAPL.US')
console.log(resp)
}
main().catch(console.error)import com.longbridge.*;
import com.longbridge.market.*;
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);
MarketContext ctx = MarketContext.create(config)) {
var resp = ctx.getBrokerPositions("AAPL.US").get();
System.out.println(resp);
}
}
}use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config);
let resp = ctx.broker_positions("AAPL.US").await?;
println!("{:?}", resp);
Ok(())
}#include <iostream>
#include <longbridge.hpp>
using namespace longbridge;
using namespace longbridge::market;
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);
MarketContext ctx = MarketContext::create(config);
ctx.broker_positions("AAPL.US", [](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/market"
)
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 := market.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer c.Close()
resp, err := c.BrokerPositions(context.Background(), "AAPL.US")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}Response
Response Example
{
"code": 0,
"message": "success",
"data": {
"buy": [
{
"parti_number": "B01224",
"name": "HSBC",
"chg": "5000000",
"strong": true
}
],
"sell": [
{
"parti_number": "B01274",
"name": "Goldman Sachs HK",
"chg": "-3000000",
"strong": false
}
],
"updated_at": "2026.05.13"
}
}
Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | 成功 | BrokerHoldingResponse |
| 400 | 請求錯誤 | None |
Schemas
BrokerHoldingResponse
| Name | Type | Required | Description |
|---|---|---|---|
| buy | object[] | 否 | 淨買入經紀商列表, |
| ∟ parti_number | string | 是 | 經紀商參與者編號 |
| ∟ name | string | 否 | 經紀商名稱 |
| ∟ chg | string | 否 | 持倉變動 |
| ∟ strong | boolean | 否 | 是否為主要持倉者 |
| sell | object[] | 否 | 淨賣出經紀商列表, |
| ∟ parti_number | string | 是 | 經紀商參與者編號 |
| ∟ name | string | 否 | 經紀商名稱 |
| ∟ chg | string | 否 | 持倉變動 |
| ∟ strong | boolean | 否 | 是否為主要持倉者 |
| updated_at | string | 否 | 最後更新時間 |