コード例 #1
0
        private void dataTransformationThread_DoWork(object sender, DoWorkEventArgs e)
        {
            int    i, r;
            String StrParam1, StrParam2, StrParam3;
            int    recursion = 1;
            Dictionary <String, String> tParams = new Dictionary <string, string>();
            List <Equity> DataToTransform;

            SET_DATA_INVALID();

            //Point to the data set to be transformed
            if (AllTransformApplied == true)
            {
                DataToTransform = statsMarketData.Constituents;
            }
            else
            {
                DataToTransform = dataSet;
            }

            //Validate the required control parameters
            if (trfWorkerParamText.Length != 4)
            {
                trfWorkerSelectedIndex = -1;
            }

            //Validate the selected transformation combobox index
            if (trfWorkerSelectedIndex >= 0)
            {
                switch (TransformTList[trfWorkerSelectedIndex])
                {
                case TransformType.TRF_GAUSS:
                    StrParam1 = trfWorkerParamText[1];
                    StrParam2 = trfWorkerParamText[2];
                    StrParam3 = trfWorkerParamText[3];

                    //If input parameter is valid, perform the transformation
                    if (Helpers.ValidateNumeric(StrParam1) && Helpers.ValidateNumeric(StrParam2))
                    {
                        recursion = int.Parse(StrParam2);
                        for (r = 0; r < recursion; r++)
                        {
                            tParams.Add("pSigma", StrParam1);
                            for (i = 0; i < DataToTransform.Count(); i++)
                            {
                                //dataSet[i].TransformData(Transformation.GAUSS, tParams);
                                DataToTransform[i].TransformData(Transformation.GAUSS, tParams);
                            }
                            tParams.Clear();
                        }
                    }
                    break;

                case TransformType.TRF_MEAN:
                    StrParam1 = trfWorkerParamText[1];
                    StrParam2 = trfWorkerParamText[2];
                    StrParam3 = trfWorkerParamText[3];

                    //If input parameter is valid, perform the transformation
                    if (Helpers.ValidateNumeric(StrParam1) && Helpers.ValidateNumeric(StrParam2))
                    {
                        recursion = int.Parse(StrParam2);
                        for (r = 0; r < recursion; r++)
                        {
                            tParams.Add("Window", StrParam1);
                            for (i = 0; i < DataToTransform.Count(); i++)
                            {
                                DataToTransform[i].TransformData(Transformation.MEAN, tParams);
                            }
                            tParams.Clear();
                        }
                    }

                    break;

                case TransformType.TRF_NORM:
                    tParams.Clear();
                    for (i = 0; i < DataToTransform.Count(); i++)
                    {
                        DataToTransform[i].TransformData(Transformation.NORMALIZE, tParams);
                    }
                    break;

                case TransformType.TRF_SHIFT_PPC:
                    StrParam1 = trfWorkerParamText[1];

                    if (lastSelectedTab >= 0 && lastSelectedTab < DataToTransform.Count() && Helpers.ValidateNumeric(StrParam1))
                    {
                        for (i = 0; i < statsMarketData.Constituents.Count; i++)
                        {
                            if (statsMarketData.Constituents[i].Name == DataToTransform[lastSelectedTab].Name)
                            {
                                statsMarketData.Constituents[i].TrimDataLeft(int.Parse(StrParam1));
                            }
                            else
                            {
                                statsMarketData.Constituents[i].TrimDataRight(int.Parse(StrParam1));
                            }
                        }
                    }

                    break;

                default:
                    break;
                }
            }

            SET_DATA_VALID();
        }