public ParameterdCandidateStrategy(CandidateParameter cp = null, 
            ParameterdCandidateStrategy parent = null, IBestCandidateSelector bestCandidateSelector = null)
        {
            if (cp == null)
            {
                cp = new CandidateParameter("Default");
            }
            this.CandidateParameter = cp;

            if (cp.ClassifierType == null && !TestParameters.EnableExcludeClassifier)
            {
                cp.SymbolCount = 1;
                cp.PeriodCount = 1;
                cp.PeriodTimeCount = 0;
                cp.PrevTimeCount = 0;
            }

            InitClassifierInfos(parent);

            if (TestParameters2.RealTimeMode)
            {
                m_enableDetailLogLevel2 = false;
            }

            m_bestCandidateSelector = bestCandidateSelector;
        }
        public ParameterdCandidateStrategy(CandidateParameter cp = null,
                                           ParameterdCandidateStrategy parent = null, IBestCandidateSelector bestCandidateSelector = null)
        {
            if (cp == null)
            {
                cp = new CandidateParameter("Default");
            }
            this.CandidateParameter = cp;

            if (cp.ClassifierType == null && !TestParameters.EnableExcludeClassifier)
            {
                cp.SymbolCount     = 1;
                cp.PeriodCount     = 1;
                cp.PeriodTimeCount = 0;
                cp.PrevTimeCount   = 0;
            }

            InitClassifierInfos(parent);

            if (TestParameters2.RealTimeMode)
            {
                m_enableDetailLogLevel2 = false;
            }

            m_bestCandidateSelector = bestCandidateSelector;
        }
Exemple #3
0
        public static void SaveCCScoresToDb(DateTime nowDate, CandidateParameter cp, ParameterdCandidateStrategy pcs)
        {
            string tableName = string.Format("{0}_CCSCORE_{1}", cp.MainSymbol, cp.DealInfoLastMinutes / (7 * 24 * 12 * 5));
            long   nowTime   = WekaUtils.GetTimeFromDate(nowDate);

            try
            {
                Feng.Data.DbHelper.Instance.ExecuteNonQuery(string.Format("SELECT TOP 1 * FROM {0} WHERE TIME = -1", tableName));
            }
            catch (Exception)
            {
                string sqlCreate = string.Format(@"CREATE TABLE {0}(
	[Time] [bigint] NOT NULL,
	[scores] [varbinary](max) NOT NULL,
	[nda] [varbinary](max) NOT NULL,
	[nds] [varbinary](max) NOT NULL,
 CONSTRAINT [PK_{0}] PRIMARY KEY CLUSTERED 
(
	[Time] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]", tableName);
                Feng.Data.DbHelper.Instance.ExecuteNonQuery(sqlCreate);
            }

            long[, ,] ndas        = new long[Parameters.AllDealTypes.Length, cp.BatchTps.Length, cp.BatchSls.Length];
            long[, ,] ndss        = new long[Parameters.AllDealTypes.Length, cp.BatchTps.Length, cp.BatchSls.Length];
            double[, ,] nowScores = new double[Parameters.AllDealTypes.Length, cp.BatchTps.Length, cp.BatchSls.Length];

            pcs.IterateClassifierInfos((k, ii, jj, h) =>
            {
                nowScores[k, ii, jj] = pcs.m_classifierInfoIdxs[k, ii, jj, h].Deals.NowScore;
                ndas[k, ii, jj]      = pcs.m_classifierInfoIdxs[k, ii, jj, h].Deals.DealLastTimeAvg;
                ndss[k, ii, jj]      = pcs.m_classifierInfoIdxs[k, ii, jj, h].Deals.DealLastTimeStd;
            });

            string sql = string.Format("INSERT INTO [{0}] ([Time],[scores],[nda],[nds]) VALUES (@Time, @score, @nda, @nds)", tableName);
            var    cmd = new System.Data.SqlClient.SqlCommand(sql);

            cmd.Parameters.AddWithValue("@Time", nowTime);
            cmd.Parameters.AddWithValue("@score", CCScoreData.SerializeScores(nowScores));
            cmd.Parameters.AddWithValue("@nda", CCScoreData.SerializeScoreTimes(ndas));
            cmd.Parameters.AddWithValue("@nds", CCScoreData.SerializeScoreTimes(ndss));

            try
            {
                Feng.Data.DbHelper.Instance.ExecuteNonQuery(string.Format("DELETE FROM {0} WHERE TIME = '{1}'", tableName, WekaUtils.GetTimeFromDate(nowDate)));

                Feng.Data.DbHelper.Instance.ExecuteNonQuery(cmd);
            }
            catch (Exception)
            {
            }
        }
Exemple #4
0
        public List<ParameterdCandidateStrategy> AddRealDealCandidates(string symbol, int dealInfoLastWeek, IBestCandidateSelector bcs = null)
        {
            List<ParameterdCandidateStrategy> realDealsCandidates = new List<ParameterdCandidateStrategy>();
            //TestParameters.InitTpsls(20, 10);
            //realDealsCandidates.Add(new RealDealCandidate("1M_10", 1 * 4 * 7 * 24 * 12 * 5, this));
            //realDealsCandidates.Add(new RealDealCandidate("1.5M_10", (int)(1.5 * 4 * 7 * 24 * 12 * 5), this));
            //realDealsCandidates.Add(new RealDealCandidate("2M_10", 2 * 4 * 7 * 24 * 12 * 5, this));

            {
                CandidateParameter cp = new CandidateParameter(symbol);

                int delta = TestParameters.GetTpSlMinDelta(symbol) * TestParameters2.nTpsl;
                cp.InitTpsls(TestParameters2.tpStart, delta, TestParameters2.tpCount, TestParameters2.slStart, delta, TestParameters2.slCount);

                cp.SymbolStart = Array.IndexOf<string>(cp.AllSymbols, symbol);
                cp.SymbolCount = 1;
                cp.PeriodStart = Array.IndexOf<string>(cp.AllPeriods, "M1");
                cp.PeriodCount = 1;

                cp.DealInfoLastMinutes = dealInfoLastWeek * 7 * 24 * 12 * 5;
                cp.Group = 1;

                InitBatchBatch(cp);

                if (cp.ClassifierType == null && !TestParameters.EnableExcludeClassifier)
                {
                    cp.AllIndNames.Clear();
                    cp.AllIndNames2.Clear();
                }
                else
                {
                    cp.DeleteUnusedIndicators();
                    //GenerateBatchEmptyInstance();
                }

                ParameterdCandidateStrategy mainPcs = new ParameterdCandidateStrategy(cp, null, bcs);
                realDealsCandidates.Add(mainPcs);

                //    for (int i = 2; i <= 3; ++i)
                //    {
                //        var cp2 = cp.Clone();
                //        cp2.Name += "_" + i.ToString();
                //        cp2.DealInfoLastMinutes = i * 2 * 4 * 7 * 24 * 12 * 5;
                //        realDealsCandidates.Add(new ParameterdCandidateStrategy(cp2));
                //    }
            }

            {
                //CandidateParameter cp = new CandidateParameter("GBPUSD");
                //cp.InitTpsls(10, 60);
                //cp.SymbolStart = 1;
                //cp.DealInfoLastMinutes = 2 * 4 * 7 * 24 * 12 * 5;
                //cp.Group = 2;
                //ParameterdCandidateStrategy mainPcs = new ParameterdCandidateStrategy(cp);
                //mainPcs.m_bestCandidateSelector = new BestCandidateSelector1(0);
                //realDealsCandidates.Add(mainPcs);

                //    for (int i = 2; i <= 3; ++i)
                //    {
                //        var cp2 = cp.Clone();
                //        cp2.Name += "_" + i.ToString();
                //        cp2.DealInfoLastMinutes = i * 2 * 4 * 7 * 24 * 12 * 5;
                //        realDealsCandidates.Add(new ParameterdCandidateStrategy(cp2));
                //    }
            }

            {
                //CandidateParameter cp = new CandidateParameter("EURGBP");
                //cp.InitTpsls(10, 30);
                //cp.SymbolStart = 6;
                //cp.DealInfoLastMinutes = 6 * 4 * 7 * 24 * 12 * 5;
                //cp.Group = 3;
                //ParameterdCandidateStrategy mainPcs = new ParameterdCandidateStrategy(cp);
                //mainPcs.m_bestCandidateSelector = new BestCandidateSelector1(0);
                //realDealsCandidates.Add(mainPcs);

                //    //    for (int i = 2; i <= 3; ++i)
                //    //    {
                //    //        var cp2 = cp.Clone();
                //    //        cp2.Name += "_" + i.ToString();
                //    //        cp2.DealInfoLastMinutes = i * 2 * 4 * 7 * 24 * 12 * 5;
                //    //        realDealsCandidates.Add(new ParameterdCandidateStrategy(cp2));
                //    //    }
            }

            foreach (var i in realDealsCandidates)
            {
                OutputTestInfoCandidate(i.CandidateParameter);
                WekaUtils.Instance.WriteLog(string.Format("BestCandidateSelector = {0}",
                    i.BestCandidateSelector == null ? "Null" : i.BestCandidateSelector.ToString()));
            }

            return realDealsCandidates;
        }
Exemple #5
0
        public void BuildExcludeModels()
        {
            Parameters.TotalCanUseMemory = 600 * 1000 * 1000;

            TestParameters.SaveDataFile = false;
            //m_batchBufferMinutes = (new TimeSpan(365 + 5, 0, 0, 0)).TotalMinutes;

            weka.classifiers.Classifier cls = new weka.classifiers.functions.LibSVM();
            (cls as weka.classifiers.AbstractClassifier).setOptions(weka.core.Utils.splitOptions("-S 0 -K 2"));
            //Classifier cls = new MincostLiblinearClassifier();
            //Classifier cls = new weka.classifiers.functions.LibLINEAR();
            //(cls as AbstractClassifier).setOptions(weka.core.Utils.splitOptions("-S 0 -P -C 1 -B 1"));
            //var cls = new SvmLightClassifier();
            //cls.setOptions(weka.core.Utils.splitOptions("-c 20 -l 4 -w 1 --p 1 --b 1"));

            var cp = new CandidateParameter("BuildExcludeModels");
            cp.DeleteUnusedIndicators();

            ParameterdCandidateStrategy realDealCandidate = new ParameterdCandidateStrategy(cp);

            SetTrainTime(new DateTime(2009, 1, 1), new DateTime(2009, 4, 30));
            //m_generateOneClassHp = 0;

            realDealCandidate.IterateClassifierInfos2(new Func<CandidateClassifier, bool>((clsInfo) =>
            {
                string modelFileName = clsInfo.WekaData.GetExcludeModelFileName(clsInfo.Name);
                //if (!System.IO.File.Exists(modelFileName))
                {
                    WekaUtils.Instance.WriteLog(string.Format("{0} is building exclude model.", clsInfo.Name));

                    //clsInfo.WekaData.m_currentTestHour = clsInfo.Hour;
                    clsInfo.WekaData.GenerateData(true, false);
                    WekaUtils.TrainInstances(clsInfo.WekaData.CurrentTrainInstancesNew, modelFileName, cls);

                    MyEvaluation eval = new MyEvaluation();
                    eval.evaluateModel(cls, clsInfo.WekaData.CurrentTrainInstancesNew);
                    return true;
                }
                //else
                //{
                //    m_currentTestHour = h;
                //    GenerateData(true, false);

                //    cls = WekaUtils.TryLoadClassifier(modelFileName);
                //    var eval = WekaUtils.TestInstances(m_trainInstancesNew[k], cls);
                //}
            }));
        }
Exemple #6
0
        public List <CandidateClassifier> GetBestClassifierInfo(ParameterdCandidateStrategy parent)
        {
            double[] sum    = new double[Parameters.AllDealTypes.Length];
            double[] oscsum = new double[Parameters.AllDealTypes.Length];

            for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
            {
                sum[k]    = 0;
                oscsum[k] = 0;
            }
            parent.IterateClassifierInfos2((cc) =>
            {
                sum[WekaUtils.GetDealTypeIdx(cc.DealType)] += cc.Deals.NowScore;
            });

            int oscCnt = 0;

            parent.IterateClassifierInfos((k, i, j, h) =>
            {
                if (TestParameters.EnablePerhourTrain)
                {
                    if (h != parent.CurrentTestHour)
                    {
                        return(true);
                    }
                }
                if (k > 0)
                {
                    return(true);
                }

                if (parent.m_classifierInfoIdxs[0, i, j, h].Deals.NowScore <= 0 && parent.m_classifierInfoIdxs[1, i, j, h].Deals.NowScore <= 0)
                {
                    oscsum[0] += parent.m_classifierInfoIdxs[0, i, j, h].Deals.NowScore;
                    oscsum[1] += parent.m_classifierInfoIdxs[1, i, j, h].Deals.NowScore;
                    oscCnt++;
                }
                return(true);
            });

            //for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
            //{
            //    sum[k] -= oscsum[k];
            //}
            //double oscsums = oscsum[0] + oscsum[1];

            int selectedDeal = -1;

            if (sum[0] < sum[1] && sum[0] < 0)
            {
                selectedDeal = 0;
            }
            else if (sum[1] < sum[0] && sum[1] < 0)
            {
                selectedDeal = 1;
            }
            if (selectedDeal == -1)
            {
                return(null);
            }

            if (oscCnt > 400)
            {
                return(null);
            }

            //selectedDeal = 1 - selectedDeal;

            List <CandidateClassifier> ret = new List <CandidateClassifier>();

            parent.IterateClassifierInfos((k, i, j, h) =>
            {
                if (k != selectedDeal)
                {
                    return;
                }

                if (TestParameters.EnablePerhourTrain)
                {
                    if (h != parent.CurrentTestHour)
                    {
                        return;
                    }
                }

                switch (m_choiceType)
                {
                case 0:
                    //if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0)// && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    {
                        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                    }
                    break;
                //case 1:
                //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                //    {
                //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                //    }
                //    break;
                //case 2:
                //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                //    {
                //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                //    }
                //    break;
                //case 3:
                //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore < 0)
                //    {
                //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                //    }
                //    break;

                case 4:
                    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    {
                        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    }
                    break;
                    //case 5:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                    //case 6:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                    //case 7:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore < 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                }
            });
            return(ret);
        }
        protected void InitClassifierInfos(ParameterdCandidateStrategy parent = null)
        {
            //int[] sls = m_batchSls != null ? m_batchSls : (m_sl.HasValue ? new int[] { m_sl.Value } : new int[] { 50, 70 });
            //int[][] tps = m_batchTps != null ? m_batchTps : (m_tp.HasValue ? new int[][] { new int[] { m_tp.Value } }
            //    : new int[][] { new int[] { 100, 140 }, new int[] { 50, 70 } });

            //if (Parameters.AllDealTypes == null || Parameters.AllDealTypes.Length == 0)
            //{
            //    Parameters.AllDealTypes = new char[] { 'B', 'S' };
            //}
            if (parent == null)
            {
                m_classifierInfos.Clear();
                m_classifierInfoIdxs = new CandidateClassifier[Parameters.AllDealTypes.Length, this.CandidateParameter.BatchTps.Length, this.CandidateParameter.BatchSls.Length, Parameters.AllHour];
                m_totalScores = new double[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];
                m_totalDeals = new int[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];

                for (int k = 0; k < m_classifierInfoIdxs.GetLength(0); ++k)
                {
                    for (int i = 0; i < m_classifierInfoIdxs.GetLength(1); ++i)
                    {
                        for (int j = 0; j < m_classifierInfoIdxs.GetLength(2); ++j)
                        {
                            int tp = this.CandidateParameter.BatchTps[i];
                            int sl = this.CandidateParameter.BatchSls[j];

                            if (!TestParameters.EnablePerhourTrain)
                            {
                                string name = string.Format("{0}_{1}_{2}", Parameters.AllDealTypes[k], tp, sl);
                                m_classifierInfos[name] = new CandidateClassifier(name, tp, sl, Parameters.AllDealTypes[k], -1, this.CandidateParameter);

                                m_classifierInfoIdxs[k, i, j, 0] = m_classifierInfos[name];
                                m_totalScores[k, i, j, 0] = 0;
                                m_totalDeals[k, i, j, 0] = 0;
                            }
                            else
                            {
                                for (int h = 0; h < m_classifierInfoIdxs.GetLength(3); ++h)
                                {
                                    //if (h != 9)
                                    //    continue;

                                    string name = string.Format("{0}_{1}_{2}_H{3}", Parameters.AllDealTypes[k], tp, sl, h);
                                    m_classifierInfos[name] = new CandidateClassifier(name, tp, sl, Parameters.AllDealTypes[k], h, this.CandidateParameter);

                                    m_classifierInfoIdxs[k, i, j, h] = m_classifierInfos[name];
                                    m_totalScores[k, i, j, h] = 0;
                                    m_totalDeals[k, i, j, h] = 0;
                                }
                            }
                        }
                    }
                }

                this.HasParent = false;
            }
            else
            {
                m_classifierInfoIdxs = parent.m_classifierInfoIdxs;
                m_totalScores = new double[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];
                m_totalDeals = new int[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];

                m_classifierInfos = parent.m_classifierInfos;

                this.HasParent = true;
            }
        }
        public List<CandidateClassifier> GetBestClassifierInfo(ParameterdCandidateStrategy parent)
        {
            double[] sum = new double[Parameters.AllDealTypes.Length];
            double[] oscsum = new double[Parameters.AllDealTypes.Length];

            for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
            {
                sum[k] = 0;
                oscsum[k] = 0;
            }
            parent.IterateClassifierInfos2( (cc) =>
            {
                sum[WekaUtils.GetDealTypeIdx(cc.DealType)] += cc.Deals.NowScore;
            });

            int oscCnt = 0;

            parent.IterateClassifierInfos((k, i, j, h) =>
            {
                if (TestParameters.EnablePerhourTrain)
                {
                    if (h != parent.CurrentTestHour)
                        return true;
                }
                if (k > 0)
                    return true;

                if (parent.m_classifierInfoIdxs[0, i, j, h].Deals.NowScore <= 0 && parent.m_classifierInfoIdxs[1, i, j, h].Deals.NowScore <= 0)
                {
                    oscsum[0] += parent.m_classifierInfoIdxs[0, i, j, h].Deals.NowScore;
                    oscsum[1] += parent.m_classifierInfoIdxs[1, i, j, h].Deals.NowScore;
                    oscCnt++;
                }
                return true;
            });

            //for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
            //{
            //    sum[k] -= oscsum[k];
            //}
            //double oscsums = oscsum[0] + oscsum[1];

            int selectedDeal = -1;
            if (sum[0] < sum[1] && sum[0] < 0)
            {
                selectedDeal = 0;
            }
            else if (sum[1] < sum[0] && sum[1] < 0)
            {
                selectedDeal = 1;
            }
            if (selectedDeal == -1)
                return null;

            if (oscCnt > 400)
                return null;

            //selectedDeal = 1 - selectedDeal;

            List<CandidateClassifier> ret = new List<CandidateClassifier>();
            parent.IterateClassifierInfos((k, i, j, h) =>
            {
                if (k != selectedDeal)
                    return;

                if (TestParameters.EnablePerhourTrain)
                {
                    if (h != parent.CurrentTestHour)
                        return;
                }

                switch (m_choiceType)
                {
                    case 0:
                        //if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0)// && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                        {
                            ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                        }
                        break;
                    //case 1:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                    //    }
                    //    break;
                    //case 2:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                    //    }
                    //    break;
                    //case 3:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore < 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[k, i, j, h]);
                    //    }
                    //    break;

                    case 4:
                        if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                        {
                            ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                        }
                        break;
                    //case 5:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                    //case 6:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore < 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore > 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                    //case 7:
                    //    if (parent.m_classifierInfoIdxs[k, i, j, h].Deals.NowScore > 0 && parent.m_classifierInfoIdxs[1 - k, i, j, h].Deals.NowScore < 0)
                    //    {
                    //        ret.Add(parent.m_classifierInfoIdxs[1 - k, i, j, h]);
                    //    }
                    //    break;
                }
            });
            return ret;
        }
        protected void InitClassifierInfos(ParameterdCandidateStrategy parent = null)
        {
            //int[] sls = m_batchSls != null ? m_batchSls : (m_sl.HasValue ? new int[] { m_sl.Value } : new int[] { 50, 70 });
            //int[][] tps = m_batchTps != null ? m_batchTps : (m_tp.HasValue ? new int[][] { new int[] { m_tp.Value } }
            //    : new int[][] { new int[] { 100, 140 }, new int[] { 50, 70 } });

            //if (Parameters.AllDealTypes == null || Parameters.AllDealTypes.Length == 0)
            //{
            //    Parameters.AllDealTypes = new char[] { 'B', 'S' };
            //}
            if (parent == null)
            {
                m_classifierInfos.Clear();
                m_classifierInfoIdxs = new CandidateClassifier[Parameters.AllDealTypes.Length, this.CandidateParameter.BatchTps.Length, this.CandidateParameter.BatchSls.Length, Parameters.AllHour];
                m_totalScores        = new double[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];
                m_totalDeals         = new int[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];

                for (int k = 0; k < m_classifierInfoIdxs.GetLength(0); ++k)
                {
                    for (int i = 0; i < m_classifierInfoIdxs.GetLength(1); ++i)
                    {
                        for (int j = 0; j < m_classifierInfoIdxs.GetLength(2); ++j)
                        {
                            int tp = this.CandidateParameter.BatchTps[i];
                            int sl = this.CandidateParameter.BatchSls[j];

                            if (!TestParameters.EnablePerhourTrain)
                            {
                                string name = string.Format("{0}_{1}_{2}", Parameters.AllDealTypes[k], tp, sl);
                                m_classifierInfos[name] = new CandidateClassifier(name, tp, sl, Parameters.AllDealTypes[k], -1, this.CandidateParameter);

                                m_classifierInfoIdxs[k, i, j, 0] = m_classifierInfos[name];
                                m_totalScores[k, i, j, 0]        = 0;
                                m_totalDeals[k, i, j, 0]         = 0;
                            }
                            else
                            {
                                for (int h = 0; h < m_classifierInfoIdxs.GetLength(3); ++h)
                                {
                                    //if (h != 9)
                                    //    continue;

                                    string name = string.Format("{0}_{1}_{2}_H{3}", Parameters.AllDealTypes[k], tp, sl, h);
                                    m_classifierInfos[name] = new CandidateClassifier(name, tp, sl, Parameters.AllDealTypes[k], h, this.CandidateParameter);

                                    m_classifierInfoIdxs[k, i, j, h] = m_classifierInfos[name];
                                    m_totalScores[k, i, j, h]        = 0;
                                    m_totalDeals[k, i, j, h]         = 0;
                                }
                            }
                        }
                    }
                }

                this.HasParent = false;
            }
            else
            {
                m_classifierInfoIdxs = parent.m_classifierInfoIdxs;
                m_totalScores        = new double[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];
                m_totalDeals         = new int[m_classifierInfoIdxs.GetLength(0), m_classifierInfoIdxs.GetLength(1), m_classifierInfoIdxs.GetLength(2), m_classifierInfoIdxs.GetLength(3)];

                m_classifierInfos = parent.m_classifierInfos;

                this.HasParent = true;
            }
        }