private void biRemove_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();

            ((CustomTickerStrategy)Strategy).StrategyInfo.Tickers.Remove(info);
            this.gridView1.RefreshData();
        }
예제 #2
0
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();

            if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Zip files (*.zip)|*.zip|All files (*.*)|*.*";
                dialog.Title  = "Open zip packed ticker's captured data file";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                if (!dialog.FileName.ToLower().Contains(info.TickerName.ToLower()))
                {
                    XtraMessageBox.Show("This simulation data file do not belonge to specified ticker.");
                    return;
                }

                ((ButtonEdit)sender).Text = dialog.FileName;
            }
            else
            {
                ((ButtonEdit)sender).EditValue = null;
            }
            this.gridView1.CloseEditor();
        }
        public override StrategyInputInfo CreateInputInfo()
        {
            StrategyInputInfo s = new StrategyInputInfo();
            TickerInputInfo   t = CreateTickerInputInfo();

            t.Ticker = Ticker;
            s.Tickers.Add(t);
            return(s);
        }
        public TickerDownloadData DownloadItem(Ticker ticker)
        {
            TickerInputInfo info = new TickerInputInfo()
            {
                Exchange = ticker.Exchange.Type, KlineIntervalMin = 5, Ticker = ticker, TickerName = ticker.Name
            };

            return(DownloadItem(info));
        }
        protected override TickerInputInfo CreateDefaultTickerInputInfo()
        {
            TickerInputInfo res = base.CreateDefaultTickerInputInfo();

            res.UseKline        = true;
            res.UseOrderBook    = true;
            res.UseTradeHistory = true;
            return(res);
        }
 private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
 {
     if (this.gridView1.FocusedColumn == this.colTicker)
     {
         TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();
         Exchange        ee   = Exchange.Get(info.Exchange);
         ee.Connect();
         this.exchangeTickersBindingSource.DataSource = ee.Tickers;
     }
     else if (this.gridView1.FocusedColumn == this.colKlineIntervalMin)
     {
         TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();
         Exchange        ee   = Exchange.Get(info.Exchange);
         ee.Connect();
         this.candleStickIntervalInfoBindingSource.DataSource = ee.GetAllowedCandleStickIntervals();
     }
 }
예제 #7
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();
        }
예제 #8
0
        private void biMoveDown_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();

            if (info == null)
            {
                return;
            }
            CustomTickerStrategy s = (CustomTickerStrategy)Strategy;
            int index = s.StrategyInfo.Tickers.IndexOf(info);

            if (index > s.StrategyInfo.Tickers.Count - 2)
            {
                return;
            }
            index++;
            s.StrategyInfo.Tickers.Remove(info);
            s.StrategyInfo.Tickers.Insert(index, info);
            this.gridView1.RefreshData();
        }
예제 #9
0
        private void sbOk_Click(object sender, EventArgs e)
        {
            this.dxErrorProvider1.ClearErrors();
            ExchangeType type = (ExchangeType)this.ceExchanges.EditValue;
            Exchange     ex   = Exchange.Get(type);

            ex.Connect();
            Ticker t = ex.Ticker((string)cbExchangeTickers.EditValue);

            if (t == null)
            {
                this.dxErrorProvider1.SetError(this.cbExchangeTickers, "Ticker not selected.");
            }
            if (this.leIntervals.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.leIntervals, "KLine Interval not selectged");
            }
            if (this.deEnd.DateTime <= this.deStart.DateTime)
            {
                this.dxErrorProvider1.SetError(this.deStart, "Start Date should be less than End Date");
            }
            if (this.dxErrorProvider1.HasErrors)
            {
                return;
            }
            TickerInfo = new TickerInputInfo()
            {
                Exchange          = type,
                KlineIntervalMin  = ((int)leIntervals.EditValue),
                Ticker            = t,
                TickerName        = t.Name,
                UseKline          = true,
                UseTradeHistory   = true,
                StartDate         = this.deStart.DateTime,
                EndDate           = this.deEnd.DateTime,
                AutoUpdateEndTime = false
            };

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #10
0
        public static ResizeableArray <CandleStickData> DownloadCandleStickData(TickerInputInfo info)
        {
            CachedCandleStickData savedData = new CachedCandleStickData()
            {
                Exchange = info.Exchange, TickerName = info.TickerName, IntervalMin = info.KlineIntervalMin
            };
            CachedCandleStickData cachedData = CachedCandleStickData.FromFile(CachedCandleStickData.Directory + "\\" + ((ISupportSerialization)savedData).FileName);

            if (cachedData != null)
            {
                return(cachedData.Items);
            }

            DateTime start             = DateTime.UtcNow;
            int      intervalInSeconds = info.KlineIntervalMin * 60;
            int      candleStickCount  = 10000;

            start = start.AddSeconds(-intervalInSeconds * candleStickCount);
            ResizeableArray <CandleStickData>         res       = new ResizeableArray <CandleStickData>();
            List <ResizeableArray <CandleStickData> > splitData = new List <ResizeableArray <CandleStickData> >();
            int deltaCount = 500;

            for (int i = 0; i < candleStickCount / deltaCount; i++)
            {
                ResizeableArray <CandleStickData> data = info.Ticker.GetCandleStickData(info.KlineIntervalMin, start, intervalInSeconds * deltaCount);
                if (data == null || data.Count == 0)
                {
                    continue;
                }
                res.AddRange(data);
                Thread.Sleep(300);
                start = start.AddSeconds(intervalInSeconds * deltaCount);
            }
            cachedData       = savedData;
            cachedData.Items = res;
            cachedData.Save();
            return(res);
        }
        public TickerTradeHistoryInfo DownloadItem(Ticker ticker)
        {
            SimulationStrategyDataProvider provider = new SimulationStrategyDataProvider();

            provider.DownloadProgressChanged += DownloadProgressChanged;
            TickerInputInfo info = new TickerInputInfo()
            {
                Exchange = ticker.Exchange.Type, KlineIntervalMin = 5, Ticker = ticker, TickerName = ticker.Name
            };
            ResizeableArray <CandleStickData> kline = provider.DownloadCandleStickData(info);

            if (kline == null)
            {
                LogManager.Default.Error("Cannot download candlesticks for " + ticker.Name);
                return(null);
            }

            LogManager.Default.Success("Downloaded candlesticks for " + ticker.Name);
            ticker.CandleStickData.AddRange(kline);

            ResizeableArray <TradeInfoItem> trades = provider.DownloadTradeHistory(info, ticker.CandleStickData.First().Time);

            if (trades == null)
            {
                LogManager.Default.Error("Cannot download trade history for " + ticker.Name);
                return(null);
            }
            LogManager.Default.Success("Downloaded trade history for " + ticker.Name);
            ticker.TradeHistory.AddRange(trades);

            TickerTradeHistoryInfo tradeInfo = new TickerTradeHistoryInfo()
            {
                Ticker = ticker
            };

            tradeInfo.HistogrammIntervalSec = HistogrammIntervalSec;
            return(tradeInfo);
        }
        public TickerDownloadData DownloadItem(TickerInputInfo info, bool downloadCandle)
        {
            Ticker ticker = info.Ticker;
            SimulationStrategyDataProvider provider = new SimulationStrategyDataProvider();

            provider.DownloadProgressChanged += DownloadProgressChanged;
            if (downloadCandle)
            {
                ResizeableArray <CandleStickData> kline = provider.DownloadCandleStickData(info);
                if (kline == null)
                {
                    LogManager.Default.Error("Cannot download candlesticks for " + ticker.Name);
                    return(null);
                }

                LogManager.Default.Success("Downloaded candlesticks for " + ticker.Name);
                ticker.CandleStickData.AddRange(kline);
            }

            ResizeableArray <TradeInfoItem> trades = provider.DownloadTradeHistory(info, info.StartDate);

            if (trades == null)
            {
                LogManager.Default.Error("Cannot download trade history for " + ticker.Name);
                return(null);
            }
            LogManager.Default.Success("Downloaded trade history for " + ticker.Name);
            ticker.TradeHistory.AddRange(trades);

            TickerDownloadData tradeInfo = new TickerDownloadData()
            {
                Ticker = ticker
            };

            tradeInfo.HistogrammIntervalSec = HistogrammIntervalSec;
            return(tradeInfo);
        }
        private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
        {
            TickerInputInfo info = (TickerInputInfo)this.gridView1.GetFocusedRow();

            info.TickerName = Convert.ToString(((GridLookUpEdit)sender).EditValue);
        }
 public TickerDownloadData DownloadItem(TickerInputInfo info)
 {
     return(DownloadItem(info, true));
 }