取消订阅行情数据
该接口用于取消订阅标的行情数据。
信息
业务指令:7
Request
Parameters
Name | Type | Required | Description |
---|---|---|---|
symbol | string[] | 是 | 订阅的标的代码,例如:[700.HK] 校验规则: 每次请求支持传入的标的数量上限是 500 个 |
sub_type | int32[] | 是 | 订阅的数据类型,例如:[1,2] ,详见 SubType |
unsub_all | bool | 是 | 是否全部取消。 - symbol 为空时,取消所有标的的订阅。- symbol 不为空时,取消这些标的的所有类型订阅。 |
Protobuf
message UnsubscribeRequest {
repeated string symbol = 1;
repeated SubType sub_type = 2;
bool unsub_all = 3;
}
Request Example
# 取消订阅行情数据
# https://open.longportapp.com/docs/quote/subscribe/unsubscribe
# 订阅行情数据请检查“开发者中心” - “行情权限”是否正确
# https://open.longportapp.com/account
#
# - 港股 - BMP 基础报价,无实时行情推送,无法用 WebSocket 订阅
# - 美股 - LV1 纳斯达克最优报价 (只限 Open API)
#
# 运行前请访问“开发者中心”确保账户有正确的行情权限。
# 如没有开通行情权限,可以通过“LongPort”手机客户端,并进入“我的 - 我的行情 - 行情商城”购买开通行情权限。
from longport.openapi import QuoteContext, Config, SubType
config = Config.from_env()
ctx = QuoteContext(config)
ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Quote])
ctx.unsubscribe(["AAPL.US"], [SubType.Quote])
Response
Protobuf
message UnsubscribeResponse{
}
错误码
协议错误码 | 业务错误码 | 描述 | 排查建议 |
---|---|---|---|
3 | 301600 | 无效的请求 | 请求参数有误或解包失败 |
3 | 301606 | 限流 | 降低请求频次 |
7 | 301602 | 服务端内部错误 | 请重试或联系技术人员处理 |
7 | 301600 | 请求参数有误 | 检查请求的 sub_type |