期权行权
概述
期权行权接口自 v0.4.2 起提供以下功能:
- 行权检验:预估行权或放弃行权后正股持仓的变化
- 查询可行权持仓:获取可提交行权/放弃行权申请的期权持仓列表
- 提交行权申请:提交提前行权或提前放弃行权申请
- 查询行权记录:分页查询已提交的行权申请历史
- 撤销行权申请:撤销尚未执行的行权申请
行权类型(OptionExerciseType)
| 枚举值 | 说明 |
|---|---|
Exercise | 提前行权 — 在到期日前提前执行期权 |
Expire | 提前放弃行权 — 在到期日前主动放弃行权 |
行权检验
对应方法:TradeClient.check_option_exercise()
预估行权或放弃行权后正股持仓变化,可在提交前确认结果。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| contract_id | int | 是 | 期权合约 ID |
| exercise_type | OptionExerciseType | str | 是 | 行权类型:Exercise / Expire |
| quantity | float | 是 | 行权数量(> 0) |
| account | str | 否 | 交易账户,默认使用 config 中的账户 |
| executing_date | str | Exercise 必填 | 行权执行日期,格式 yyyy-MM-dd |
| is_force | bool | Exercise 必填 | 是否强制行权 |
| itm_rate | int | 否 | 价内率阈值 0–10(仅 Expire 类型可用) |
| secret_key | str | 否 | 机构账户交易员密钥 |
| lang | Language | str | 否 | 语言 |
返回(OptionExerciseCheckResult)
| 字段 | 类型 | 说明 |
|---|---|---|
| available_quantity | float | 可行权数量 |
| position | float | 当前期权持仓 |
| stk_position | float | 正股当前持仓 |
| stk_position_change | float | 行权后正股持仓变化量 |
| stk_position_before | float | 行权前正股持仓 |
| stk_position_after | float | 行权后正股持仓 |
| symbol | str | 正股代码 |
示例
from tigeropen.common.consts import OptionExerciseType
# Exercise 类型行权检验(quantity、executing_date、is_force 必填)
result = client.check_option_exercise(
contract_id=1234567890,
exercise_type=OptionExerciseType.EXERCISE,
quantity=1.0,
executing_date='2025-06-20',
is_force=False
)
print(f"available_quantity={result.available_quantity}")
print(f"stk_position_before={result.stk_position_before}")
print(f"stk_position_after={result.stk_position_after}")
# Expire 类型,设置价内率(quantity 必填)
result = client.check_option_exercise(
contract_id=1234567890,
exercise_type=OptionExerciseType.EXPIRE,
quantity=1.0,
itm_rate=5
)返回示例
{
"available_quantity": 10.0,
"position": 10.0,
"stk_position": 300.0,
"stk_position_change": -100.0,
"stk_position_before": 300.0,
"stk_position_after": 200.0,
"symbol": "AAPL"
}查询可行权持仓
对应方法:TradeClient.get_option_exercise_positions()
查询当前账户下可提交行权或放弃行权申请的期权持仓列表。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| exercise_type | OptionExerciseType | str | 是 | 行权类型:Exercise / Expire |
| account | str | 否 | 交易账户,默认使用 config 中的账户 |
| secret_key | str | 否 | 机构账户交易员密钥 |
| lang | Language | str | 否 | 语言 |
返回(OptionExercisePositionPageResult)
| 字段 | 类型 | 说明 |
|---|---|---|
| items | List[OptionExercisePosition] | 持仓列表 |
| page_num | int | 当前页码 |
| page_size | int | 每页数量 |
| item_count | int | 总记录数 |
| page_count | int | 总页数 |
OptionExercisePosition 字段
| 字段 | 类型 | 说明 |
|---|---|---|
| contract_id | int | 期权合约 ID |
| symbol | str | 期权合约代码 |
| stk_symbol | str | 正股代码 |
| expire_date | str | 到期日,格式 yyyy-MM-dd |
| strike | str | 行权价 |
| call_put | str | CALL / PUT |
| market | str | 市场 |
| account_id | int | 账户 ID |
| position | float | 持仓数量 |
| available_quantity | float | 可行权数量 |
示例
result = client.get_option_exercise_positions(
exercise_type=OptionExerciseType.EXERCISE
)
print(f"item_count={result.item_count}")
for pos in result.items:
print(f"contract_id={pos.contract_id} symbol={pos.symbol} "
f"expire_date={pos.expire_date} available_qty={pos.available_quantity}")返回示例
{
"item_count": 4,
"page_num": 1,
"page_size": 10,
"page_count": 1,
"items": [
{
"contract_id": 1684414425,
"symbol": "AAPL",
"stk_symbol": "AAPL",
"expire_date": "2026-04-17",
"strike": "280.0",
"call_put": "PUT",
"market": "US",
"account_id": 600021133765,
"position": 10.0,
"available_quantity": 10.0
}
]
}提交行权申请
对应方法:TradeClient.submit_option_exercise()
提交提前行权或提前放弃行权申请。
注意
- 提交前建议先调用行权检验接口确认持仓变化
executing_date与is_force仅在 Exercise 类型时有效,且为必填itm_rate仅在 Expire 类型时可用- 提交成功后如需撤销,请使用撤销行权申请接口
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| contract_id | int | 是 | 期权合约 ID |
| exercise_type | OptionExerciseType | str | 是 | 行权类型:Exercise / Expire |
| quantity | float | 是 | 行权数量(> 0) |
| account | str | 否 | 交易账户,默认使用 config 中的账户 |
| executing_date | str | Exercise 必填 | 行权执行日期,格式 yyyy-MM-dd |
| is_force | bool | Exercise 必填 | 是否强制行权 |
| itm_rate | int | 否 | 价内率阈值 0–10(仅 Expire 类型) |
| secret_key | str | 否 | 机构账户交易员密钥 |
| lang | Language | str | 否 | 语言 |
返回
成功时返回 True,失败时抛出 ApiException。
示例
# 提前行权
success = client.submit_option_exercise(
contract_id=1234567890,
exercise_type=OptionExerciseType.EXERCISE,
quantity=1.0,
executing_date='2025-06-20',
is_force=False
)
print('提交成功' if success else '提交失败')
# 提前放弃行权
success = client.submit_option_exercise(
contract_id=1234567890,
exercise_type=OptionExerciseType.EXPIRE,
quantity=1.0
)查询行权记录
对应方法:TradeClient.get_option_exercise_records()
分页查询已提交的行权申请记录。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| account | str | 否 | 交易账户,默认使用 config 中的账户 |
| page | int | 否 | 页码,从 1 开始,默认 1 |
| size | int | 否 | 每页数量,1–100,默认 20 |
| status | str | 否 | 行权状态过滤:New / Cancel / Success / Fail |
| exercise_type | OptionExerciseType | str | 否 | 行权类型过滤:Exercise / Expire |
| symbol | str | 否 | 正股代码过滤 |
| order_by | str | 否 | 排序字段:symbol / expire_date / strike / is_call |
| secret_key | str | 否 | 机构账户交易员密钥 |
| lang | Language | str | 否 | 语言 |
返回(OptionExercisePageResult)
| 字段 | 类型 | 说明 |
|---|---|---|
| items | List[OptionExerciseRecord] | 记录列表 |
| page_num | int | 当前页码 |
| page_size | int | 每页数量 |
| item_count | int | 总记录数 |
| page_count | int | 总页数 |
OptionExerciseRecord 字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id | int | 行权申请记录 ID |
| contract_id | int | 期权合约 ID |
| symbol | str | 期权合约代码 |
| stk_symbol | str | 正股代码 |
| expire_date | str | 到期日 |
| strike | str | 行权价 |
| call_put | str | CALL / PUT |
| type | str | Exercise / Expire |
| request_quantity | float | 申请数量 |
| quantity | float | 实际行权数量 |
| status | str | 申请状态:New / Cancel / Success / Fail |
| executing_date | str | 行权执行日期 |
| itm_rate | int | 价内率 |
| is_force | bool | 是否强制行权 |
| reason | str | 拒绝原因(如有) |
| account_id | int | 账户 ID |
示例
# 基本查询
result = client.get_option_exercise_records(page=1, size=20)
print(f"item_count={result.item_count} page_count={result.page_count}")
for record in result.items:
print(f"id={record.id} type={record.type} status={record.status}")
# 带过滤条件
result = client.get_option_exercise_records(
exercise_type=OptionExerciseType.EXERCISE,
order_by='symbol',
page=1,
size=20
)返回示例
{
"item_count": 19,
"page_num": 1,
"page_size": 10,
"page_count": 2,
"items": [
{
"id": 315,
"contract_id": 2701923713,
"symbol": "AAPL",
"stk_symbol": "AAPL",
"expire_date": "2026-06-05",
"strike": "305.0",
"call_put": "PUT",
"type": "Exercise",
"request_quantity": 1.0,
"quantity": 0.0,
"status": "Cancel",
"executing_date": "2026-06-01",
"itm_rate": 0,
"is_force": false,
"reason": "Cancelled by manual",
"account_id": 600021133765
}
]
}撤销行权申请
对应方法:TradeClient.cancel_option_exercise()
撤销尚未执行的行权申请。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| exercise_id | int | 是 | 行权申请记录 ID(从查询行权记录接口获取) |
| account | str | 否 | 交易账户,默认使用 config 中的账户 |
| secret_key | str | 否 | 机构账户交易员密钥 |
| lang | Language | str | 否 | 语言 |
返回
成功时返回 True,失败时抛出 ApiException。
示例
success = client.cancel_option_exercise(exercise_id=record_id)
print('撤销成功' if success else '撤销失败')