基于期权定价的兴全合润基金交易策略

来源:https://uqer.io/community/share/5534bc30f9f06c8f3390468f

版本:1.1

作者:李丞

联系:cheng.li@datayes.com

摘要

分级基金是中国金融市场化下创新的产物,多数是以AB端分级,A端获取相对保守收益,B端获取杠杆收益的结构。通俗的讲,在分级基金结构中,大多数情况下,B端优先承受市场风险损失,换取A端“借”给它钱投资的融资优势。

现在市场上大多数的指数型分级基金采取的收益分配模式为:A端获取固定的约定收益率,多半为一年期定存+x%;B端获取剩余的母基金净资产。这样的分级基金可以看做A端是一个固定利率债券,B端是一个看涨期权,其中的期权卖方恰恰是A端。在这里我们不会详细探讨这一类型的结构,关于这一类型分级基金的期权分析可以参考[1]。

这里我们会看一个有趣的产品,在这个产品中,A、B端都是期权形式的[1]。这个产品就是兴全合润分级基金.

1. 兴全合润期权结构分析

收益的结构最容易以一张图的形式表示出来:

  1. from matplotlib import pyplot
  2. import numpy as np
  3. import pandas as pd
  4. import seaborn as sns
  5. def AReturn(base):
  6. if base < 1.21:
  7. return 1.0
  8. else:
  9. return base - 0.21
  10. def BReturn(base):
  11. if base < 0.5:
  12. return 0.1 / 0.6
  13. elif base < 1.21:
  14. return (base - 0.4) / 0.6
  15. else:
  16. return base + 0.14
  17. xspace = np.linspace(0.2, 1.5, 40)
  18. aSeries = [AReturn(x) for x in xspace]
  19. bSeries = [BReturn(x) for x in xspace]
  20. pyplot.figure(figsize=(12,8))
  21. pyplot.plot(xspace, xspace, '-k')
  22. pyplot.plot(xspace, aSeries, '-.k')
  23. pyplot.plot(xspace, bSeries, '--k')
  24. pyplot.xlim((0.2,1.5))
  25. pyplot.legend(['NAV', 'A', 'B'], loc = 'best', fontsize = 16)
  26. <matplotlib.legend.Legend at 0x64f2d10>

基于期权定价的兴全合润基金交易策略 - 图1

收益的描述也可以用下式描述,其中 NAV 为母基金净值:

基于期权定价的兴全合润基金交易策略 - 图2

可以看到,这两个子基金的价值都是三个期权的组合,只是权重不同:

  • A份额买入一份行权价为1.21元的期权

  • B份额买入5/3份行权价为0的看涨期权,同时卖出2/3份行权价为1.21元的看涨期权

对于这些期权,我们可以假设标的即为母基金净值,期限为当前日期到下一个折算日(下一个折算日为2016年4月22日),无风险利率使用3个月Shibor做简单的近似:

  1. # 导入需要的模块
  2. from CAL.PyCAL import *
  3. # 读入外部行情数据
  4. data = pd.read_excel(r'xqhr.xlsx','Sheet1')
  5. riskFree = data['Shibor 3M'] / 100.0
  6. maturity = data['Maturity']
  7. spot = data['163406.OFCN']
  8. ATarget = data['150016.XSHE']
  9. BTarget = data['150017.XSHE']
  10. def AOptionPrice(vol, riskFree, maturity, spot):
  11. price1 = BSMPrice(1, 1.21, spot, riskFree, 0.0, vol[0], maturity, rawOutput = True)
  12. return 1.0*np.exp(-riskFree*maturity) + price1[0]
  13. def BOptionPrice(vol, riskFree, maturity, spot):
  14. price1 = BSMPrice(1, 1.21, spot, riskFree, 0.0, vol[0], maturity, rawOutput = True)
  15. return -2.0/3.0*np.exp(-riskFree*maturity) + 5.0/3.0 * spot - 2.0/3.0 * price1[0]
  16. aTheoreticalPrice = AOptionPrice([0.09], riskFree, maturity, spot)
  17. bTheoreticalPrice = BOptionPrice([0.09], riskFree, maturity, spot)

我们分别看一下,AB端基金理论价格和实际收盘价之间的关系(上面的计算中假设波动率为15%):可以看到,基本上理论价格和真实价格的变动是完全同向的,但是存在价差,A长期折价,B长期溢价。这个价差随着到期折算日的接近,收敛至0。这个是与期权的性质是完全一致的。

  1. data['A (Theoretical)'] = aTheoreticalPrice
  2. data['B (Theoretical)'] = bTheoreticalPrice
  3. pyplot.figure(figsize = (16,10))
  4. ax1 = pyplot.subplot('211')
  5. data.plot('endDate', ['150016.XSHE','A (Theoretical)'], style = ['-.k', '-k'])
  6. ax1.legend(['A', 'A (Theoretical)'], loc = 'best')
  7. ax2 = pyplot.subplot('212')
  8. data.plot('endDate', ['150017.XSHE','B (Theoretical)'], style = ['-.k', '-k'])
  9. ax2.legend(['B', 'B (Theoretical)'], loc = 'best')
  10. <matplotlib.legend.Legend at 0x7134610>

基于期权定价的兴全合润基金交易策略 - 图3

2. 兴全合润的期权投资策略

根据上面的分析,似乎读者可以得到这样的一个印象:A端长期比较便宜,应该直接持有A端,真的是这样吗?这里面实际上有以下的问题:

  • A端由于收益算法的原因,属于类固定收益产品,并且它在标的价格高企时,凸性为负;
  • B端属于杠杆类型,在标的股价高企时,凸性为正;
  • 市场可能会对凸性的不同,对于AB端分别进行折溢价调整;
  • 15%是一个魔幻数(Magic Number),真实市场波动率水平显然不应该是一个常值。 这里我们将涉及一个策略,试着解释最后一个问题。期权有一种估计期权的方法,称为“隐含波动率”。我们可以把类似的想法引入我们这个产品当中,每天收盘的时候,我们可以观察到A端和B端的价格(或者说两个期权组合的价格)。这时候,可以使用优化的方法,找到一个波动率水平使得理论价格在某种标准下与实际价格差异最小。我们把这个波动率水平称之为瑞和300的“隐含波动率”。

有了这个隐含波动率水平,我们可以再计算理论价格,这时候计算而得的理论价格,我们可以认为是“真实”市场估计下的理论期权价值。用这个价格作为评估的标准,比较A端与B端那个更加便宜,从而决定购买哪个产品。下面的策略中,我们即使用上面介绍的办法,每天调仓,根据估价的高低,分别购买A端(B端),同时卖出B端(A端)。这个策略只在二级市场中进行交易。具体的参数如下:

本策略的参数如下:

  • 起始日期: 2010年5月31日
  • 结束日期: 2015年3月27日
  • 起始资金: 100000元
  • 调仓周期: 每个交易日
  1. prices1 = []
  2. prices2 = []
  3. aTarget = []
  4. bTarget = []
  5. def processDate(record):
  6. riskFree = record['Shibor 3M'] / 100.0
  7. maturity = record['Maturity']
  8. spot = record['163406.OFCN']
  9. ATarget = record['150016.XSHE']
  10. BTarget = record['150017.XSHE']
  11. def errorFunction(vol):
  12. price1 = AOptionPrice(vol, riskFree, maturity, spot)
  13. price2 = BOptionPrice(vol, riskFree, maturity, spot)
  14. return (price1 - ATarget)**2 + (price2 - BTarget)**2
  15. out, fx, its, imode, smode = optimize.fmin_slsqp(errorFunction, [0.15], bounds = [(0.01, 0.25)], epsilon = 1e-6, iter = 10000, disp = False, full_output = True, acc = 1e-16)
  16. price1 = AOptionPrice(out, riskFree, maturity, spot)
  17. price2 = BOptionPrice(out, riskFree, maturity, spot)
  18. prices1.append(price1)
  19. prices2.append(price2)
  20. aTarget.append(ATarget)
  21. bTarget.append(BTarget)
  22. return price1 - ATarget, price2 - BTarget
  1. import datetime as dt
  2. from scipy import optimize
  3. callDate = [dt.datetime(2013,4,19)]
  4. class deque:
  5. def __init__(self, maxlen):
  6. self.maxlen = maxlen
  7. self.cont = []
  8. def append(self,vec):
  9. self.cont.append(vec)
  10. if len(self.cont)>self.maxlen:
  11. self.cont = self.cont[len(self.cont) - self.maxlen:]
  12. def __item__(self, i):
  13. return self.cont[i]
  14. def average(self):
  15. sum = 0.0
  16. for i in xrange(len(self.cont)):
  17. sum += self.cont[i]
  18. return sum / float(len(self.cont))
  19. class Account:
  20. def __init__(self, cash, commission = 0.0005):
  21. self.aAmount = 0
  22. self.bAmount = 0
  23. self.commission = commission
  24. self.cash = cash
  25. def order(self, amount, fundType, price):
  26. if fundType.upper() == 'A':
  27. self.aAmount += amount
  28. if amount> 0:
  29. self.cash -= amount * price * (1.0 + self.commission)
  30. else:
  31. self.cash -= amount * price * (1.0 - self.commission)
  32. elif fundType.upper() == 'B':
  33. self.bAmount += amount
  34. if amount> 0:
  35. self.cash -= amount * price * (1.0 + self.commission)
  36. else:
  37. self.cash -= amount * price * (1.0 - self.commission)
  38. def currentValue(self, aQuote, bQuote):
  39. return self.aAmount * aQuote + self.bAmount * bQuote + self.cash
  40. def BackTesting(data, window = 20, startAmount = 100000, tradeVol = 2000):
  41. account = Account(startAmount)
  42. aWindow = deque(maxlen = window)
  43. bWindow = deque(maxlen = window)
  44. performance = [startAmount]
  45. aVol = [0]
  46. bVol = [0]
  47. cash = [startAmount]
  48. for i in xrange(1, len(data)):
  49. previousDay = data.loc[i-1]
  50. aUnderEstimated, bUnderEstimated = processDate(previousDay)
  51. aWindow.append(aUnderEstimated)
  52. bWindow.append(bUnderEstimated)
  53. aAverage = aWindow.average()
  54. bAverage = bWindow.average()
  55. today = data.loc[i]
  56. aPrice = today['150016.XSHE']
  57. bPrice = today['150017.XSHE']
  58. if i >= 5:
  59. # 如果分级A端相对于B端更便宜
  60. if aUnderEstimated - aAverage > bUnderEstimated - bAverage:
  61. if account.cash > tradeVol:
  62. account.order(tradeVol, 'A', aPrice)
  63. if account.bAmount >0:
  64. account.order(-tradeVol, 'B', bPrice)
  65. # 如果分级B端相对于A端更便宜
  66. elif aUnderEstimated - aAverage < bUnderEstimated - bAverage:
  67. if account.cash > tradeVol:
  68. account.order(tradeVol, 'B', bPrice)
  69. if account.aAmount >0:
  70. account.order(-tradeVol, 'A', aPrice)
  71. for calDate in callDate:
  72. if today['endDate'] == calDate:
  73. account.order(-account.aAmount, 'A', aPrice)
  74. account.order(-account.bAmount, 'B', bPrice)
  75. performance.append(account.currentValue(aPrice, bPrice))
  76. aVol.append(account.aAmount)
  77. bVol.append(account.bAmount)
  78. cash.append(account.cash)
  79. originalReturn = data[['150016.XSHE', '150017.XSHE', '163406.OFCN']].values
  80. start = originalReturn[0]
  81. originalReturn[0] = 1.0
  82. dates = data['endDate']
  83. scalar = 1.0
  84. count = 0
  85. for i in xrange(1, len(originalReturn)):
  86. if count < len(callDate) and dates[i-1] == callDate[count]:
  87. start = originalReturn[i]
  88. originalReturn[i] = originalReturn[i-1]
  89. count += 1
  90. else:
  91. scalar = originalReturn[i] / start
  92. start = originalReturn[i]
  93. originalReturn[i] = originalReturn[i-1] * scalar
  94. scalar = float(performance[0])
  95. performance = [p / scalar for p in performance]
  96. return pd.DataFrame({'Performance':performance, '150016.XSHE': aVol, '150017.XSHE': bVol, 'Cash': cash, '163406.OFCN': data['163406.OFCN'].values, 'A Performance': originalReturn[:,0], 'B Performance': originalReturn[:,1],'Benchmark Return':originalReturn[:,2]} ,index = data.endDate)
  1. bt = BackTesting(data, tradeVol = 20000)
  2. bt.plot(y = ['Benchmark Return', 'Performance', 'A Performance', 'B Performance'], figsize = (16,8), style = ['-k', '-.k'])
  3. pyplot.legend( ['Benchmark', 'Strategy', 'A', 'B'], loc = 'best')
  4. <matplotlib.legend.Legend at 0x7285510>

基于期权定价的兴全合润基金交易策略 - 图4

由上图可知,这样的策略是比较典型的指数增强型策略

  1. res = pd.DataFrame({'A (Implied)': prices1, 'B (Implied)':prices2, 'A': aTarget, 'B': bTarget}, index = data.endDate[1:])
  2. pyplot.figure(figsize = (16,10))
  3. ax1 = pyplot.subplot('211')
  4. res.plot(y = ['A (Implied)', 'A'], style = ['-k', '-.k'])
  5. pyplot.legend(['A (Implied)', 'A'])
  6. ax1 = pyplot.subplot('212')
  7. res.plot(y = ['B (Implied)', 'B'], style = ['-k', '-.k'])
  8. pyplot.legend(['B (Implied)', 'B'])
  9. <matplotlib.legend.Legend at 0x7804290>

基于期权定价的兴全合润基金交易策略 - 图5

3. 我们是否能够比“猴子”做的更好?

作为和该策略的比较,我们可以使用一个随机投资的做法。让我们看看,和“猴子”(Monky Random Choice Strategy)比,我们是否能够做的更好?

  1. def BackTesting2(data, window = 20, startAmount = 100000, tradeVol = 2000):
  2. account = Account(startAmount)
  3. performance = [startAmount]
  4. aVol = [0]
  5. bVol = [0]
  6. cash = [startAmount]
  7. s = MersenneTwister19937UniformRsg(seed = 1234)
  8. for i in xrange(1, len(data)):
  9. previousDay = data.loc[i-1]
  10. aUnderEstimated, bUnderEstimated = processDate(previousDay)
  11. today = data.loc[i]
  12. aPrice = today['150016.XSHE']
  13. bPrice = today['150017.XSHE']
  14. if i >= 5:
  15. # 如果随机数>0.5
  16. if s.nextSequence()[0] > 0.5:
  17. if account.cash > tradeVol:
  18. account.order(tradeVol, 'A', aPrice)
  19. if account.bAmount >0:
  20. account.order(-tradeVol, 'B', bPrice)
  21. # 如果随机数<0.5
  22. elif s.nextSequence()[0] < 0.5:
  23. if account.cash > tradeVol:
  24. account.order(tradeVol, 'B', bPrice)
  25. if account.aAmount >0:
  26. account.order(-tradeVol, 'A', aPrice)
  27. for calDate in callDate:
  28. if today['endDate'] == calDate:
  29. account.order(-account.aAmount, 'A', aPrice)
  30. account.order(-account.bAmount, 'B', bPrice)
  31. performance.append(account.currentValue(aPrice, bPrice))
  32. aVol.append(account.aAmount)
  33. bVol.append(account.bAmount)
  34. cash.append(account.cash)
  35. originalReturn = list(data['163406.OFCN'].values)
  36. start = originalReturn[0]
  37. originalReturn[0] = 1.0
  38. dates = data['endDate']
  39. scalar = 1.0
  40. count = 0
  41. for i in xrange(1, len(originalReturn)):
  42. if count < len(callDate) and dates[i-1] == callDate[count]:
  43. start = originalReturn[i]
  44. originalReturn[i] = originalReturn[i-1]
  45. count += 1
  46. else:
  47. scalar = originalReturn[i] / start
  48. start = originalReturn[i]
  49. originalReturn[i] = originalReturn[i-1] * scalar
  50. scalar = float(performance[0])
  51. performance = [p / scalar for p in performance]
  52. return pd.DataFrame({'Performance':performance, '150016.XSHE': aVol, '150017.XSHE': bVol, 'Cash': cash, '163406.OFCN': data['163406.OFCN'].values, 'Benchmark Return':originalReturn } ,index = data.endDate)
  1. bt1 = BackTesting(data, tradeVol = 20000)
  2. bt2 = BackTesting2(data, tradeVol = 20000)
  3. bt1['Monky'] = bt2['Performance']
  4. bt1.plot(y = ['Benchmark Return', 'Monky', 'Performance'], figsize = (16,8), style = ['-k', '--k', '-.k'])
  5. pyplot.legend( ['Benchmark', 'Monkey', 'Strategy'], loc = 'best')
  6. <matplotlib.legend.Legend at 0x7804150>

基于期权定价的兴全合润基金交易策略 - 图6

结果令人满意,我们的期权投资比随机选择的结果好的多。我们看到如果随机投资,“猴子”式的选择并不能显著的击败标的母基金。但是我们的期权投资策略还是可以保持的持续性的跑赢指数以及随机选择。

4. 使用历史波动率

这里我们给了一个使用历史波动率计算折溢价水平,与之前使用的隐含波动率方法进行比较。这里使用的历史波动率水平是20天年化收益标准差。结果上,我们无法显著区别这两种波动率算法在表现上面的区别。但是他们都可以显著的击败标的母基金。

  1. def processDate2(record):
  2. riskFree = record['Shibor 3M'] / 100.0
  3. maturity = record['Maturity']
  4. spot = record['163406.OFCN']
  5. ATarget = record['150016.XSHE']
  6. BTarget = record['150017.XSHE']
  7. volatility = record['volatility']
  8. vol = [volatility]
  9. price1 = AOptionPrice(vol, riskFree, maturity, spot)
  10. price2 = BOptionPrice(vol, riskFree, maturity, spot)
  11. return price1 - ATarget, price2 - BTarget
  12. def BackTesting3(data, window = 20, startAmount = 100000, tradeVol = 2000):
  13. account = Account(startAmount)
  14. aWindow = deque(maxlen = window)
  15. bWindow = deque(maxlen = window)
  16. performance = [startAmount]
  17. aVol = [0]
  18. bVol = [0]
  19. cash = [startAmount]
  20. for i in xrange(1, len(data)):
  21. previousDay = data.loc[i-1]
  22. aUnderEstimated, bUnderEstimated = processDate2(previousDay)
  23. aWindow.append(aUnderEstimated)
  24. bWindow.append(bUnderEstimated)
  25. aAverage = aWindow.average()
  26. bAverage = bWindow.average()
  27. today = data.loc[i]
  28. aPrice = today['150016.XSHE']
  29. bPrice = today['150017.XSHE']
  30. if i >= 5:
  31. # 如果分级A端相对于B端更便宜
  32. if aUnderEstimated - aAverage > bUnderEstimated - bAverage:
  33. if account.cash > tradeVol:
  34. account.order(tradeVol, 'A', aPrice)
  35. if account.bAmount >0:
  36. account.order(-tradeVol, 'B', bPrice)
  37. # 如果分级B端相对于A端更便宜
  38. elif aUnderEstimated - aAverage < bUnderEstimated - bAverage:
  39. if account.cash > tradeVol:
  40. account.order(tradeVol, 'B', bPrice)
  41. if account.aAmount >0:
  42. account.order(-tradeVol, 'A', aPrice)
  43. for calDate in callDate:
  44. if today['endDate'] == calDate:
  45. account.order(-account.aAmount, 'A', aPrice)
  46. account.order(-account.bAmount, 'B', bPrice)
  47. performance.append(account.currentValue(aPrice, bPrice))
  48. aVol.append(account.aAmount)
  49. bVol.append(account.bAmount)
  50. cash.append(account.cash)
  51. originalReturn = list(data['163406.OFCN'].values)
  52. start = originalReturn[0]
  53. originalReturn[0] = 1.0
  54. dates = data['endDate']
  55. scalar = 1.0
  56. count = 0
  57. for i in xrange(1, len(originalReturn)):
  58. if count < len(callDate) and dates[i-1] == callDate[count]:
  59. start = originalReturn[i]
  60. originalReturn[i] = originalReturn[i-1]
  61. count += 1
  62. else:
  63. scalar = originalReturn[i] / start
  64. start = originalReturn[i]
  65. originalReturn[i] = originalReturn[i-1] * scalar
  66. scalar = float(performance[0])
  67. performance = [p / scalar for p in performance]
  68. return pd.DataFrame({'Performance':performance, '150016.XSHE': aVol, '150017.XSHE': bVol, 'Cash': cash, '163406.OFCN': data['163406.OFCN'].values, 'Benchmark Return':originalReturn } ,index = data.endDate)
  1. bt3 = BackTesting3(data, tradeVol = 20000)
  2. bt1['Historical (Vol)'] = bt3['Performance']
  3. bt1.plot(y = ['Benchmark Return', 'Historical (Vol)', 'Performance'], figsize = (16,8), style = ['-k', '--k', '-.k'])
  4. pyplot.legend( ['Benchmark', 'Historical Vol', 'Implied Vol'], loc = 'best')
  5. <matplotlib.legend.Legend at 0x7841410>

基于期权定价的兴全合润基金交易策略 - 图7

5. 风险收益分析

下面我们按照每个自然年评估策略的绩效。可以看到在5个自然年中,只有一年的收益为负;更值得关注的是,这个策略相对于原策略都录得了正的超额收益。

  1. value = bt1[['Performance', 'Benchmark Return']]
  2. value['endDate'] = value.index.values
  3. returnRes = [0]
  4. tmp = np.log(value['Performance'][1:].values/ value['Performance'][:-1].values)
  5. returnRes.extend(tmp)
  6. value['Per. Return'] = returnRes
  7. returnRes = [0]
  8. tmp = np.log(value['Benchmark Return'][1:].values/ value['Benchmark Return'][:-1].values)
  9. returnRes.extend(tmp)
  10. value['Benchmark Return'] = returnRes
  11. year2010 = value[(value['endDate'] > Date(2010,1,1).toTimestamp()) & (value['endDate'] <= Date(2010,12,31).toTimestamp())]
  12. year2011 = value[(value['endDate'] > Date(2011,1,1).toTimestamp()) & (value['endDate'] <= Date(2011,12,31).toTimestamp())]
  13. year2012 = value[(value['endDate'] > Date(2012,1,1).toTimestamp()) & (value['endDate'] <= Date(2012,12,31).toTimestamp())]
  14. year2013 = value[(value['endDate'] > Date(2013,1,1).toTimestamp()) & (value['endDate'] <= Date(2013,12,31).toTimestamp())]
  15. year2014 = value[(value['endDate'] > Date(2014,1,1).toTimestamp()) & (value['endDate'] <= Date(2014,12,31).toTimestamp())]
  16. year2015 = value[(value['endDate'] > Date(2015,1,1).toTimestamp()) & (value['endDate'] <= Date(2015,12,31).toTimestamp())]
  17. days = 252
  18. def perRes(yearRes):
  19. yearRes['Excess Return'] = yearRes['Per. Return'] - yearRes['Benchmark Return']
  20. mean = yearRes.mean() * days * 100
  21. std = yearRes.std() * np.sqrt(days) * 100
  22. return mean['Per. Return'], mean['Excess Return'], std['Per. Return']
  23. res2010 = perRes(year2010)
  24. res2011 = perRes(year2011)
  25. res2012 = perRes(year2012)
  26. res2013 = perRes(year2013)
  27. res2014 = perRes(year2014)
  28. res2015 = perRes(year2015)
  29. perRet = []
  30. exceRet= []
  31. perStd = []
  32. for res in [res2010, res2011, res2012, res2013, res2014, res2015]:
  33. perRet.append(res[0])
  34. exceRet.append(res[1])
  35. perStd.append(res[2])
  36. resTable = pd.DataFrame({'Strategy (Return %)':perRet, 'Excess (Return %)':exceRet, 'Strategy (Volatility %)':perStd }, index = ['2010', '2011', '2012', '2013', '2014', '2015'])
  37. resTable.index.name = 'Year'
  38. resTable.plot(kind = 'bar', figsize = (14,8), legend = True)
  39. <matplotlib.axes.AxesSubplot at 0x82f4b50>

基于期权定价的兴全合润基金交易策略 - 图8