跳轉到內容

獲取已訂閱標的行情

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

ℹ️Info

Request

Protobuf

protobuf
message SubscriptionRequest {
}

Request Example

python
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

protobuf
message SubscriptionResponse {
  repeated SubTypeList sub_list = 1;
}

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

Response JSON Example

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

錯誤碼

協議錯誤碼業務錯誤碼描述排查建議
3301600無效的請求請求參數有誤或解包失敗
3301606限流降低請求頻次
7301602服務端內部錯誤請重試或聯繫技術人員處理