private void buttonLoadFutures_Click(object sender, EventArgs e)
        {
            DataOpenerForm dof = new DataOpenerForm();
            if (DialogResult.OK == dof.ShowDialog())
            {
                try
                {
                    futureList.Clear();
                    int currentParts = 0;
                    StreamReader sr = dof.GetStream();
                    lcount = 0;

                    while (sr.Peek() >= 0)
                    {
                        string line = sr.ReadLine();
                        if (lcount == 0)
                        {
                            line = Regex.Replace(line, @"\s+", ",");
                            string[] parts = line.Split(new[] { ',' });
                            pcount = parts.Length;
                            for (int i = 0; i < pcount; i++)
                                maturities.Add(Double.Parse(parts[i], NumberStyles.AllowDecimalPoint | NumberStyles.Float));
                        }

                        lcount++;
                    }
                    sr.Close();
                    if (lcount == 0 || pcount == 0) return;

                    while (currentParts < pcount)
                    {
                        sr = dof.GetStream();
                        sr.ReadLine();
                        while (sr.Peek() >= 0)
                        {
                            string line = sr.ReadLine();
                            line = Regex.Replace(line, @"\s+", ",");
                            string[] parts = line.Split(new[] { ',' });
                            futureList.Add(Math.Log(Double.Parse(parts[currentParts], NumberStyles.AllowDecimalPoint | NumberStyles.Float)));
                        }
                        currentParts++;
                        sr.Close();
                    }
                    buttonCalibrate.Enabled = true;

                    labele0.Text = futureList[0].ToString();
                }
                catch (Exception)
                {
                    futureList.Clear();
                    MessageBox.Show("File not formated");
                }
            }
        }
Exemple #2
0
        private void buttonLoadFutures_Click(object sender, EventArgs e)
        {
            DataOpenerForm dof = new DataOpenerForm();

            if (DialogResult.OK == dof.ShowDialog())
            {
                try
                {
                    futureList.Clear();
                    int          currentParts = 0;
                    StreamReader sr           = dof.GetStream();
                    lcount = 0;

                    while (sr.Peek() >= 0)
                    {
                        string line = sr.ReadLine();
                        if (lcount == 0)
                        {
                            line = Regex.Replace(line, @"\s+", ",");
                            string[] parts = line.Split(new[] { ',' });
                            pcount = parts.Length;
                            for (int i = 0; i < pcount; i++)
                            {
                                maturities.Add(Double.Parse(parts[i], NumberStyles.AllowDecimalPoint | NumberStyles.Float));
                            }
                        }


                        lcount++;
                    }
                    sr.Close();
                    if (lcount == 0 || pcount == 0)
                    {
                        return;
                    }

                    while (currentParts < pcount)
                    {
                        sr = dof.GetStream();
                        sr.ReadLine();
                        while (sr.Peek() >= 0)
                        {
                            string line = sr.ReadLine();
                            line = Regex.Replace(line, @"\s+", ",");
                            string[] parts = line.Split(new[] { ',' });
                            futureList.Add(Math.Log(Double.Parse(parts[currentParts], NumberStyles.AllowDecimalPoint | NumberStyles.Float)));
                        }
                        currentParts++;
                        sr.Close();
                    }
                    buttonCalibrate.Enabled = true;

                    labele0.Text = futureList[0].ToString();
                }
                catch (Exception)
                {
                    futureList.Clear();
                    MessageBox.Show("File not formated");
                }
            }
        }