跳到主要內容

獲取已訂閱標的行情

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

信息

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