public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();

            if (sc == null || sc.Table == null || sc.Table.Rows.Count < this.ReviewExpectCnt)
            {
                return(ret);
            }
            DataTableEx dt = sc.CarTable;

            if (dt == null)
            {
                throw new Exception("无法获得概率分布表!");
            }
            //Log("最后一期数据", string.Join(",", dt.Rows[0].ItemArray));
            //Log("最后二期数据", string.Join(",", dt.Rows[1].ItemArray));
            string     val = dt.Rows[dt.Rows.Count - 1][string.Format("{0}", InputMinTimes)].ToString();
            OnceChance cc  = new OnceChance();

            cc.SignExpectNo = ed.Expect;
            cc.ChanceType   = 1;
            string code_model = "{0}/{1}";

            HoldCnt++;
            cc.ChanceCode          = BySer ? string.Format(code_model, InputMaxTimes, val) : string.Format(code_model, val, InputMaxTimes);
            cc.ChipCount           = 1;//码数必须是实际码数,使用的金额队列必须是1码的队列
            cc.InputTimes          = HoldCnt;
            cc.strInputTimes       = string.Format("{0}", cc.InputTimes);
            cc.AllowMaxHoldTimeCnt = 1;
            cc.InputExpect         = ed;
            cc.StragId             = this.GUID;
            cc.NeedConditionEnd    = true;//这是必须的,才能在整体回测中触发CheckNeedEndTheChance
            //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
            cc.IsTracer = 0;
            cc.Odds     = this.CommSetting.GetGlobalSetting().Odds;
            //cc.UnitCost = this.getChipAmount(0,cc,);
            ret.Add(cc);
            return(ret);
        }
Beispiel #2
0
        public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();

            CurrChancesCnt = 0;//置零,防止后面留存
            ExpectList LastDataList = this.LastUseData();

            if (LastDataList == null)
            {
                Log(this.StragClassName, "数据为空!");
                return(ret);
            }
            if (LastDataList.Count < ReviewExpectCnt)
            {
                Log("基础数据数量不足", string.Format("小于回览期数:{0}", ReviewExpectCnt));
                return(ret);
            }
            //ExpectList LastDataList = datas;
            ExpectData PreData = LastDataList[LastDataList.Count - 2];
            //Log(string.Format("前期{0}:{1}", PreData.Expect, PreData.OpenCode), string.Format("当期{0}:{1}", LastDataList.LastData.Expect, LastDataList.LastData.OpenCode));
            //Log(string.Format("el数据长度:{0},First:{1};Last{2}", LastDataList.Count,LastDataList.FirstData.Expect,LastDataList.LastData.Expect), string.Format("原始数据长度:{0};First:{1};Last:{2}", sc.orgData.Count,sc.orgData.FirstData.Expect,sc.orgData.LastData.Expect));
            DataTableEx   dt       = sc.getSubTable(sc.orgData.Count - this.ReviewExpectCnt, this.ReviewExpectCnt);
            List <string> strCodes = new List <string>();

            for (int i = 0; i < 10; i++)//遍历每个车号/名次
            {
                List <int> coldata = null;
                string     strCol  = string.Format("{0}", (i + 1) % 10);
                dt.getColumnData(strCol, ref coldata);
                //Log(string.Format("车/次:{0}",strCol), string.Format("取得的数据:{0}",string.Join(",",coldata)));
                int RepeatCnt = 0;
                for (int j = 1; j < ReviewExpectCnt; j++)
                {
                    if (coldata[j] == coldata[j - 1])
                    {
                        RepeatCnt++;
                    }
                }
                if (RepeatCnt < this.ReviewExpectCnt - 1)//如果重复次数小于回顾次数减一,表示重复次数不够,跳过
                {
                    continue;
                }
                string strCode = "";//其实无需比较,对单个车/名次来说,矩阵都一样,策略只需建立一个即可
                strCode = string.Format("{0}/{1}", strCol, coldata[0]);

                //Log(string.Format("车/次:{0}", strCol), strCode);
                strCodes.Add(strCode);

                if (HoldCnt >= 0) //当持有次数超过指定次数后,不再增加
                {
                    HoldCnt++;    //持有次数加1
                }
                //Log("获得机会处理", string.Format("当前持有次数:{0}", HoldCnt));
                RealCnt++;
            }

            if (strCodes.Count == 0)//机会数为0
            {
                return(ret);
            }
            if (!GetRev)
            {
                OnceChance cc = new OnceChance();
                cc.SignExpectNo        = ed.Expect;
                cc.ChanceType          = 1;
                cc.ChanceCode          = string.Join("+", strCodes);
                cc.ChipCount           = strCodes.Count;//码数必须是实际码数,使用的金额队列必须是1码的队列
                cc.InputTimes          = RealCnt;
                cc.strInputTimes       = string.Format("{0}", cc.InputTimes);
                cc.AllowMaxHoldTimeCnt = 1;
                cc.InputExpect         = ed;
                cc.NeedConditionEnd    = true;
                cc.StragId             = this.GUID;
                //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
                cc.IsTracer    = 0;
                cc.Odds        = this.CommSetting.GetGlobalSetting().Odds;
                CurrChancesCnt = strCodes.Count;
                //cc.UnitCost = this.getChipAmount(0,cc,);
                ret.Add(cc);
                //获得所有机会后,统一为本次机会分配资金
                return(ret);
            }
            else
            {
                for (int i = 0; i < strCodes.Count; i++)
                {
                    NolimitTraceChance cc = new NolimitTraceChance();
                    cc.SignExpectNo        = ed.Expect;
                    cc.ChanceType          = 1;
                    cc.ChanceCode          = ChanceClass.getRevChance(strCodes[i]);
                    cc.ChipCount           = 9;//码数必须是实际码数,使用的金额队列必须是1码的队列
                    cc.InputTimes          = RealCnt;
                    cc.strInputTimes       = string.Format("{0}", cc.InputTimes);
                    cc.AllowMaxHoldTimeCnt = 1;
                    cc.InputExpect         = ed;
                    cc.StragId             = this.GUID;
                    //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
                    cc.IsTracer    = 1;
                    cc.Odds        = this.CommSetting.GetGlobalSetting().Odds;
                    CurrChancesCnt = strCodes.Count;
                    //cc.UnitCost = this.getChipAmount(0,cc,);
                    ret.Add(cc);
                }
                return(ret);
            }
        }