跳到主要內容

獲取已訂閱標的行情

該接口用於獲取當前連接已訂閱的標的行情。

SDK Links

Python
longport.openapi.QuoteContext.subscriptions
Rust
longport::quote::QuoteContext#subscriptions
Go
QuoteContext.Subscriptions
Node.js
QuoteContext#subscriptions
信息

Request

Protobuf

message SubscriptionRequest {
}

Request Example

from longport.openapi import QuoteContext, Config, SubType
config = Config.from_env()
ctx = QuoteContext(config)

ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote])
resp = ctx.subscriptions()
print(resp)

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服務端內部錯誤請重試或聯繫技術人員處理