Exemple #1
0
        static List <DateTime> ExpandTemporalSpace(ConfigurationVariableSpace <DateTime> temporalSpace)
        {
            var expandedDateList = new List <DateTime>();

            DateTime currentDate = temporalSpace.Min;

            while (currentDate <= temporalSpace.Max)
            {
                //if (currentDate.DayOfWeek != DayOfWeek.Saturday && currentDate.DayOfWeek != DayOfWeek.Sunday)
                expandedDateList.Add(currentDate);

                currentDate = currentDate.AddDays(1);
            }

            return(expandedDateList);
        }
Exemple #2
0
        /*
         * public static BacktestGroupRecord CreateBacktestGroupRecord(string guid)
         * {
         *  var record = new BacktestGroupRecord();
         *  record.GUID = guid;
         *
         *  var responseConfigArr = guid.Split(new[] { "|" }, 2, StringSplitOptions.None);
         *
         *  record.ResponseType = responseConfigArr[0];
         *  record. = CreateConfigurationSpace(responseConfigArr[1]);
         *
         *  return record;
         * }
         */
        public static ConfigurationSpace CreateConfigurationSpace(string configString)
        {
            int indexLastTrade  = configString.LastIndexOf("|");
            int indexFirstTrade = configString.Substring(0, indexLastTrade).LastIndexOf("|");
            var minDateString   = configString.Substring(indexFirstTrade + 1, indexLastTrade - indexFirstTrade - 1);
            var maxDateString   = configString.Substring(indexLastTrade + 1, configString.Length - indexLastTrade - 1);
            var minDate         = Convert.ToDateTime(minDateString);
            var maxDate         = Convert.ToDateTime(maxDateString);
            var temporalSpace   = new ConfigurationVariableSpace <DateTime>("TradeDate", minDate, maxDate, 1);

            string paramString    = configString.Substring(0, indexFirstTrade);
            var    paramSpaceList = ParseParameterSpace(paramString);

            var configSpace = new ConfigurationSpace {
                ParameterSpace = paramSpaceList, TemporalSpace = temporalSpace
            };

            return(configSpace);
        }
Exemple #3
0
        public static List <BacktestGroupRecord> GenerateBacktestGroupRecords(int numGroups)
        {
            var    groupRecords         = new List <BacktestGroupRecord>();
            Random random               = new Random();
            int    iRandomResponseIndex = random.Next(1, _responseTypes.Length + 1) - 1;
            var    responseType         = _responseTypes[iRandomResponseIndex];

            for (int i = 0; i < numGroups; i++)
            {
                var paramSpaceList = new List <ConfigurationVariableSpace <double> >();
                paramSpaceList.Add(new ConfigurationVariableSpace <double>("XMACoefficient", 0, random.Next(10, 20), 1));
                int intervalMin = random.Next(1, 3) * 5 + 5;
                int intervalMax = random.Next(2, 3) * 5 + intervalMin;
                paramSpaceList.Add(new ConfigurationVariableSpace <double>("IntervalSize", intervalMin, intervalMax, 1));

                int daysBack      = -random.Next(25, 35);
                int daysLong      = random.Next(1, 2) * 4 + 3;
                var startDate     = DateTime.Now.AddDays(daysBack);
                var endDate       = startDate.AddDays(daysLong);
                var temporalSpace = new ConfigurationVariableSpace <DateTime>("TradeDate", startDate, endDate, 1);

                var configurationSpace = new ConfigurationSpace();
                configurationSpace.ParameterSpace = paramSpaceList;
                configurationSpace.TemporalSpace  = temporalSpace;

                groupRecords.Add(new BacktestGroupRecord
                {
                    GUID         = CommonFunctions.GenerateBacktestGroupGUID(responseType, configurationSpace),
                    CreateDate   = DateTime.Now.AddDays(-random.Next(1, 7)).AddSeconds(random.Next(0, 59)),
                    NumBacktests = configurationSpace.GetSpaceSize(),
                    MaxPNL       = Math.Round(100 * random.NextDouble(), 2),
                    MinPNL       = Math.Round(-100 * random.NextDouble(), 2)
                });
            }

            return(groupRecords);
        }