Exemplo n.º 1
0
        public List <ResponseSessionRecord> GetBacktestRecords(BacktestGroupRecord backtestGroup, string query)
        {
            //TODO: implement Mongo query
            var filteredList = new List <ResponseSessionRecord>();
            var completeList = MockUtilities.GenerateResponseSessionRecords(backtestGroup.GUID);

            foreach (var record in completeList)
            {
                if (record.GUID.Contains(query))
                {
                    filteredList.Add(record);
                }
            }

            return(filteredList);
        }
        public void RunBackTest(IHistDataService _histDataService, DarkLightResponse _response)
        {
            Task.Factory.StartNew(() => {
                var progressModels        = new BacktestProgressModel[numSlots];
                string key                = _response.Key;
                Random random             = new Random();
                int currentTestIndex      = -1;
                int[] slotTestIndex       = Enumerable.Range(0, numSlots).ToArray();
                double[] slotSpeed        = new double[numSlots];
                double[] slotProgress     = new double[numSlots];
                int numFinishedSlots      = 0;
                ManualResetEventSlim mres = new ManualResetEventSlim(true);
                _groupDict.Add(key, mres);

                var testList = MockUtilities.GenerateResponseSessionRecords(key);

                _broker.Publish(new StatusEvent
                {
                    Key        = key,
                    StatusType = StatusType.Begin
                });

                while (true)
                {
                    mres.Wait();
                    Thread.Sleep(100);

                    for (int s = 0; s < numSlots; s++)
                    {
                        if (slotProgress[s] < 0.0001 || slotProgress[s] >= 1.0)
                        {
                            if (currentTestIndex < testList.Count - 1)
                            {
                                currentTestIndex++;
                                slotTestIndex[s] = currentTestIndex;
                                slotSpeed[s]     = (double)random.Next(1, 8) / 100;
                                slotProgress[s]  = 0;
                            }
                            else
                            {
                                numFinishedSlots++;
                                slotSpeed[s] = 0;
                            }
                        }

                        slotProgress[s] += slotSpeed[s];
                        var testIndex    = slotTestIndex[s];
                        var test         = testList[testIndex];

                        progressModels[s] = new BacktestProgressModel
                        {
                            Slot          = "Slot " + (s + 1).ToString() + ":",
                            BacktestID    = test.GUID,
                            ProgressValue = slotProgress[s]
                        };
                    }

                    _broker.Publish(new StatusEvent
                    {
                        Key                  = key,
                        StatusType           = StatusType.Progress,
                        ProgressModels       = progressModels,
                        NumBacktestsComplete = currentTestIndex + 1,
                        NumBacktests         = testList.Count
                    });

                    if (numFinishedSlots == numSlots)
                    {
                        _broker.Publish(new StatusEvent
                        {
                            Key        = "",
                            StatusType = StatusType.Complete
                        });
                        return;
                    }
                }
            });
        }
Exemplo n.º 3
0
 public List <DarkLightTick> GetBacktestTicks(string backtestID)
 {
     //TODO: implement Mongo query
     return(MockUtilities.GenerateTicks(backtestID, 20));
 }
Exemplo n.º 4
0
 public List <BacktestGroupRecord> GetBacktestGroupRecords(string query)
 {
     //TODO: implement Mongo query
     return(MockUtilities.GenerateBacktestGroupRecords(20));
 }