Esempio n. 1
0
        private void DownLoadMin1Bar()
        {
            string text = "当前进度:开始下载1分线.....";

            RefreshLabel(this.lblDisplay, text);
            GMCollector gmc             = new GMCollector();
            string      beginTimeString = Utils.DateTimeToString(this.DtpBeginTime.Value);
            string      endTimeString   = Utils.DateTimeToString(this.DtpEndTime.Value);
            int         i = 0;

            foreach (var item in this.CmbSymbol.Items)
            {
                string symbol = item.ToString();
                text = string.Format("当前进度:下载<{0}>的1分线", symbol);
                RefreshLabel(this.lblDisplay, text);
                List <Bar> bars = gmc.HistoryBars(symbol, 60, beginTimeString, endTimeString);
                if (bars.Count > 0)
                {
                    TradeDataAccessor.StoreMin1Bars(symbol, bars);
                }
                i++;
                RefreshProgressBar(this.PgbDisplay, i);
            }
            text = "当前进度:1分线下载完毕。";
            RefreshLabel(this.lblDisplay, text);
        }
        public override bool Execute(CancellationToken token)
        {
            string beginTime = Utils.DateTimeToString((DateTime)this.dataDate);
            string endTime   = Utils.DateTimeToString(((DateTime)this.dataDate).Date.AddDays(1));

            foreach (string symbol in this.symbols)
            {
                token.ThrowIfCancellationRequested();
                object[]   parameters = new object[] { symbol, 60, beginTime, endTime };
                List <Bar> data       = (List <Bar>) this.invokeMethod(parameters);
                if (data.Count > 0)
                {
                    TradeDataAccessor.StoreMin1Bars(symbol, data);
                    Console.WriteLine("{0}:{1} 得到数据 {2} 条", this.Name, symbol, data.Count);
                }
                else
                {
                    Console.WriteLine("{0}:{1} 没有数据", this.Name, symbol);
                }
            }
            return(true);
        }