public static MongoDataDictionary <XDXRData> getAllXDXRDataAsync(string DataType, List <string[]> codeGrp) { if (GlobalClass.TypeDataPoints[DataType].NeedLoadAllXDXR == 0) { return(null); } DateTime now = DateTime.Now; //MongoDataDictionary<XDXRData> ret = new MongoDataDictionary<XDXRData>(); ////DateSerialCodeDataBuilder dcdb = new DateSerialCodeDataBuilder("CN_Stock_A",GlobalClass.TypeDataPoints["CN_Stock_A"].XDXRTable,codes); SecurityGrpReader <XDXRData> sgr = new SecurityGrpReader <XDXRData>(); sgr.CheckEvent = (a, b, c, d, f) => { }; MongoDataDictionary <XDXRData> data = sgr.GetResult(codeGrp, (a) => { XDXRReader reader = new XDXRReader(GlobalClass.TypeDataPoints[DataType].DataType, GlobalClass.TypeDataPoints[DataType].XDXRTable, a); MongoDataDictionary <XDXRData> res = reader.GetAllCodeDateSerialDataList <XDXRData>(true); return(res); }, GlobalClass.TypeDataPoints[DataType].MaxThreadCnt, 1); return(data); }
private void btn_TestDayData_Click(object sender, EventArgs e) { //string code = "600519"; ////if(!dtp.RuntimeInfo.SecurityCodes.Contains(code)) ////{ //// MessageBox.Show(string.Format("证券{0}不存在!",code)); //// return; ////} int MaxThrdCnt = int.Parse(this.txt_maxThreadCnt.Text); int GrpUnitCnt = int.Parse(this.txt_GrpUnitCnt.Text); int ThrdInterVal = int.Parse(this.txt_ThrdInterval.Text); CommMarketClass cmc = new CommMarketClass(dtp); string strendT = this.txt_endT.Text; string strbegT = this.txt_begT.Text; if (useCodes == null) { useCodes = cmc.GetMarketsStocks("000001", strendT, 500, true, true, false); } string[] currCodes = new string[useCodes.Length]; try { Array.Copy(useCodes, 0, currCodes, 0, currCodes.Length); List <string[]> codeGrps = GroupBuilder.ToGroup <string>(currCodes, currCodes.Length / dtp.ThreadUnitCnt); begT = DateTime.Now; DisplayCnt(currCodes.Length, codeGrps.Count, 0, 0, 0); SecurityGrpReader <StockMongoData> sgr = new SecurityGrpReader <StockMongoData>(); sgr.CheckEvent = DisplayCnt; MongoDataDictionary <StockMongoData> data = sgr.GetResult(codeGrps, (a) => { SecurityReader sr = new SecurityReader(dtp.DataType, dtp.HistoryTable, a); MongoDataDictionary <StockMongoData> res = sr.GetAllCodeDateSerialDataList <StockMongoData>(strbegT, strendT); return(res); }, dtp.MaxThreadCnt, 1); DisplayCnt(currCodes.Length, codeGrps.Count, MaxThrdCnt, 0, data.Count); begT = DateTime.Now; List <MongoDataDictionary <StockMongoData> > datalist = GroupBuilder.ToGroup <StockMongoData>(data, currCodes.Length / dtp.ThreadUnitCnt); sgr.CheckEvent = DisplayCnt; data = sgr.GetResult(datalist, (a) => { return(new SecurityReader(dtp.DataType).FQ(a, dtp.RuntimeInfo.XDXRList)); }, dtp.MaxThreadCnt, 1); DisplayCnt(currCodes.Length, codeGrps.Count, MaxThrdCnt, 0, data.Count); //// reader.GetAllCodeDateSerialDataList<StockMongoData>("2015-07-15", "2019-03-27"); ////data = reader.Stock_FQ(data, dtp.RuntimeInfo.XDXRList); ////MongoReturnDataList<StockMongoData> fqdata = reader.Stock_FQ(code, data); ////////int n = 0; ////////StockMongoData testobj = null; ////////var test = fqdata.Where(a => (a.date == "2015-07-15")); ////////testobj = test.First(); ////////MessageBox.Show(string.Format("{0},{1}", testobj.date, testobj.close)); ////////n = fqdata.Count/2; ////////MessageBox.Show(string.Format("{0},{1}", fqdata[n].date, fqdata[n].close)); ////////n = fqdata.Count-1; ////////MessageBox.Show(string.Format("{0},{1}", fqdata[n].date, fqdata[n].close)); ////EMA ema1 = new EMA(fqdata.ToList(a => a.close).ToArray(),12); ////EMA ema2 = new EMA(fqdata.ToList(a => a.close).ToArray(), 26); ////Matrix e1 = ema1.GetResult(); ////Matrix e2 = ema2.GetResult(); ////int n = fqdata.Count - 1; ////MessageBox.Show(string.Format("12:{0:f2},26:{1:f2}",e1[n-1,0],e2[n-1,0])); ////MACD macd = new MACD(fqdata.ToList(a => a.close).ToArray()); ////Matrix ret = macd.GetResult(); ////int cnt = 10; ////for (int i = 0; i < cnt; i++) ////{ //// MessageBox.Show(string.Format("{0}:{4:f2}=>Diff:{1:f2};DEA:{2:f2};MACD:{3:f2}", fqdata[n - i].date, ret.Detail[n - i, 0], ret.Detail[n - i, 1], ret.Detail[n - i, 2],fqdata[n-i].close)); ////} } catch (Exception ce) { MessageBox.Show(ce.Message); } }