public AmoutSerials getOptSerials(DataTypePoint dtp, string type, int len, double odds, Int64 MaxValue, int FirstAmt, bool NeedAddFirst) { double prob = getProb(dtp, type, len.ToString(), null); double rodds = odds / prob / 10; return(getOptSerials_detail(type, len, rodds, MaxValue, FirstAmt, NeedAddFirst)); }
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Timer_Ex tm = sender as Timer_Ex; DataTypePoint dtp = DataTypes[tm.Name]; DateTime CurrTime = DateTime.Now;//当前时间 ExecSubscriptClass esc = new ExecSubscriptClass(DataTypes[tm.Name]); esc.OnCancelSubScript += FinishedSubscript; esc.OnCancelSubScript += CancelSubscript; esc.OnUpdateData += OnUpdateData; if (!tm.SubsciptStatus) //未订阅状态,开始订阅,设置下次启动时间到停止时间 { DateTime EndT = CurrTime.Date.Add(dtp.ReceiveEndTime.TimeOfDay); //当日的结束时间 if (CurrTime > EndT) //当前时间已经过了结束时间,不订阅,唤醒时间设置到下个周期的开始时间 { tm.Interval = CurrTime.AddDays(1).Add(dtp.ReceiveStartTime.TimeOfDay).Subtract(CurrTime).TotalMilliseconds; Log("错过取消订阅时间,不订阅", string.Format("下次唤醒订阅时间{0}", CurrTime.AddDays(1).Add(dtp.ReceiveStartTime.TimeOfDay).ToLongTimeString())); return; } esc.Subscript(CurrTime > CurrTime.Date.Add(dtp.ReceiveStartTime.TimeOfDay)); tm.SubsciptStatus = true; tm.Interval = EndT.Subtract(CurrTime).TotalMilliseconds;//当日结束时唤醒 Log("已订阅,下次唤醒取消订阅时间", EndT.ToLongTimeString()); } else//订阅状态,停止订阅,设置下次启动时间到停止时间 { DateTime BegT = DateTime.Now.Date.AddDays(1).Add(dtp.ReceiveStartTime.TimeOfDay);//当日的结束时间 esc.CancelSubscript(); tm.SubsciptStatus = false; tm.Interval = BegT.Subtract(CurrTime).TotalMilliseconds; Log("下次唤醒订阅时间", BegT.ToLongTimeString()); } }
public static string getNextExpectNo(string expect, DataTypePoint dtp) { int DateLong = dtp.ExpectCodeDateLong; int CounterMax = dtp.ExpectCodeCounterMax; string dateFmt = dtp.ExpectCodeDateFormate; //if(DateLong==0) // return string.Format("{0}", long.Parse(expect) + 1); string strDate = expect.Substring(0, DateLong); string strCounter = expect.Substring(DateLong); int CounterLong = expect.Length - strDate.Length; long counterValue = long.Parse(strCounter); DateTime currDate; if (!DateTime.TryParseExact(strDate, dateFmt, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out currDate))//不是日期,继续合上 { return(string.Format("{0}{1}", strDate, string.Format("{0}", counterValue + 1).PadLeft(CounterLong, '0'))); } else { if (counterValue < CounterMax) { return(string.Format("{0}{1}", strDate, string.Format("{0}", counterValue + 1).PadLeft(CounterLong, '0'))); } else { return(string.Format("{0}{1}", currDate.AddDays(1).ToString(dateFmt), "1".PadLeft(CounterLong, '0'))); } } }
public override DataTable getTableFromSpecCondition(DataTypePoint dtp, string expect, int Period, string strPos, string strTaget, params object[] others) { DataTable dt = new DataTable(); if (dtp.ExDataConfig.FromDataBase != "1") { int iPos = int.Parse(strPos); string strType = ""; if (iPos < 9) //2~8为任N { strType = "A"; } else if (iPos < 30) //11,14为直选2,3 { strType = "P"; } else //31,32为组2,3 { strType = "C"; } return(getCombMatchMetrix(Period, strType, int.Parse(strTaget))); } else { return(null); } return(dt); }
public static long getInterExpectCnt(string expectFrom, string expectTo, DataTypePoint dtp) { long lFrom = long.Parse(expectFrom); long lTo = long.Parse(expectTo); if (lTo <= lFrom) // { return(lFrom - lTo); } if (lTo - lFrom < dtp.ExpectCodeCounterMax) { return(Math.Max(1, lTo - lFrom)); } string currExpect = expectFrom; long ret = 1; while (true) { currExpect = getNextExpectNo(currExpect, dtp); if (currExpect.Trim() == expectTo.Trim()) { return(ret); } ret++; if (ret > 1000) { return(1); } } }
public static DataReader CreateReader(string strType, string docName, string[] codes) { DataTypePoint dtp = GlobalClass.TypeDataPoints[strType]; DataReader ret = null; switch (strType) { case "CAN28": { ret = new CAN28ExpectReader(); break; } case "TXFFC": { ret = new TXFFCExpectReader(); break; } case "CN_Stock_A": { ret = new SecurityReader(strType, docName, codes); break; } case "SCKL12": { ret = new SCKL12_ExpectReader(); break; } case "NLKL12": { ret = new NLKL12_ExpectReader(); break; } case "GDKL11": { ret = new GDKL11_ExpectReader(); break; } case "XYFT": { ret = new XYFT_ExpectReader(); break; } case "PK10": default: { ret = new ExpectReader(); break; } } return(ret); }
public PK10_HtmlDataClass(DataTypePoint dp) : base(dp) { //this.dataUrl = "https://www.52cp.cn/pk10/history";// //GlobalClass.PK10_url; //"https://www.52cp.cn/pk10/history"; this.dataUrl = GlobalClass.TypeDataPoints["PK10"].RuntimeInfo.DefaultDataUrl; //LogLib.LogableClass.ToLog("数据源url", this.dataUrl); //this.UseXmlMothed = GlobalClass.TypeDataPoints["PK10"].RuntimeInfo.DefaultUseXmlModel==1; this.UseDataType = GlobalClass.TypeDataPoints["PK10"].RuntimeInfo.DefaultUseDataType;// }
public MainForm() : base() { InitializeComponent(); gobj = new GlobalClass(); dtp = GlobalClass.TypeDataPoints.First().Value; er = DataReaderBuild.CreateReader(dtp.DataType, null, null); Program.optFunc.RefreshMainWindow += refreshData; }
public Dictionary <string, MissDataItem> getMissData(ExpectList data, DataTypePoint dtp, string currExpect, int peroid, string pos, string target, object[] others) { Dictionary <string, MissDataItem> ret = new Dictionary <string, MissDataItem>(); string key = string.Format("{0}_{1}_{2}_{3}", dtp.DataType, peroid, pos, target); if (AllBuffs == null) { AllBuffs = new Dictionary <string, MissDataBuff>(); } MissDataBuff mdb = null; if (!AllBuffs.ContainsKey(key)) { DataTable dt = bc.getTableFromSpecCondition(dtp, currExpect, peroid, pos, target, others); if (dt == null) { return(ret); } mdb = new MissDataBuff(); mdb.LastExpect = currExpect; mdb.InitList(dt, "id", peroid); AllBuffs.Add(key, mdb); } else { mdb = AllBuffs[key]; string strNext = ExpectReader.getNextExpectNo(mdb.LastExpect, dtp); string lastExpect = data.LastData.Expect.Trim(); string openCode = data.LastData.OpenCode; if (mdb.LastExpect.Trim().Equals(lastExpect)) { } else if (strNext.Trim().Equals(lastExpect)) { for (int i = 0; i < mdb.SerialDiffs.Count; i++) { string strKey = mdb.SerialDiffs[i].ItemName; int val = bc.isMatch(strKey, openCode) ? 1 : 0; mdb.SerialDiffs[i] = mdb.SerialDiffs[i].getAdd(strKey, val); } } else //防止跳,或者中断后一次多条记录 { DataTable dt = bc.getTableFromSpecCondition(dtp, currExpect, peroid, pos, target, others); if (dt == null) { return(ret); } mdb.LastExpect = currExpect; mdb.InitList(dt, "id", peroid); } mdb.LastExpect = lastExpect; } ret = mdb.getMissDataitem(); return(ret); }
public Form2(GlobalObj _gb) { gb = _gb; InitializeComponent(); if (GlobalClass.TypeDataPoints.ContainsKey("CN_Stock_A")) { dtp = GlobalClass.TypeDataPoints["CN_Stock_A"]; } //gb.Sys = new SystemGlobal(gb.w); }
protected void InitTables() { dtp = GlobalClass.TypeDataPoints[strDataType]; strChanceTable = dtp.ChanceTable; strResultTable = dtp.ResultTable; strNewestTable = dtp.NewestTable; strHistoryTable = dtp.HistoryTable; strMissHistoryTable = dtp.MissHistoryTable; strMissNewestTable = dtp.MissNewestTable; }
public static DataSet getDataSet(DataTypePoint dtp, string expect) { DataSet ds = new DataSet(); Type t = Type.GetType(dtp.ExDataConfig.convertClass); if (t == null) { return(null); } return(ds); }
public static HtmlDataClass CreateInstance(DataTypePoint dtp) { HtmlDataClass ret = null; switch (dtp.DataType) { case "TXFFC": { ret = new TXFFC_HtmlDataClass(dtp); break; } case "CAN28": { ret = new CAN28_HtmlDataClass(dtp); break; } case "SCKL12": { ret = new SCKL12_HtmlDataClass(dtp); break; } case "NLKL12": { ret = new NLKL12_HtmlDataClass(dtp); break; } case "GDKL11": { ret = new GDKL11_HtmlDataClass(dtp); break; } case "XYFT": { ret = new XYFT_HtmlDataClass(dtp); break; } case "PK10": default: { ret = new PK10_HtmlDataClass(dtp); break; } } return(ret); }
public BackTestClass(DataTypePoint _dtpName, long FromE, long buffCnt, SettingClass setting, long EndE = 0) { dtp = _dtpName; BegExpect = FromE; EndExpect = EndE; LoopCnt = buffCnt; if (_dtpName.DataType.ToUpper().Equals("CN_STOCK_A")) { //LoopCnt = 1000 * 60 * 60 * 24 * buffCnt;//1000*60*60*24 一天 } CurrSetting = setting; testIndex = 0; }
public override DataSet ExDataTable(DataTypePoint dtp, string expect, Func <DataTypePoint, string, DataSet> getDatatFunc) { if (exData == null) { exData = new Dictionary <string, DataSet>(); } string key = string.Format("{0}_{1}", dtp.DbName, expect); if (!exData.ContainsKey(key)) { DataSet ds = new DataSet(); exData.Add(key, ds); } return(exData[key]); }
void OnUpdateData(DataTypePoint dtp, Dictionary <string, ExpectList> els) { Log(dtp.DataType, "成功完成订阅"); foreach (string key in els.Keys) { if (AllHy.ContainsKey(key)) { AllHy[key] = els[key]; } else { AllHy.Add(key, els[key]); } } }
public override long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts) { DataTypePoint dtp = UsingDpt; if (mSc != null) { string strCode = cc.ChanceCode; string type = strCode.Substring(0, 1); string target = strCode.Substring(1, 1); amts = mSc.getOptSerials(dtp, type, int.Parse(target), this.CommSetting.Odds, allowInvestmentMaxValue, 1, false); } if (amts.Serials == null) { return(1); } return(getDefaultChipAmount(RestCash, cc, amts)); }
public SubscriptData() { InitializeComponent(); this.ServiceName = "接收订阅数据服务"; DataTypes = new Dictionary <string, DataTypePoint>(); int index = 0; AllHy = new Dictionary <string, ExpectList>(); if (GlobalClass.TypeDataPoints.Where(p => p.Value.SubScriptModel == 1).Count() == 0) { return; //如果订阅模式为1的数量为0,啥都不干 } foreach (string key in GlobalClass.TypeDataPoints.Keys) { DataTypePoint dtp = GlobalClass.TypeDataPoints[key]; if (dtp.SubScriptModel == 1)//订阅模式 { DataTypes.Add(key, dtp); Timer_Ex timer = new Timer_Ex(index, key) { AutoReset = true, Interval = dtp.ReceiveSeconds * 1000 }; timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); timer.Enabled = false; if (Tm_ForSubScripts == null) { Tm_ForSubScripts = new List <Timer_Ex>(); } Tm_ForSubScripts.Add(timer); index++; } } try { SaveTimer.Interval = DataTypes.Where(p => p.Value.SaveInterVal > 0).First().Value.SaveInterVal;//第一个设置了SaveInterVal的对象的值,没有会报错 } catch { SaveTimer.Interval = 5 * 60 * 1000;//默认5分钟保存一次 } SaveTimer.Enabled = false; SaveTimer.AutoReset = true; SaveTimer.Elapsed += SaveTimer_Elapsed; //.First<DataTypePoint>().SaveInterVal; }
public void InitSecurity() { foreach (string key in GlobalClass.TypeDataPoints.Keys) { DataTypePoint dtp = GlobalClass.TypeDataPoints[key]; if (dtp.RuntimeInfo == null) { dtp.RuntimeInfo = new DataPointBuff(dtp); } dtp.RuntimeInfo.DefaultDataUrl = dtp.MainDataUrl; //dtp.RuntimeInfo.DefaultUseXmlModel = dtp.SrcUseXml; dtp.RuntimeInfo.DefaultUseDataType = dtp.MainDataType; dtp.RuntimeInfo.DefaultDataDecode = dtp.DataDecode; if (dtp.IsSecurityData == 0) { LogableClass.ToLog(string.Format("Type:{0}", key), "非证券类型,无须加载基本信息!"); continue; } LogableClass.ToLog(string.Format("准备获取[{0}]股票清单", key), "开始"); dtp.RuntimeInfo.SecurityInfoList = InitSecurityClass.getAllCodes(key); if (dtp.RuntimeInfo.SecurityInfoList == null) { LogableClass.ToLog(string.Format("准备获取[{0}]股票清单", key), "失败"); continue; } LogableClass.ToLog(string.Format("获取[{0}]股票清单", key), string.Format("股票数量:{0}", dtp.RuntimeInfo.SecurityInfoList.Count)); string[] codes = dtp.RuntimeInfo.SecurityInfoList.Keys.ToArray(); dtp.RuntimeInfo.SecurityCodes = codes; LogableClass.ToLog(string.Format("准备获取[{0}]日期数据", key), "开始"); dtp.RuntimeInfo.HistoryDateList = InitSecurityClass.getStockIndexAllDateList(key); LogableClass.ToLog(string.Format("获取[{0}]日期数据", key), string.Format("日期数量:{0}", dtp.RuntimeInfo.HistoryDateList.Count)); LogableClass.ToLog(string.Format("准备获取[{0}]除权除息数据", key), "开始"); DateTime now = DateTime.Now; List <string[]> test = new List <string[]>(); //List<string[]> codeGrp = GroupBuilder.ToGroup<string>(codes, dtp.CodeGrpCnt); test.Add(new string[] { "000001" }); //dtp.RuntimeInfo.XDXRList = InitSecurityClass.getAllXDXRDataAsync(key,dtp.RuntimeInfo.getGrpCodes); dtp.RuntimeInfo.XDXRList = InitSecurityClass.getAllXDXRDataAsync(key, test); //dtp.RuntimeInfo.XDXRList = new MongoDataDictionary<XDXRData>();//用时再取 //dtp.RuntimeInfo.XDXRList = InitSecurityClass.getAllXDXRDataAsync(key, test); ToLog("获取XDXR总共经历时间", DateTime.Now.Subtract(now).TotalSeconds.ToString()); LogableClass.ToLog(string.Format("获取[{0}]除权除息数据", key), string.Format("总数量:{0}", dtp.RuntimeInfo.XDXRList.Sum(p => p.Value.Count))); //GlobalClass.TypeDataPoints[key] = dtp; } }
public DataTable getData(DataTypePoint dtp, DataTable dt, params object[] objs) { string url = dtp.ExDataConfig.InterfaceUrl; if (objs.Length > 1) { string missUrlModel = objs[0].ToString(); // "lottery={0}&period={1}&pos={2}&target={3}"; object[] args = objs.Skip(1).ToArray(); url = string.Format(dtp.ExDataConfig.InterfaceUrl + "{0}", string.Format(missUrlModel, args)); } string res = WebAccessor.GetData(url); if (res == null) { return(null); } return(ConvertToData(res, dtp, dt)); }
public frm_StragMonitor() { InitializeComponent(); //chart_ForGuide_Paint dtp = GlobalClass.TypeDataPoints.First().Value; exread = DataReaderBuild.CreateReader(dtp.DataType, null, null); PK10DataTimer.Interval = GlobalClass.TypeDataPoints.First().Value.ReceiveSeconds * 1000; PK10DataTimer.AutoReset = true; PK10DataTimer.Elapsed += new ElapsedEventHandler(RefreshPK10Data); PK10DataTimer.Enabled = false; LogTimer.Interval = 3 * 60 * 1000; LogTimer.AutoReset = true; LogTimer.Elapsed += new ElapsedEventHandler(RefreshLogInfo); LogTimer.Enabled = false; //RefreshLogInfo(null,null); //RefreshPK10Data(null, null); //RefreshPK10Data(); //RefreshPK10NoClosedChances(); dg_StragList.ContextMenuStrip = this.contextMenuStrip_OperatePlan; //dg_NoCloseChances.ContextMenuStrip = this.contextMenuStrip_OperatePlan; CheckForIllegalCrossThreadCalls = false; Program.optFunc.RefreshMonitorWindow += refreshSvrData; }
public bool hasNewsMissData(DataTypePoint dtp, string expectNo) { string strHtml = WebAccessor.GetData(dtp.ExDataConfig.MissHtmlUrl); if (strHtml == null) { return(false); } string strReg = dtp.ExDataConfig.keyReg; Regex reg = new Regex(strReg); MatchCollection mcs = reg.Matches(strHtml); if (mcs.Count > 0) { for (int i = 0; i < mcs.Count; i++)//任何一个指定正则表达式匹配,就说明是当前期数 { if (mcs[i].Groups[1].Value.ToString().Trim() == expectNo) { return(true); } } } return(false); }
public DataTable ConvertToData(string strHtml, DataTypePoint dtp, DataTable oldTable = null) { Type t = Type.GetType(dtp.ExDataConfig.convertClass); if (t == null) { return(null); } if (strHtml == null) { return(null); } DataTable dt = new DataTable(); HashSet <string> useCols = new HashSet <string>(); if (oldTable != null)//如果提供了架构,复制架构 { dt = dt.Clone(); for (int i = 0; i < dt.Columns.Count; i++) { useCols.Add(dt.Columns[i].ColumnName); } } else//如果没有架构,重新定义架构 { string[] names = dtp.ExDataConfig.dataColumns.Split(','); Dictionary <string, string> nameDic = names.ToDictionary(a => a, a => a); FieldInfo[] flds = t.GetFields(); //根据配置里指定的列建立表结构 flds.ToList().ForEach(a => { if (nameDic.ContainsKey(a.Name) && !dt.Columns.Contains(a.Name)) { dt.Columns.Add(a.Name); useCols.Add(a.Name); } }); } Web52CPMissDataClass data = new Web52CPMissDataClass(); data = data.FromJson(strHtml); if (data == null) { return(null); } if (data.status != 1) { return(null); } data.result.ForEach(a => { DataRow dr = dt.NewRow(); useCols.ToList().ForEach( c => { FieldInfo fi = t.GetField(c); if (fi != null) { dr[c] = fi.GetValue(a); } } ); dt.Rows.Add(dr); } ); return(dt); }
public List <string> generateUrl(DataTypePoint dtp) { return(null); }
void OnCalcFinished(DataTypePoint dtp) { //this.SystemStdDevs = cs.getSystemStdDevList(); //testIndex++; //testIndex++; }
public abstract System.Data.DataSet ReadExData(DataTypePoint dtp, string expectNo, Func <DataTypePoint, string, System.Data.DataSet> ConvertFunc);
public ExecSubscriptClass(DataTypePoint _dtp) { dtp = _dtp; }
public override DataSet ReadExData(DataTypePoint dtp, string expectNo, Func <DataTypePoint, string, System.Data.DataSet> ConvertFunc) { throw new NotImplementedException(); }
CalcEquitPlanGroupClass(DataTypePoint _dtp) : base(_dtp) { }
void CancelSubscript(DataTypePoint dtp, Dictionary <string, ExpectList> els) { Log(dtp.DataType, "成功取消订阅"); }