FRM模型十六:期权策略(期权组合)


本文所有代码基于windAPI,复现前先下载客户端并注册账号

备兑看涨期权(Covered Call)

构成:标的资产的多头 + 欧式看涨期权空头
损益:当标的资产市场价格上涨时,标的资产多头获利,看涨期权空头不行权。
当标的资产价格下降时,标的资产多头亏损,看涨期权行权获利弥补多头方损失。

头寸 损益
标的资产多头 S T − S 0 S_{T}-S_{0} STS0
看涨期权空头 C − m a x ( S T − K , 0 ) C-max(S_{T}-K,0) Cmax(STK,0)
整体策略 S T − S 0 − m a x ( S T − K , 0 ) + C S_{T}-S_{0}-max(S_{T}-K,0)+C STS0max(STK,0)+C

其中 S T S_{T} ST表示T时刻的市价,K表示执行价,C表示看涨期权价格。损益图如下所示。

在这里插入图片描述
代码实现:

def CoveredCall(UnderlyingCode, OptionCode,StartTime):
    '''
    UndelyingCode:标的资产代码
    OptionCode:对冲期权的代码
    StartTime:开始回测时间
    '''

    error_code, wsd_data = w.wsd(OptionCode, "exe_price,exe_enddate,close,exe_ratio", StartTime, StartTime, usedf=True)
    StrikePrice = wsd_data['EXE_PRICE'][0]
    StrikeTime = wsd_data['EXE_ENDDATE'][0]
    OptionPrice = wsd_data['CLOSE'][0]
    Ratio = wsd_data['EXE_RATIO'][0]

    # 取当前系统时间
    current_time = datetime.datetime.now()
    # 比较行权日和当前,如果行权日晚于当前时间,只能回测到当前时间,否则可以回测到行权日。
    if current_time > StrikeTime:
        BacktestTime = StrikeTime
    else:
        BacktestTime = current_time

    # 定义合约份数
    N_ETF = 10000
    N_option = 1

    # 取行情数据
    error_code, etf_data = w.wsd(UnderlyingCode, "close", StartTime, BacktestTime, usedf=True)
    S0 = etf_data['CLOSE'][0]
    Payoff = (etf_data - S0) * N_ETF + N_option * OptionPrice - np.max(etf_data - StrikePrice, 0) * Ratio
    Payoff.plot(legend=None)
    plt.xlabel('Time', fontsize=8)
    plt.xticks(rotation=45)
    plt.ylabel('Payoff', fontsize=8)
    plt.show(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值