Пример #1
0
        private void biTickerIntensity_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            List <TickerDownloadDataInfo> selected = GetTickersForData();
            TradeHistoryIntensityInfo     info     = new TradeHistoryIntensityInfo();

            info.DownloadProgressChanged += OnTickerDownloadProgressChanged;
            Crypto.Core.Helpers.TickerDownloadData historyInfo = null;
            ProgressForm         = new DownloadProgressForm();
            ProgressForm.Cancel += (d, ee) => {
                DownloadCanceled = true;
            };

            Thread t = new Thread(() => {
                foreach (TickerDownloadDataInfo di in selected)
                {
                    Exchange ex = Exchange.Get(di.Exchange);
                    if (!ex.Connect())
                    {
                        continue;
                    }
                    TickerInputInfo ti = new TickerInputInfo()
                    {
                        Exchange = ex.Type, Ticker = ex.Ticker(di.BaseCurrency, di.MarketCurrency), StartDate = di.StartDate, EndDate = di.EndDate, KlineIntervalMin = di.KLineIntervalMin
                    };
                    ti.TickerName = ti.Ticker.Name;
                    historyInfo   = info.DownloadItem(ti, false);
                    info.Items.Add(historyInfo);
                    info.Result.Add(historyInfo);
                }
                BeginInvoke(new MethodInvoker(() => ProgressForm.Close()));
            });

            t.Start();
            ProgressForm.ShowDialog(this);
            if (DownloadCanceled)
            {
                XtraMessageBox.Show("Downloading Canceled.");
                return;
            }

            StrategyDataForm dataForm = new StrategyDataForm();

            dataForm.Visual = info;
            dataForm.Show();
        }
Пример #2
0
        private void biDownload_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (TickerDataDownloadForm dlg = new TickerDataDownloadForm()
            {
                Owner = this
            }) {
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                DownloadCanceled = false;
                TradeHistoryIntensityInfo info = new TradeHistoryIntensityInfo();
                info.DownloadProgressChanged += OnTickerDownloadProgressChanged;
                info.Exchange = Exchange.Get(dlg.TickerInfo.Exchange);
                Core.Helpers.TickerDownloadData historyInfo = null;
                ProgressForm         = new DownloadProgressForm();
                ProgressForm.Cancel += (d, ee) => {
                    DownloadCanceled = true;
                };

                Thread t = new Thread(() => {
                    historyInfo = info.DownloadItem(dlg.TickerInfo);
                    BeginInvoke(new MethodInvoker(() => ProgressForm.Close()));
                });
                t.Start();
                ProgressForm.ShowDialog(this);
                if (DownloadCanceled)
                {
                    XtraMessageBox.Show("Downloading Canceled.");
                    return;
                }
                if (historyInfo == null)
                {
                    XtraMessageBox.Show("Error downloading ticker trade history");
                    return;
                }
                info.Items.Add(historyInfo);
                info.Result.Add(historyInfo);

                //TickerDownloadDataInfo ki = new TickerDownloadDataInfo();
                //ki.Type = TickerDataType.Candlesticks;
                //ki.Exchange = dlg.TickerInfo.Exchange;
                //ki.BaseCurrency = dlg.TickerInfo.Ticker.BaseCurrency;
                //ki.MarketCurrency = dlg.TickerInfo.Ticker.MarketCurrency;
                //ki.KLineIntervalMin = dlg.TickerInfo.KlineIntervalMin;
                //ki.StartDate = dlg.TickerInfo.StartDate;
                //ki.EndDate = dlg.TickerInfo.EndDate;
                //ki.GenerateFileName();

                //var prevItem = DataItems.FirstOrDefault(i => i.FileName.EndsWith(ki.FileName));
                //if(prevItem != null)
                //    DataItems.Remove(prevItem);
                //DataItems.Add(ki);

                //TickerDownloadDataInfo ti = new TickerDownloadDataInfo();
                //ti.Type = TickerDataType.TradeHistory;
                //ti.Type = TickerDataType.Candlesticks;
                //ti.Exchange = dlg.TickerInfo.Exchange;
                //ti.BaseCurrency = dlg.TickerInfo.Ticker.BaseCurrency;
                //ti.MarketCurrency = dlg.TickerInfo.Ticker.MarketCurrency;
                //ti.KLineIntervalMin = dlg.TickerInfo.KlineIntervalMin;
                //ti.StartDate = dlg.TickerInfo.StartDate;
                //ti.EndDate = dlg.TickerInfo.EndDate;
                //ti.GenerateFileName();

                //prevItem = DataItems.FirstOrDefault(i => i.FileName.EndsWith(ti.FileName));
                //if(prevItem != null)
                //    DataItems.Remove(prevItem);
                //DataItems.Add(ti);
                InitializeData();
            }
        }