Пример #1
0
        public void Purge(DateTime t0, DateTime t1, int nTI)
        {
            bool[] delflag = new bool[titles.Length];
            for (int i = 0; i < delflag.Length; i++)
            {
                delflag[i] = false;
            }


            for (int i = 0; i < titles.Length; i++)
            {
                if (titles[i].Tstart > t0 || titles[i].Tend < t1)
                {
                    delflag[i] = true;
                }

                if (!titles[i].Cut(t0, t1, nTI))
                {
                    delflag[i] = true;
                }

                double total = titles[i].Close[titles[i].Close.Length - 1] / titles[i].Close[0];
                if (total > 5)
                {
                    delflag[i] = true;
                }

                if (total < 0.2)
                {
                    delflag[i] = true;
                }

                total = titles[i].High[titles[i].High.Length - 1] / titles[i].High[0];
                if (total > 5)
                {
                    delflag[i] = true;
                }

                if (total < 0.2)
                {
                    delflag[i] = true;
                }

                total = titles[i].Low[titles[i].Low.Length - 1] / titles[i].Low[0];
                if (total > 5)
                {
                    delflag[i] = true;
                }

                if (total < 0.2)
                {
                    delflag[i] = true;
                }


                double[] dperc = TI.calculate_dperc(titles[i].Close, 1);
                for (int k = 1; k < dperc.Length; k++)
                {
                    if (Math.Abs(dperc[k]) > 0.5)
                    {
                        delflag[i] = true;
                        break;
                    }
                }

                dperc = TI.calculate_dperc(titles[i].High, 1);
                for (int k = 1; k < dperc.Length; k++)
                {
                    if (Math.Abs(dperc[k]) > 0.5)
                    {
                        delflag[i] = true;
                        break;
                    }
                }

                dperc = TI.calculate_dperc(titles[i].Low, 1);
                for (int k = 1; k < dperc.Length; k++)
                {
                    if (Math.Abs(dperc[k]) > 0.5)
                    {
                        delflag[i] = true;
                        break;
                    }
                }


                double gamma = 6;

                for (int k = 1; k < 10; k++)
                {
                    dperc = TI.calculate_dperc(titles[i].Close, k);
                    for (int z = 1; z < dperc.Length; z++)
                    {
                        if (Math.Abs(dperc[z]) > gamma * TI.SimulationSigmaFTSEraw(k))
                        {
                            delflag[i] = true;
                            break;
                        }
                    }
                }
            }

            // remove elements and stuff
            int newlength = 0;

            for (int i = 0; i < titles.Length; i++)
            {
                if (!delflag[i])
                {
                    newlength++;
                }
            }

            Title[] newtitles = new Title[newlength];
//            MessageBox.Show("Total Purged(): " + newtitles.Length + " over: " + titles.Length);
            int index = 0;

            for (int i = 0; i < titles.Length; i++)
            {
                if (!delflag[i])
                {
                    titles[i].SetDay0(t0);
                    newtitles[index++] = titles[i];
                }                 // else System.Console.WriteLine("purged: " + i);
            }


            titles = newtitles;
        }