Exemplo n.º 1
0
        public static object BachelierGreek(double fwd, double strike, double maturity, double vol, string request)
        {
            return(FunctionRunnerUtils.Run("BachelierGreek", () =>
            {
                double gamma, theta, vega, vanna, vomma;
                Bachelier.Greeks(fwd, strike, maturity, vol,
                                 out gamma, out theta, out vega, out vanna, out vomma);
                switch (request.Trim().ToLower())
                {
                case "gamma":
                    return gamma;

                case "theta":
                    return theta;

                case "vega":
                    return vega;

                case "vanna":
                    return vanna;

                case "vomma":
                    return vomma;

                default:
                    throw new Exception(string.Format("Unknow greek : {0}", request));
                }
            }));
        }
Exemplo n.º 2
0
        public static object BachelierImpliedVol(double forward, double strike, double maturity, double price, string optionType)
        {
            return(FunctionRunnerUtils.Run("BachelierImpliedVol", () =>
            {
                double q;
                switch (optionType.Trim().ToLower())
                {
                case "call":
                    q = 1.0;
                    break;

                case "put":
                    q = -1.0;
                    break;

                default:
                    throw new Exception(string.Format("Unknow option type : {0}", optionType));
                }
                return Bachelier.ImpliedVol(price, forward, strike, maturity, q);
            }));
        }