Exemple #1
0
        public void TestGUIRealTimeNoHistorical()
        {
            var config = CreateSimulateConfig();

            try {
                StarterConfigView form;
                StartGUI(config, out form);
                config.SymbolList = "IBM,GBP/USD";
                StrategyBaseTest.CleanupFiles(config.SymbolList, null);
                config.DefaultPeriod  = 10;
                config.DefaultBarUnit = BarUnit.Tick.ToString();
                config.ModelLoader    = "Example: Reversal Multi-Symbol";
                config.StarterName    = "FIXSimulatorStarter";
                config.Start();
                config.WaitComplete(120, () => { return(config.CommandWorker.IsBusy); });
                config.Stop();
                config.WaitComplete(120, () => { return(!config.CommandWorker.IsBusy); });
                Assert.IsFalse(config.CommandWorker.IsBusy, "ProcessWorker.Busy");
            }
            catch (Exception ex)
            {
                log.Error("Test failed with error: " + ex.Message, ex);
                Environment.Exit(1);
            }
            finally
            {
                execute.Exit();
                guiThread.Join();
                Factory.Release();
            }
        }
Exemple #2
0
        public void TestRealTimeNoHistorical()
        {
            var config = CreateSimulateConfig();

            config.SymbolList = "IBM,GBP/USD";
            StrategyBaseTest.CleanupFiles(config.SymbolList, null);
            config.DefaultPeriod  = 10;
            config.DefaultBarUnit = BarUnit.Tick.ToString();
            config.ModelLoader    = "Example: Reversal Multi-Symbol";
            config.StarterName    = "FIXSimulatorStarter";
            config.Start();
            config.WaitComplete(10);
            config.Stop();
            config.WaitComplete(120, () => { return(!config.CommandWorker.IsBusy); });
            Assert.IsFalse(config.CommandWorker.IsBusy, "ProcessWorker.Busy");
        }
Exemple #3
0
 public void TestGUIRealTimeDemo()
 {
     Assert.Ignore();
     StrategyBaseTest.CleanupFiles(null, null);
     try
     {
         while (true)
         {
             TestGUIIteration();
         }
     }
     catch (Exception ex)
     {
         log.Error("Test failed with error: " + ex.Message, ex);
         Environment.Exit(1);
     }
     finally
     {
         Factory.Release();
     }
 }
Exemple #4
0
        public void TestGUIIteration()
        {
            var appData = Factory.Settings["PriceDataFolder"];

            File.Delete(appData + @"\ServerCache\IBM.tck");
            var config             = new StarterConfig();
            StarterConfigView form = null;

            StartGUI(config, out form);
            try {
                config.WaitComplete(2);
                config.SymbolList = "IBM";
                StrategyBaseTest.CleanupFiles(config.SymbolList, null);
                config.DefaultPeriod  = 10;
                config.DefaultBarUnit = BarUnit.Second.ToString();
                config.ModelLoader    = "Example: Breakout Reversal";
                config.StarterName    = "Realtime Operation (Demo or Live)";
                config.Start();
                config.WaitComplete(30, () => { return(form.PortfolioDocs.Count > 0); });
                Assert.Greater(form.PortfolioDocs.Count, 0);
                var chart = form.PortfolioDocs[0].ChartControl;
                config.WaitComplete(30, () => { return(chart.IsDrawn); });
                var pane = chart.DataGraph.MasterPane.PaneList[0];
                Assert.IsNotNull(pane.CurveList);
                config.WaitComplete(30, () => { return(pane.CurveList.Count > 0); });
                Assert.Greater(pane.CurveList.Count, 0);
                var chartBars = (OHLCBarItem)pane.CurveList[0];
                config.WaitComplete(60, () => { return(chartBars.NPts >= 3); });
                Assert.GreaterOrEqual(chartBars.NPts, 3);
                config.Stop();
                config.WaitComplete(30, () => { return(!config.CommandWorker.IsBusy); });
                Assert.IsFalse(config.CommandWorker.IsBusy, "ProcessWorker.Busy");
            } catch (Exception ex) {
                log.Error("Test failed with error: " + ex.Message, ex);
                Environment.Exit(1);
            } finally {
                execute.Exit();
                guiThread.Join();
            }
        }
Exemple #5
0
 public void TestCapturedDataMatchesProvider()
 {
     Assert.Ignore();
     try
     {
         var config = CreateSimulateConfig();
         StarterConfigView form;
         StartGUI(config, out form);
         config.SymbolList = "/ESZ9";
         StrategyBaseTest.CleanupFiles(config.SymbolList, null);
         config.DefaultPeriod  = 1;
         config.DefaultBarUnit = BarUnit.Minute.ToString();
         config.EndDateTime    = DateTime.UtcNow;
         config.ModelLoader    = "Example: Reversal Multi-Symbol";
         config.StarterName    = "FIXSimulatorStarter";
         config.Start();
         config.WaitComplete(short.MaxValue);
         config.Stop();
         config.WaitComplete(1200, () => { return(!config.CommandWorker.IsBusy); });
         Assert.IsFalse(config.CommandWorker.IsBusy, "ProcessWorker.Busy");
         string appData      = Factory.Settings["AppDataFolder"];
         string compareFile1 = appData + @"\Test\MockProviderData\ESZ9.tck";
         string compareFile2 = appData + @"\Test\ServerCache\ESZ9.tck";
         using (var reader1 = Factory.TickUtil.TickFile()) {
             reader1.Initialize(compareFile1, config.SymbolList, TickFileMode.Read);
             var tickIO = Factory.TickUtil.TickIO();
             try {
                 int count = 0;
                 while (reader1.TryReadTick(tickIO))
                 {
                     count++;
                 }
             } catch (QueueException ex) {
                 Assert.IsTrue(ex.EntryType == EventType.StartHistorical || ex.EntryType == EventType.EndHistorical, "start or end historical");
             }
         }
         using (var reader1 = Factory.TickUtil.TickFile())
             using (var reader2 = Factory.TickUtil.TickFile()) {
                 reader1.Initialize(compareFile1, TickFileMode.Read);
                 reader2.Initialize(compareFile2, TickFileMode.Read);
                 var  tickIO1 = Factory.TickUtil.TickIO();
                 var  tickIO2 = Factory.TickUtil.TickIO();
                 bool result  = true;
                 int  count   = 0;
                 while (reader1.TryReadTick(tickIO1) && reader2.TryReadTick(tickIO2))
                 {
                     TimeStamp ts1 = new TimeStamp(tickIO1.UtcTime);
                     TimeStamp ts2 = new TimeStamp(tickIO2.UtcTime);
                     if (!ts1.Equals(ts2))
                     {
                         result = false;
                         log.Error("Tick# " + count + " failed. Expected: " + ts1 + ", But was:" + ts2);
                     }
                     count++;
                 }
                 Assert.IsTrue(result, "Tick mismatch errors. See log file.");
             }
     } catch (Exception ex) {
         log.Error("Test failed with error: " + ex.Message, ex);
         Environment.Exit(1);
     }
     finally
     {
         Factory.Release();
     }
 }