// The number of days for which we wish to create the cone for
int[] wNumValues = new int[9] { 10, 20, 30, 45, 60, 75, 90, 105, 120 };
// create a datatable to simplify display
System.Data.DataTable oDT = new System.Data.DataTable("tblVolCone");
oDT.Columns.Add("NumDays", typeof(double));
oDT.Columns.Add("VolMax", typeof(double));
oDT.Columns.Add("VolMin", typeof(double));
oDT.Columns.Add("VolAve", typeof(double));
oDT.Columns.Add("VolLast", typeof(double));
// calculates the cone values for each period
for (int i = 0; i < wNumValues.Length; i++)
{
List<double> wVolValues;
// The volatility cone is returned as a statistical object from which we can easily get the Min, Max, Average, Median values
QuantExpress.Maths.Statistics.DescriptiveStatistics oStat =
QuantExpress.Finance.DerivPricing.Historical.HistoricalVolatility.VolatilityCone(m_PriceForCone,
wNumValues[i], null, out wVolValues);
// insert the volatility cone data into the datatable for display
System.Data.DataRow oDRow = oDT.NewRow();
oDRow["NumDays"] = wNumValues[i];
oDRow["VolMax"] = oStat.Max * 100.0;
oDRow["VolMin"] = oStat.Min * 100.0;
oDRow["VolAve"] = oStat.Average() * 100.0;
oDRow["VolLast"] = wVolValues[wVolValues.Count - 1] * 100.0;
oDT.Rows.Add(oDRow);
}
|