コード例 #1
0
ファイル: Library.cs プロジェクト: zhangz/Highlander.Net
        /// <summary>
        /// Gets the AT mforward.
        /// </summary>
        /// <param name="zeroDates"></param>
        /// <param name="zeroRates">The zero curve.</param>
        /// <param name="divDates"></param>
        /// <param name="divAms">The div curve.</param>
        /// <param name="expiry"></param>
        /// <param name="spot">The spot.</param>
        /// <param name="today"></param>
        /// <returns></returns>
        public static double GetForward(DateTime today, DateTime expiry, double spot, DateTime[] zeroDates, double[] zeroRates, DateTime[] divDates, double[] divAms)
        {
            var       wrapper = new Wrapper();
            ZeroCurve myZero  = wrapper.UnpackZero(today, zeroDates, zeroRates);
            DivList   myDiv   = wrapper.UnpackDiv(today, expiry, divDates, divAms);
            double    t       = expiry.Subtract(today).Days / 365.0;
            double    temp    = Collar.GetATMfwd(myZero, myDiv, spot, t);

            return(temp);
        }
コード例 #2
0
ファイル: Library.cs プロジェクト: zhangz/Highlander.Net
        /// <summary>
        ///
        /// </summary>
        /// <param name="spot"></param>
        /// <param name="strike"></param>
        /// <param name="vol"></param>
        /// <param name="paystyle"></param>
        /// <param name="today"></param>
        /// <param name="expiry"></param>
        /// <param name="zeroDates"></param>
        /// <param name="zeroRates"></param>
        /// <param name="q"></param>
        /// <returns></returns>
        public static double BlackScholesPricerContDiv(double spot, double strike, double vol, string paystyle, DateTime today, DateTime expiry,
                                                       DateTime[] zeroDates, double[] zeroRates, double q)
        {
            double    t      = expiry.Subtract(today).Days / 365.0;
            ZeroCurve myZero = (new Wrapper()).UnpackZero(today, zeroDates, zeroRates);
            double    fwd    = Collar.GetATMfwd(myZero, q, spot, t);
            double    r      = myZero.LinInterp(t);
            //create default pricer
            var myPrice = new Pricer {
                Strike = strike, Payoff = paystyle
            };
            double pr = myPrice.BSprice(fwd, t, strike, r, vol, paystyle);

            return(pr);
        }