声明:本内容为个人业余研究,所有标的代码仅做为示例,回测收益不代表未来,不做为投资建议。
卖出深度虚值期权是一种高胜率,像卖彩票的策略,旨在从时间价值衰减中获利,是时间的朋友。这种策略的核心在于识别那些权利金合理、风险可控且到期概率较高的合约。上一篇文章获取当前未到期800支期权行情数据,今天将介绍三层过滤策略,通过时间维度、希腊字母特征和隐含波动率指标逐步筛选具备卖出价值的深度虚值期权。该策略的核心逻辑在于通过多维度数据交叉验证,平衡风险与收益。
本策略采用递进式过滤机制,每层聚焦不同关键指标,形成漏斗型筛选流程:
三层过滤环环相扣,最终输出符合严格标准的候选合约池。
deffilter_first_layer(basic_info_path, daily_data_dir, current_date=None):# 加载期权基本信息表 df_basic = pd.read_csv(basic_info_path)# 计算剩余到期天数 log.info("计算剩余到期天数...") df_basic['days_to_expiry'] = df_basic['delist_date'].apply(lambda x: calculate_days_to_expiry(x, current_date) )# 过滤剩余10-45天的合约 log.info("过滤剩余10-45天的合约...") df_time_filtered = df_basic[ (df_basic['days_to_expiry'] >= 10) & (df_basic['days_to_expiry'] <= 60) ].copy()if df_time_filtered.empty: log.warning("没有符合条件的合约(剩余10-45天)")return pd.DataFrame()# 获取权利金并过滤 > 0.0100 log.info("获取权利金并过滤 > 0.0100...") premiums = [] valid_indices = []for idx, row in df_time_filtered.iterrows(): ts_code = row['ts_code'] premium = get_latest_premium(ts_code, daily_data_dir)if premium isnotNoneand premium > 0.0100: premiums.append(premium) valid_indices.append(idx)else:if premium isNone: log.debug(f"期权 {ts_code} 权利金获取失败")else: log.debug(f"期权 {ts_code} 权利金 {premium} 不符合条件")# 创建过滤后的DataFrame df_filtered = df_time_filtered.loc[valid_indices].copy() df_filtered['premium'] = premiums# 解析期权名称信息 log.info("解析期权名称信息...") parsed_info = []for name in df_filtered['name']: info = parse_option_name(name) parsed_info.append(info)return df_filtered关键作用解析:
get_latest_premium函数实时获取最新成交价,保证数据的时效性。deffilter_second_layer(df_first_filtered, current_date=None): log.info("=" * 50) log.info("开始第二层过滤:Delta 0.2-0.3的虚值合约") log.info("=" * 50) risk_free_rate = 0.02# 无风险利率假设 historical_volatility = 0.20# 历史波动率假设 valid_indices = [] deltas = [] underlying_prices = [] is_out_of_money_list = []for idx, row in df_first_filtered.iterrows(): name = row['name'] ts_code = row['ts_code'] strike_price = row.get('strike_price', row.get('exercise_price'))# 确定期权类型 option_type = Noneif'option_type'in row: option_type = 'call'if row['option_type'] == '认购'else'put'else:if'认购'in name: option_type = 'call'elif'认沽'in name: option_type = 'put'ifnot option_type: log.warning(f"无法确定期权类型: {name}")continue# 获取标的资产价格 underlying_symbol = row.get('underlying')if pd.isna(underlying_symbol): underlying_symbol = name.split('期权')[0] + '期权'if'期权'in name else name S = get_underlying_price(underlying_symbol)if S isNone: log.warning(f"无法获取标的资产价格: {underlying_symbol}")continue# 执行价格与剩余时间处理 K = float(strike_price) days_to_expiry = row.get('days_to_expiry') or calculate_days_to_expiry(row['delist_date'], current_date) T = days_to_expiry / 365.0# 计算Delta值 delta = calculate_delta(S, K, T, risk_free_rate, historical_volatility, option_type)if delta isNone: log.warning(f"无法计算Delta值: {ts_code}")continue# 判断虚值状态 is_otm = is_out_of_money(S, K, option_type)# 满足条件则记录if0.2 <= delta <= 0.4and is_otm: valid_indices.append(idx) deltas.append(delta) underlying_prices.append(S) is_out_of_money_list.append(is_otm)else: log.debug(f"期权 {ts_code} 不符合第二层条件: Delta={delta:.3f}, 虚值={is_otm}")return df_first_filtered.loc[valid_indices]核心逻辑说明:
is_out_of_money函数严格区分实值/虚值,确保只保留真正的深度虚值合约。deffilter_third_layer(df_second_filtered, current_date=None):try: risk_free_rate = 0.02 valid_indices = [] implied_volatilities = []for idx, row in df_second_filtered.iterrows(): name = row['name'] ts_code = row['ts_code'] strike_price = row.get('strike_price', row.get('exercise_price')) market_price = row.get('premium')if market_price isNoneor market_price <= 0: log.warning(f"期权市场价格无效: {ts_code}, 价格={market_price}")continue# 确定期权类型 option_type = Noneif'option_type'in row: option_type = 'call'if row['option_type'] == '认购'else'put'else:if'认购'in name: option_type = 'call'elif'认沽'in name: option_type = 'put'ifnot option_type: log.warning(f"无法确定期权类型: {name}")continue# 获取标的资产价格 S = row.get('underlying_price')if S isNone: underlying_symbol = row.get('underlying')if pd.isna(underlying_symbol): underlying_symbol = name.split('期权')[0] + '期权'if'期权'in name else name S = get_underlying_price(underlying_symbol)if S isNone: log.warning(f"无法获取标的资产价格: {ts_code}")continue# 执行价格与剩余时间处理 K = float(strike_price) days_to_expiry = row.get('days_to_expiry') or calculate_days_to_expiry(row['delist_date'], current_date) T = days_to_expiry / 365.0# 计算隐含波动率 iv = calculate_implied_volatility(S, K, T, risk_free_rate, market_price, option_type)if iv isNone: log.warning(f"无法计算隐含波动率: {ts_code}")continue# IV阈值检查if iv < 0.20: valid_indices.append(idx) implied_volatilities.append(iv)else: log.debug(f"期权 {ts_code} 不符合第三层条件: IV={iv:.3f}")return df_second_filtered.loc[valid_indices]技术要点剖析:
calculate_implied_volatility函数反向求解BS模型中的σ,反映市场对未来波动的预期。本文提出的三层过滤策略通过标准化流程解决了深度虚值期权筛选,后面可在现有基础上添加趋势强度评分、资金流向监控等,及时修正偏离现实的预设参数。
PS: 源码下载,请移步知识星球!
星球中整理了文章中涉及到的源码,加入后即可以看到之前发的源码,三天内不满意可以退款。也会将收集到的机构研报,优秀策略源码,群友常咨询的问题整理到不同标签下,做为知识库沉淀下来。
所有策略仅用于学习和研究,不保证交易收益,不作为投资建议,风险自负,所有收益仅表示历史回测收益,不表示未来收益。大QMT和ptrade请充分使用模拟盘测试,miniQMT使用模拟账号测试。
听了群友的建议,年化收益达到了70%,增加了动态仓位权重调整后的全球核心资产轮动策略(含python代码解析)
欢迎扫描下方二维码,备注【开通】,开通QMT或Ptrade;备注【加群】,加入量化交易交流群;备注【电子书】,赠送QMT或Ptrade入门操作指南。

仅做知识整理,本公众号对这些信息的准确性和完整性不作任何保证,本材料不构成任何投资意见。投资有风险,入市需谨慎。