public bool Calculate() { if (Exchange == null) { LogManager.Default.Error("Exchange not specified"); return(false); } if (!Exchange.Connect()) { LogManager.Default.Error("Exchange not connected"); return(false); } foreach (string baseCurr in BaseCurrencies) { List <Ticker> tickers = Exchange.Tickers.Where(t => t.BaseCurrency == baseCurr && (MarketCurrencies == null || MarketCurrencies.Contains(t.MarketCurrency))).ToList(); foreach (Ticker ticker in tickers) { TickerDownloadData tradeInfo = DownloadItem(ticker); if (tradeInfo == null) { continue; } Result.Add(tradeInfo); Items.Add(tradeInfo); RaiseTickerAdded(tradeInfo); } } return(true); }
protected void RaiseTickerAdded(TickerDownloadData info) { if (TickerAdded != null) { TickerAdded(this, new TickerTradeHistoryInfoEventArgs() { Info = info }); } }
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(); }
private void barButtonItem5_ItemClick_1(object sender, 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); Crypto.Core.Helpers.TickerDownloadData historyInfo = null; ProgressForm = new DownloadProgressForm(); ProgressForm.Cancel += (d, ee) => { DownloadCanceled = true; }; Thread t = new Thread(() => { historyInfo = info.DownloadItem(dlg.TickerInfo.Ticker.BaseCurrency, dlg.TickerInfo.Ticker.MarketCurrency); 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); StrategyDataForm dataForm = new StrategyDataForm(); dataForm.Visual = info; dataForm.Show(); } }
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); }