Exemple #1
0
        protected override ExpectList getData(string strHtml)
        {
            ExpectList  ret = new ExpectList();
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(strHtml);
                XmlNodeList rows = doc.SelectNodes("/xml/row");
                if (rows.Count == 0)
                {
                    return(ret);
                }
                for (int i = rows.Count - 1; i >= 0; i--)
                {
                    ExpectData ed = new ExpectData();
                    ed.Expect   = rows[i].Attributes["expect"].Value;
                    ed.OpenCode = rows[i].Attributes["opencode"].Value;
                    ed.OpenTime = DateTime.Parse(rows[i].Attributes["opentime"].Value);
                    ret.Add(ed);
                }
            }
            catch
            {
            }
            return(ret);
        }
Exemple #2
0
        public bool Matched(ExpectData data, out int MatchCnt)
        {
            //MatchCnt = 0;
            ExpectList el = new ExpectList();

            el.Add(data);
            return(Matched(el, out MatchCnt, false));
        }
Exemple #3
0
        public object Clone()
        {
            ExpectData ret = new ExpectData();

            ret.Expect   = this.Expect;
            ret.OpenCode = this.OpenCode;
            ret.OpenTime = this.OpenTime;
            return(ret);
        }
Exemple #4
0
        protected override ExpectList getHisData(string strHtml)
        {
            ExpectList ret    = new ExpectList();
            string     strBeg = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"dt caipiao mbm\"";
            string     strEnd = "</table>";
            int        ibeg   = strHtml.IndexOf(strBeg);

            strHtml = strHtml.Substring(ibeg);
            int iend = strHtml.IndexOf(strEnd) + strEnd.Length;

            if (ibeg == 0)
            {
                return(ret);
            }
            if (iend <= 0)
            {
                return(ret);
            }
            string      txtTable = strHtml.Substring(0, iend);
            XmlDocument doc      = new XmlDocument();

            try
            {
                doc.LoadXml(txtTable);
                XmlNodeList nodelist = doc.SelectNodes("table/tr");
                for (int i = 0; i < nodelist.Count; i++)
                {
                    if (i == 0)
                    {
                        continue;
                    }
                    XmlNodeList tdlist = nodelist[i].SelectNodes("td");
                    if (tdlist.Count == 0)
                    {
                        continue;
                    }
                    ExpectData ed           = new ExpectData();
                    string     strExpect    = tdlist[0].InnerText;
                    string     strIndex     = tdlist[1].InnerText;
                    string     strOpenCodes = string.Join(",", tdlist[2].InnerText.Substring(0, 5).ToCharArray());
                    string[]   strTimes     = strExpect.Split(' ');
                    DateTime   dt           = DateTime.ParseExact(strExpect, "yyyyMMdd HH:mm", CultureInfo.InvariantCulture);
                    DateTime   bdt          = DateTime.Parse(dt.ToShortDateString());
                    string     strRindex    = "0000" + dt.Subtract(bdt).TotalMinutes.ToString();
                    ed.Expect   = string.Format("{0}{1}", strTimes[0], strRindex.Substring(strRindex.Length - 4));
                    ed.OpenCode = strOpenCodes;
                    ed.OpenTime = dt;
                    ret.Add(ed);
                }
            }
            catch (Exception ce)
            {
            }
            return(ret);
        }
        /// <summary>
        /// 机器学习-下期位移
        /// </summary>
        /// <param name="ReviewCnt">计算数据长度</param>
        /// <param name="TrainCnt">训练数据长度</param>
        /// <returns></returns>
        public Dictionary <string, double> getAllShiftCnt(int ReviewCnt, int TrainCnt)
        {
            ExpectData ed           = orgData.LastData;
            string     lastExpectId = long.Parse(ed.Expect).ToString();

            if (orgData.Count < ReviewCnt + TrainCnt + 1)
            {
                return(null);
            }
            int[,] CurrTrainSet  = new int[10, TrainCnt];
            int[,] CurrReviewSet = new int[10, ReviewCnt];
            ////if (!LastReviewShiftDistr.ContainsKey(lastExpectId))
            ////{

            ////    //LastReviewShiftDistr
            ////}
            return(null);
        }
Exemple #6
0
        public List <Dictionary <int, string> > getNoDispNums(int reviewCnt)
        {
            List <Dictionary <int, string> > ret = new List <Dictionary <int, string> >();
            int    lastId    = data.Count - 1;
            string RestModel = "1234567890";

            for (int i = 0; i < Math.Min(reviewCnt, data.Count); i++)
            {
                ExpectData currExpect             = data[lastId - i];
                Dictionary <int, string> lastData = null;
                Dictionary <int, string> newData  = new Dictionary <int, string>();
                if (i > 0)
                {
                    lastData = ret[i - 1];
                }
                for (int j = 0; j < 10; j++)
                {
                    string carNo      = currExpect.ValueList[j];
                    int    carId      = int.Parse(carNo);
                    string LastString = RestModel;
                    if (lastData != null)
                    {
                        LastString = lastData[carId];//取得最后一次的字符串
                    }
                    string strNo = string.Format("{0}", (j + 1) % 10);
                    LastString = LastString.Replace(strNo, "");
                    newData.Add(carId, LastString);
                }
                ret.Add(newData);
            }
            List <Dictionary <int, string> > reSortRet = new List <Dictionary <int, string> >();

            for (int i = 0; i < 10; i++)
            {
                Dictionary <int, string> tmp = new Dictionary <int, string>();
                for (int j = 0; j < ret.Count; j++)
                {
                    tmp.Add(j, ret[j][i]);
                }
                reSortRet.Add(tmp);
            }

            return(reSortRet);
        }
Exemple #7
0
        protected override ExpectList getData(string strHtml)
        {
            ExpectList ret    = new ExpectList();
            string     strBeg = "<table";
            string     strEnd = "</table>";
            int        ibeg   = strHtml.IndexOf(strBeg);
            int        iend   = strHtml.IndexOf(strEnd) + strEnd.Length;

            if (ibeg == 0)
            {
                return(ret);
            }
            if (iend <= ibeg)
            {
                return(ret);
            }
            string      txtTable = strHtml.Substring(ibeg, iend - ibeg);
            XmlDocument doc      = new XmlDocument();

            try
            {
                doc.LoadXml(txtTable);
                XmlNodeList nodelist = doc.SelectNodes("table/tr");
                for (int i = 0; i < nodelist.Count; i++)
                {
                    XmlNodeList tdlist = nodelist[i].SelectNodes("td");
                    if (tdlist.Count == 0)
                    {
                        continue;
                    }
                    ExpectData ed = new ExpectData();
                    ed.Expect   = tdlist[1].InnerText.Replace("-", "");
                    ed.OpenCode = tdlist[4].InnerText;
                    ed.OpenTime = DateTime.Parse(tdlist[2].InnerText);
                    ret.Add(ed);
                }
            }
            catch (Exception ce)
            {
            }
            return(ret);
        }
Exemple #8
0
        List <Dictionary <int, string> > getNoDispCars(int reviewCnt)
        {
            List <Dictionary <int, string> > ret = new List <Dictionary <int, string> >();
            int    lastId    = data.Count - 1;
            string RestModel = "1234567890";

            for (int i = 0; i < Math.Min(reviewCnt, data.Count); i++)
            {
                ExpectData currExpect             = data[lastId - i];
                Dictionary <int, string> lastData = null;
                Dictionary <int, string> newData  = new Dictionary <int, string>();
                if (i > 0)
                {
                    lastData = ret[i - 1];
                }
                for (int j = 0; j < 10; j++)
                {
                    string LastString = RestModel;
                    if (lastData != null)
                    {
                        LastString = lastData[j];//取得最后一次的字符串
                    }
                    LastString = LastString.Replace(currExpect.ValueList[j], "");
                    newData.Add(j, LastString);
                }
                ret.Add(newData);
            }
            List <Dictionary <int, string> > reSortRet = new List <Dictionary <int, string> >();

            for (int i = 0; i < 10; i++)
            {
                Dictionary <int, string> tmp = new Dictionary <int, string>();
                for (int j = 0; j < ret.Count; j++)
                {
                    tmp.Add(j, ret[j][i]);
                }
                reSortRet.Add(tmp);
            }

            return(reSortRet);
        }
Exemple #9
0
        public override List <PK10CorePress.ChanceClass> getChances(PK10CorePress.CommCollection sc, PK10CorePress.ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();
            ExpectList         el  = sc.orgData;
            List <ChanceClass> scs = new List <ChanceClass>();
            strag_CommOldClass coc = new strag_CommOldClass();

            coc.CommSetting = this.CommSetting;
            coc.ChipCount   = this.ChipCount;
            coc.FixChipCnt  = true;
            //coc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt;
            coc.BySer = this.BySer;
            //coc.ReviewExpectCnt = ;
            coc.InputMinTimes = this.InputMinTimes;
            coc.StagSetting   = new StagConfigSetting();
            if (!this.IsTracing)//未持仓时才计算过往概率
            {
                double sucrate = double.NaN;
                if (this.CommSetting.UseLocalWaveData)//如果使用本地数据,获取该期本地数据
                {
                    sucrate = this.LocalWaveData[el.LastData.Expect];
                }
                if (double.IsNaN(sucrate))               //如果数据异常,继续去寻找
                {
                    sucrate = getSucRate(el, coc, true); //该类策略全部是一次性机会,可反复下注
                }
                if (this.RateDic == null)
                {
                    this.RateDic = new Dictionary <string, double>();
                }
                if (!this.RateDic.ContainsKey(this.LastUseData().LastData.Expect))//加入胜率队列
                {
                    RateDic.Add(this.LastUseData().LastData.Expect, sucrate);
                }
                if (!this.CheckEnableIn())
                {
                    return(ret);
                }

                this.IsTracing = true;//满足条件,开始持仓
                //this.debug_maxRate = 0;
            }
            CommCollection scc = new ExpectListProcess(el).getSerialData(InputMinTimes, BySer);

            ret = coc.getChances(scc, el.LastData);
            for (int i = 0; i < ret.Count; i++)
            {
                ret[i].NeedConditionEnd  = true;
                ret[i].OnCheckTheChance += CheckNeedEndTheChance;
            }
            return(ret);
        }
Exemple #10
0
 public override List <PK10CorePress.ChanceClass> getChances(PK10CorePress.CommCollection sc, PK10CorePress.ExpectData ed)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
        public ExpectList getFileData(string filename)
        {
            ExpectList   ret  = new ExpectList();
            FileStream   file = new FileStream(filename, FileMode.Open, FileAccess.Read);
            StreamReader str  = new StreamReader(file, Encoding.Default);

            try
            {
                //用以接受FileStream对象中的数据,第2个参数是字节数组中开始写入数据的位置,它通常是0,
                //表示从数组的开端文件中向数组写数据,最后一个参数规定从文件读多少字符.
                Decoder d = Encoding.Default.GetDecoder();

                int    lcnt = 0;
                string txtline;
                while ((txtline = str.ReadLine()) != null)
                {
                    lcnt++;
                    if (lcnt <= 1)
                    {
                        continue;//标题跳过
                    }
                    if (txtline.Trim().Length == 0)
                    {
                        continue;
                    }
                    txtline = txtline.Replace("	", ",");
                    string[] items = txtline.Split(',');
                    if (items.Length != 2)
                    {
                        throw new Exception(string.Format("{0}第{1}行数据异常!", filename, lcnt));
                    }
                    ExpectData ed = new ExpectData();
                    ed.OpenCode = string.Join(",", items[1].ToCharArray());
                    string   strOrg  = items[0];
                    string[] strOrgs = strOrg.Split('-');
                    if (strOrgs.Length > 1)
                    {
                        string   strDate  = strOrgs[0];
                        string   strId    = strOrgs[1];
                        string   DstrDate = string.Format("{0}-{1}-{2}", strDate.Substring(0, 4), strDate.Substring(4, 2), strDate.Substring(6));
                        DateTime etime    = DateTime.Parse(DstrDate);
                        ed.OpenTime = etime.AddMinutes(int.Parse(strId)).AddSeconds(6);
                        ed.Expect   = ed.OpenTime.ToString("yyyy-MM-dd HH-mm-SS").Replace("-", "").Replace("/", "").Replace(":", "").Replace(" ", "").Substring(0, 12);
                    }
                    else
                    {
                        ed.Expect = strOrg;
                        string   strDate  = strOrg.Substring(0, 8);
                        string   strId    = ed.Expect.Substring(8);
                        string   DstrDate = string.Format("{0}-{1}-{2} {3}:{4}:{5}", strDate.Substring(0, 4), strDate.Substring(4, 2), strDate.Substring(6), strId.Substring(0, 2), strId.Substring(2), "06");
                        DateTime etime    = DateTime.Parse(DstrDate);
                        ed.OpenTime = etime;
                    }
                    //ed.Expect = items[0].Replace("-", "");

                    //if (ed.OpenCode == "0,0,0,0,0")



                    ret.Add(ed);
                }

                str.Close();
                //file.Close();
            }
            catch (IOException e)
            {
                str.Close();
                //file.Close();
                throw e;
            }
            return(ret);
        }
Exemple #12
0
        public override List <PK10CorePress.ChanceClass> getChances(PK10CorePress.CommCollection sc, PK10CorePress.ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();
            DataTableEx        dt  = null;

            if (this.BySer)
            {
                dt = sc.SerialDistributionTable;
            }
            else
            {
                dt = sc.CarDistributionTable;
            }
            if (dt == null)
            {
                throw new Exception("无法获得概率分布表!");
            }
            int    MatchCnt    = 0;
            string strAllCodes = "";
            double MinSucRate  = 0;

            if (this.FixChipCnt)
            {
                MinSucRate = this.CommSetting.Odds / this.ChipCount; //指定注数需要的最小胜率
            }
            for (int i = 0; i < 10; i++)
            {
                //获得各项的最小的
                List <double> coldata = null;
                string        strCol  = string.Format("{0}", (i + 1) % 10);

                string strVal   = ed.ValueList[i];
                int    ExistCnt = sc.FindLastDataExistCount(this.InputMinTimes, strCol, strVal);
                if (ExistCnt > 1)//前n次不是最后一次才出现
                {
                    continue;
                }
                dt.getColumnData(strCol, ref coldata);
                double    avgval  = coldata.Average();
                double    stdval  = ProbMath.CalculateStdDev(coldata);
                string    strSql  = string.Format("[{0}]={1}", "Id", strVal);
                string    strSort = string.Format("[{0}] asc", "Id");
                DataRow[] drs     = dt.Select(strSql, "");
                if (drs.Length != 1)
                {
                    throw new Exception("概率数据表错乱!");
                }
                int InAllViewExistCnt = int.Parse(drs[0][strCol].ToString()); //前100(指定的viewcnt)期出现的次数
                if (InAllViewExistCnt > avgval - stdval * this.StdvCnt)       //如果前100期内出现的概率大于指定的标准差数,跳过
                {
                    continue;
                }
                if (InAllViewExistCnt > this.ReviewExpectCnt * (1 - MinSucRate))//如果成功数小于对应注数的失败数
                {
                    continue;
                }
                string strCode = string.Format("{0}/{1}", BySer ? strCol : strVal, BySer ? strVal : strCol);

                MatchCnt++;
                strAllCodes = string.Format("{0}{1}{2}", strAllCodes, MatchCnt > 1 ? "+" : "", strCode);
            }
            if (MatchCnt < this.ChipCount)
            {
                return(ret);
            }
            ChanceClass cc = new ChanceClass();

            cc.SignExpectNo        = ed.Expect;
            cc.ChanceType          = 3;
            cc.InputTimes          = 1;
            cc.strInputTimes       = "1";
            cc.AllowMaxHoldTimeCnt = 1;
            cc.InputExpect         = ed;
            cc.ChipCount           = MatchCnt;
            cc.ChanceCode          = strAllCodes;
            cc.CreateTime          = ed.OpenTime;
            cc.NeedConditionEnd    = true;
            cc.OnCheckTheChance   += CheckNeedEndTheChance;
            cc.Closed = false;
            ret.Add(cc);
            return(ret);
        }
Exemple #13
0
        public bool Matched(ExpectList el, out int MatchCnt, bool getRev)
        {
            //ExpectData data = el.LastData;
            string[] strArr = ChanceCode.Split('+');
            MatchCnt = 0;
            int begid = -1;   //默认为0,多期再去寻找起点

            if (el.Count > 1) //多期考虑
            {
                if (long.Parse(this.ExpectCode) < long.Parse(el.FirstData.Expect))
                {
                    Log("错误", "匹配是否需要关闭错误", "需要关闭的机会早于数据以前,无论是否中奖,立即关闭!");
                    return(true);
                }
                begid = el.IndexOf(this.ExpectCode);
                if (begid < 0)
                {
                    Log("错误", "匹配是否需要关闭错误", "需要关闭的机会不在数据中,无论是否中奖,立即关闭!");
                    return(true);
                }
            }
            //////ExpectData inputEd = el[begid];
            //////Log("计算服务", "获取到期号信息", string.Format("expect:{0};openCode:{1}",inputEd.Expect,inputEd.OpenCode));
            for (int ei = begid + 1; ei < el.Count; ei++)
            {
                ExpectData data = el[ei];
                for (int k = 0; k < strArr.Length; k++)
                {
                    //Log("计算服务", string.Format("循环检查进入期数后的期数是否命中机会:{0}", ChanceCode), string.Format("expect:{0};openCode:{1}", data.Expect, data.OpenCode));
                    string   UseCode = getRev ? getRevChance(strArr[k]) : strArr[k];
                    string[] arr     = UseCode.Trim().Split('/');
                    string   strSer  = arr[0].Trim();
                    string   strCar  = arr[1].Trim();
                    for (int i = 0; i < strSer.Length; i++)
                    {
                        string strSerNo = strSer.Substring(i, 1).Trim();
                        int    iNo      = int.Parse(strSerNo);
                        if (iNo == 0)
                        {
                            iNo = 10;
                        }
                        for (int j = 0; j < strCar.Length; j++)
                        {
                            string strCarNo = strCar.Substring(j, 1).Trim();
                            if (strCarNo == data.ValueList[iNo - 1])
                            {
                                MatchCnt++;
                            }
                        }
                    }
                }
                if (MatchCnt > 0)//任何一期命中都需要关闭
                {
                    break;
                }
            }
            if (MatchCnt > 0)
            {
                return(true);
            }
            return(false);
        }
Exemple #14
0
        //以下为trace属性
        public bool Matched(ExpectData data)
        {
            int tmp = 0;

            return(Matched(data, out tmp));
        }