/// <summary> /// Gets the theta. /// </summary> /// <returns></returns> public double GetTheta() { double spot = Tree.Underlying(0, 0); double _tau = Tree.Time; int n1 = _divdays.Length; int n2 = _ratedays.Length; BinomialTreePricer lhs1 = new BinomialTreePricer(spot, Strike, Payoff.ToLower()[0] == 'p', _tau, _vol, Tree.Columns, _flatFlag, Style, Smoothing, _ratedays, _rateamts, _divdays, _divamts, _treeType); int[] _divdays1 = new int[n1]; for (int idx = 0; idx < n1; idx++) { _divdays1[idx] = Math.Max(_divdays[idx] - 1, 0); } int[] _ratedays1 = new int[n2]; for (int idx = 0; idx < n2; idx++) { _ratedays1[idx] = Math.Max(_ratedays[idx] - 1, 0); } BinomialTreePricer lhs2 = new BinomialTreePricer(spot, Strike, Payoff.ToLower()[0] == 'p', _tau - 1.0 / 365.0, _vol, Tree.Columns, _flatFlag, Style, Smoothing, _ratedays1, _rateamts, _divdays1, _divamts, _treeType); double p1 = lhs1.GetPrice(); double p2 = lhs2.GetPrice(); double theta = lhs2.GetPrice() - lhs1.GetPrice(); return(theta); }
/// <summary> /// Gets the vega. /// </summary> /// <returns></returns> public double GetVega() { double spot = Tree.Underlying(0, 0); double _tau = Tree.Time; BinomialTreePricer lhs1 = new BinomialTreePricer(spot, Strike, Payoff.ToLower()[0] == 'p', _tau, 0.99 * _vol, Tree.Columns, _flatFlag, Style, Smoothing, _ratedays, _rateamts, _divdays, _divamts, _treeType); BinomialTreePricer lhs2 = new BinomialTreePricer(spot, Strike, Payoff.ToLower()[0] == 'p', _tau, 1.01 * _vol, Tree.Columns, _flatFlag, Style, Smoothing, _ratedays, _rateamts, _divdays, _divamts, _treeType); double P1 = lhs1.GetPrice(); double P2 = lhs2.GetPrice(); double vega = 0.0; if (_vol != 0) { vega = 0.01 * (P2 - P1) / (2 * 0.01 * _vol); } return(vega); }