跳到主要內容

获取标的盘口

该接口用于获取标的的盘口数据。

SDK Links

Python
longport.openapi.QuoteContext.depth
Rust
longport::quote::QuoteContext#depth
Go
QuoteContext.Depth
Node.js
QuoteContext#depth
信息

Request

Parameters

NameTypeRequiredDescription
symbolstring标的代码,使用 ticker.region 格式,例如:700.HK

Protobuf

message SecurityRequest {
string symbol = 1;
}

Request Example

# 获取标的盘口
#
# 运行前请访问“开发者中心”确保账户有正确的行情权限。
# 如没有开通行情权限,可以通过“LongPort”手机客户端,并进入“我的 - 我的行情 - 行情商城”购买开通行情权限。
from longport.openapi import QuoteContext, Config

config = Config.from_env()
ctx = QuoteContext(config)

resp = ctx.depth("700.HK")
print(resp)

Response

Response Properties

NameTypeDescription
symbolstring标的代码
askobject[]卖盘
∟ positionint32档位
∟ pricestring价格
∟ volumeint64挂单量
∟ order_numint64订单数量
bidobject[]买盘
∟ positionint32档位
∟ pricestring价格
∟ volumeint64挂单量
∟ order_numint64订单数量

Protobuf

message SecurityDepthResponse {
string symbol = 1;
repeated Depth ask = 2;
repeated Depth bid = 3;
}

message Depth {
int32 position = 1;
string price = 2;
int64 volume = 3;
int64 order_num = 4;
}

Response JSON Example

{
"symbol": "700.HK",
"ask": [
{
"position": 1,
"price": "335.000",
"volume": 500,
"order_num": 1
},
{
"position": 2,
"price": "335.200",
"volume": 400,
"order_num": 1
},
{
"position": 3,
"price": "335.400",
"volume": 500,
"order_num": 2
},
{
"position": 4,
"price": "335.600",
"volume": 1200,
"order_num": 3
},
{
"position": 5,
"price": "335.800",
"volume": 14000,
"order_num": 8
}
],
"bid": [
{
"position": 1,
"price": "334.800",
"volume": 69400,
"order_num": 13
},
{
"position": 2,
"price": "334.600",
"volume": 266600,
"order_num": 27
},
{
"position": 3,
"price": "334.400",
"volume": 61300,
"order_num": 29
},
{
"position": 4,
"price": "334.200",
"volume": 125900,
"order_num": 31
},
{
"position": 5,
"price": "334.000",
"volume": 194600,
"order_num": 94
}
]
}

错误码

协议错误码业务错误码描述排查建议
3301600无效的请求请求参数有误或解包失败
3301606限流降低请求频次
7301602服务端内部错误请重试或联系技术人员处理
7301600请求标的不存在检查请求的 symbol 是否正确
7301603标的无行情标的没有请求的行情数据
7301604无权限没有获取标的行情的权限