mirror of
https://github.com/longbridge/developers.git
synced 2026-09-19 03:34:09 +08:00
4.4 KiB
4.4 KiB
id, title, slug, sidebar_position
| id | title | slug | sidebar_position |
|---|---|---|---|
| quote_optionchain_date_strike | 获取标的的期权链到期日期权标的列表 | optionchain-date-strike | 12 |
该接口用于获取标的的期权链到期日期权标的列表。
:::info
业务指令:21
:::
Request
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | 是 | 标的代码,使用 ticker.region 格式,例如:700.HK |
| expiry_date | string | 是 | 期权到期日,使用 YYMMDD 格式,例如:20220429,通过 期权到期日 接口获取 |
Protobuf
message OptionChainDateStrikeInfoRequest {
string symbol = 1;
string expiry_date = 2;
}
Request Example
# 获取标的的期权链到期日期权标的列表
# https://open.longbridgeapp.com/docs/quote/pull/optionchain-date-strike
import os
import time
from longbridge.http import Auth, Config, HttpClient
from longbridge.ws import ReadyState, WsCallback, WsClient
# Protobuf 变量定义参见:https://github.com/longbridgeapp/openapi-protobufs/blob/main/quote/api.proto
from longbridge.proto.quote_pb2 import (Command, OptionChainDateStrikeInfoRequest, OptionChainDateStrikeInfoResponse)
class MyWsCallback(WsCallback):
def on_state(self, state: ReadyState):
print(f"-> state: {state}")
auth = Auth(os.getenv("LONGBRIDGE_APP_KEY"), os.getenv("LONGBRIDGE_APP_SECRET"), access_token=os.getenv("LONGBRIDGE_ACCESS_TOKEN"))
http = HttpClient(auth, Config(base_url="https://openapi.longbridgeapp.com"))
ws = WsClient("wss://openapi-quote.longbridgeapp.com", http, MyWsCallback())
# 运行前请访问 “开发者中心“ 确保账户有正确的行情权限。
# 如没有开通行情权限,可以通过 "长桥" 手机客户端,并进入 “我的 - 我的行情 - 行情商城“ 购买开通行情权限。
req = OptionChainDateStrikeInfoRequest(symbol="AAPL.US", expiry_date="20230120")
result = ws.send_request(Command.QueryOptionChainDateStrikeInfo, req.SerializeToString())
resp = OptionChainDateStrikeInfoResponse()
resp.ParseFromString(result)
print(f"Option chain info:\n\n {resp}")
Response
Response Properties
| Name | Type | Description |
|---|---|---|
| strike_price_info | object[] | 到期日期权标的列表 |
| ∟ price | string | 行权价 |
| ∟ call_symbol | string | CALL 期权标的代码 |
| ∟ put_symbol | string | PUT 期权标的代码 |
| ∟ standard | bool | 是否标准期权 |
Protobuf
message OptionChainDateStrikeInfoResponse {
repeated StrikePriceInfo strike_price_info = 1;
}
message StrikePriceInfo {
string price = 1;
string call_symbol = 2;
string put_symbol = 3;
bool standard = 4;
}
Response JSON Example
{
"strike_price_info": [
{
"price": "100",
"call_symbol": "AAPL220429C100000.US",
"put_symbol": "AAPL220429P100000.US",
"standard": true
},
{
"price": "105",
"call_symbol": "AAPL220429C105000.US",
"put_symbol": "AAPL220429P105000.US",
"standard": true
},
{
"price": "110",
"call_symbol": "AAPL220429C110000.US",
"put_symbol": "AAPL220429P110000.US",
"standard": true
},
{
"price": "115",
"call_symbol": "AAPL220429C115000.US",
"put_symbol": "AAPL220429P115000.US",
"standard": true
}
]
}
错误码
| 协议错误码 | 业务错误码 | 描述 | 排查建议 |
|---|---|---|---|
| 3 | 301600 | 无效的请求 | 请求参数有误或解包失败 |
| 3 | 301606 | 限流 | 降低请求频次 |
| 7 | 301602 | 服务端内部错误 | 请重试或联系技术人员处理 |
| 7 | 301600 | 请求数据非法 | 检查请求的 symbol,expiry_date 数据格式 |