public TickerTradeHistoryInfo DownloadItem(string baseCurrency, string marketCurrency) { SimulationStrategyDataProvider provider = new SimulationStrategyDataProvider(); Ticker ticker = Exchange.Tickers.FirstOrDefault(t => t.BaseCurrency == baseCurrency && t.MarketCurrency == marketCurrency); return(DownloadItem(ticker)); }
public StrategyOptimizationManager(StrategyBase strategy) { Strategy = strategy; DataProvider = new SimulationStrategyDataProvider(); Manager = new StrategiesManager(DataProvider); Manager.Strategies.Add(Strategy); Strategy.Manager = Manager; Strategy.OptimizationMode = true; Strategy.OptimizationParametersInitialized = false; Strategy.InitializeParametersToOptimize(); Strategy.DemoMode = true; }
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 biSimulation_ItemClick(object sender, ItemClickEventArgs e) { Stopped = false; StrategyBase strategy = (StrategyBase)this.gridView1.GetFocusedRow(); if (strategy == null) { XtraMessageBox.Show("No strategy selected."); return; } if (!strategy.SupportSimulation) { XtraMessageBox.Show("This strategy does not support simulation."); return; } StrategiesManager manager = new StrategiesManager(); manager.FileName = "SimulationStrategiesManager.xml"; StrategyBase cloned = strategy.Clone(); cloned.DemoMode = true; manager.Strategies.Add(cloned); this.siStatus.Caption = "<b>Loading data from exchanges...</b>"; IOverlaySplashScreenHandle handle = SplashScreenManager.ShowOverlayForm(gridControl1); Application.DoEvents(); SimulationStrategyDataProvider dataProvider = new SimulationStrategyDataProvider(); dataProvider.DownloadProgressChanged += OnSimulationProviderDownloadProgressChanged; this.beSimulationProgress.EditValue = 0; this.beSimulationProgress.Visibility = BarItemVisibility.Always; manager.Initialize(dataProvider); dataProvider.DownloadProgressChanged -= OnSimulationProviderDownloadProgressChanged; if (!manager.Start()) { XtraMessageBox.Show("Error starting simulation! Please check log messages"); return; } this.beSimulationProgress.EditValue = 0; this.beSimulationProgress.Visibility = BarItemVisibility.Always; this.siStatus.Caption = "<b>Running simulation...</b>"; Application.DoEvents(); Stopwatch timer = new Stopwatch(); timer.Start(); int elapsedSeconds = 0; double progress = 0; while (manager.Running) { this.beSimulationProgress.EditValue = (int)(dataProvider.SimulationProgress * this.repositoryItemProgressBar1.Maximum); if (timer.ElapsedMilliseconds / 1000 > elapsedSeconds) { elapsedSeconds = (int)(timer.ElapsedMilliseconds / 1000); this.siStatus.Caption = string.Format("<b>Running simulation... {0} sec</b>", elapsedSeconds); Application.DoEvents(); } if ((dataProvider.SimulationProgress - progress) >= 0.05) { progress = dataProvider.SimulationProgress; Application.DoEvents(); } } this.beSimulationProgress.Visibility = BarItemVisibility.Never; SplashScreenManager.CloseOverlayForm(handle); manager.Save(); this.siStatus.Caption = "<b>Simulation done.</b>"; Application.DoEvents(); //this.toastNotificationsManager1.ShowNotification("404ef86f-183c-4fea-960b-86f54e52ea76"); StrategyConfigurationManager.Default.ShowData(cloned); }