Пример #1
0
        private VolatilitySourceData GetVolatility_Bloomberg(int SecurityID, DateTime ValuationDate)
        {
            SqlCommand sqlCom = new SqlCommand("spOTCOptionPrice_GetVolatility_Bloomberg");

            sqlCom.CommandType = CommandType.StoredProcedure;
            sqlCom.Parameters.Add(new SqlParameter("@SecurityID", SecurityID));
            sqlCom.Parameters.Add(new SqlParameter("@PriceDate", ValuationDate));
            DataSet ds = db.FetchData(sqlCom);
            VolatilitySourceData vsd = new VolatilitySourceData();

            if (ds.Tables[0].Rows.Count != 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];

                try {
                    vsd.Source      = InputSourceData.InputSource.Bloomberg;
                    vsd.Volatility  = double.Parse(dr["Volatility"].ToString());
                    vsd.CaptureTime = DateTime.ParseExact(dr["CaptureTime"].ToString(), "dd/MM/yyyy HH:mm:ss", null);
                    vsd.BBData      = new BBData()
                    {
                        Ticker = dr["BBGTicker"].ToString(), Field = dr["BBField"].ToString(), Value = double.Parse(dr["Volatility"].ToString())
                    };
                } catch {
                    // Problem with data so don't return half a class, return as if nothing was obtained from db
                    vsd = new VolatilitySourceData();
                }
            }
            return(vsd);
        }
Пример #2
0
        private VolatilitySourceData GetVolatility_ManualOverride(int SecurityID, DateTime ValuationDate)
        {
            SqlCommand sqlCom = new SqlCommand("spOTCOptionPrice_GetVolatility_Default");

            sqlCom.CommandType = CommandType.StoredProcedure;
            sqlCom.Parameters.Add(new SqlParameter("@SecurityID", SecurityID));
            DataSet ds = db.FetchData(sqlCom);
            VolatilitySourceData vsd = new VolatilitySourceData();

            if (ds.Tables[0].Rows.Count != 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];

                //if the value is null ignore (i.e. is missing)
                if (dr["DefaultUnderlyingVolatility"] != DBNull.Value)
                {
                    vsd.Source      = InputSourceData.InputSource.Override;
                    vsd.CaptureTime = DateTime.ParseExact(dr["CaptureTime"].ToString(), "dd/MM/yyyy HH:mm:ss", null);
                    vsd.Volatility  = double.Parse(dr["DefaultUnderlyingVolatility"].ToString());
                }
            }
            return(vsd);
        }