SAS:计算期权数据集的多个隐含波动率

SAS: Calculating multiple Implied Volatilities for dataset of options

我想每天计算一组期权链的隐含波动率。我在包含以下列的数据集中拥有所有必要的数据:

OptionID opt_price strike today exp eq_price intrate

IV 的 SAS 代码是:

options pageno=1 nodate ls=80 ps=64;

proc fcmp;
   opt_price=5;
   strike=50;
   today='20jul2010'd;
   exp='21oct2010'd;
   eq_price=50;
   intrate=.05;
   time=exp - today;
   array opts[5] initial abconv relconv maxiter status
                 (.5 .001 1.0e-6 100 -1);
   function blksch(strike, time, eq_price, intrate, volty);
      return(blkshclprc(strike, time/365.25,
                        eq_price, intrate, volty));
   endsub;
   bsvolty=solve("blksch", opts, opt_price, strike,
                             time, eq_price, intrate, .);

   put 'Option Implied Volatility:' bsvolty
       'Initial value: ' opts[1]
       'Solve status: ' opts[5];
run;

来源:https://documentation.sas.com/?docsetId=proc&docsetTarget=p1xoknqns865t7n1wehj6xarwhdb.htm&docsetVersion=9.4&locale=en#p0ymk0vrf7cecfn1kec073rxqm7z

现在,这个函数不知何故不需要 sigma。为什么?

其次,如何输入和输出一个带有几年期权系列的数据集? 我尝试了 optionID 但我不知道如何正确输入数据然后将其添加到数据集中(新变量称为 bsvolty.

使用 FCMP 选项 DATA=OUT= 提供输入和捕获输出。

至于 sigma 参数位置中的缺失值 (.),SOLVE 文档指出:

The SOLVE function finds the value of the specified argument that makes the expression of the following form equal to zero.

  • expected-value -
    function-name
    (argument-1,argument-2,
    ..., argument-n)

You specify the argument of interest with a missing value (.), which appears in place of the argument in the parameter list that is shown above. If the SOLVE function finds the value, then the value that is returned for this function is the implied value.

因此,SOLVE() 用于 blkshclprc 西格玛(即波动率)

示例代码:

data have;
input OptionID opt_price strike today: date9. exp: date9. eq_price intrate;
format today exp date9.;
datalines;
1 5 50 20jul2010 21oct2010  50 0.05
2 5 75 21jul2010 22oct2010  50 0.05
3 5 55 22jul2010 23oct2010  50 0.05
4 5 60 23jul2010 24oct2010  50 0.05
;

proc fcmp data=have out=want;

  time = exp - today;

  array opts[5] 
    initial abconv relconv maxiter status
    ( .5    .001   1.0e-6  100     -1)
  ;

  function blksch(strike, time, eq_price, intrate, volty);

    put volty=;  /* show the SOLVE iterations in the OUTPUT window */

    return ( blkshclprc ( 
      strike,       /* E: exercise prices */
      time/365.25,  /* t: time to maturity (years) */
      eq_price,     /* S: share price */
      intrate,      /* r: annualized risk-free interest rate, continuouslycompounded */
      volty         /* sigma: volatility of the underlying asset */
    ));
  endsub;

  bsvolty=solve("blksch", opts, opt_price, strike,
                           time, eq_price, intrate, .);
run;

输出数据集

输出window