跳到主要內容

获取已订阅标的行情

该接口用于获取当前连接已订阅的标的行情。

信息

Request

Protobuf

message SubscriptionRequest {
}

Request Example

from time import sleep
from longport.openapi import QuoteContext, Config, SubType, PushQuote, Period, AdjustType

def on_quote(symbol: str, event: PushQuote):
print(symbol, event)

config = Config.from_env()
ctx = QuoteContext(config)
ctx.set_on_quote(on_quote)
ctx.subscribe(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"], [SubType.Quote], is_first_push=True)

Response

Response Properties

NameTypeDescription
sub_listobject[]订阅的数据
∟ symbolstring标的代码
∟ sub_type[]int32订阅的数据类型,详见 SubType

Protobuf

message SubscriptionResponse {
repeated SubTypeList sub_list = 1;
}

message SubTypeList {
string symbol = 1;
repeated SubType sub_type = 2;
}

Response JSON Example

{
"sub_list": [
{
"symbol": "700.HK",
"sub_type": [1, 2, 3]
},
{
"symbol": "AAPL.US",
"sub_type": [2]
}
]
}

错误码

协议错误码业务错误码描述排查建议
3301600无效的请求请求参数有误或解包失败
3301606限流降低请求频次
7301602服务端内部错误请重试或联系技术人员处理