Пример #1
0
 private void LoadParameters()
 {
     this.parameters.Clear();
     foreach (StrategyRunner strategyRunner in this.solutionRunner.Runners.Values)
     {
         if (strategyRunner.Enabled)
         {
             Strategy strategy = strategyRunner.Strategy;
             Dictionary <string, OptimizationParameter> dictionary = new Dictionary <string, OptimizationParameter>();
             this.parameters[strategyRunner.StrategyName] = dictionary;
             foreach (FieldInfo fieldInfo in strategy.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
             {
                 object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(OpenQuant.API.OptimizationParameterAttribute), false);
                 if (customAttributes.Length > 0)
                 {
                     OpenQuant.API.OptimizationParameterAttribute parameterAttribute = customAttributes[0] as OpenQuant.API.OptimizationParameterAttribute;
                     if (!(fieldInfo.FieldType != typeof(int)) || !(fieldInfo.FieldType != typeof(float)) || (!(fieldInfo.FieldType != typeof(double)) || !(fieldInfo.FieldType != typeof(Decimal))))
                     {
                         EParamType type = (EParamType)0;
                         if (fieldInfo.FieldType == typeof(float) || fieldInfo.FieldType == typeof(double) || fieldInfo.FieldType == typeof(Decimal))
                         {
                             type = (EParamType)1;
                         }
                         OptimizationParameter optimizationParameter = new OptimizationParameter(strategyRunner.StrategyName, fieldInfo.Name, parameterAttribute.Start, parameterAttribute.Stop, parameterAttribute.Step, type);
                         dictionary[fieldInfo.Name] = optimizationParameter;
                         this.parameterList.Add(optimizationParameter);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
		private void LoadParameters()
		{
			this.parameters.Clear();
			foreach (StrategyRunner strategyRunner in this.solutionRunner.Runners.Values)
			{
				if (strategyRunner.Enabled)
				{
					Strategy strategy = strategyRunner.Strategy;
					Dictionary<string, OptimizationParameter> dictionary = new Dictionary<string, OptimizationParameter>();
					this.parameters[strategyRunner.StrategyName] = dictionary;
					foreach (FieldInfo fieldInfo in strategy.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
					{
                        object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(OpenQuant.API.OptimizationParameterAttribute), false);
						if (customAttributes.Length > 0)
						{
                            OpenQuant.API.OptimizationParameterAttribute parameterAttribute = customAttributes[0] as OpenQuant.API.OptimizationParameterAttribute;
							if (!(fieldInfo.FieldType != typeof(int)) || !(fieldInfo.FieldType != typeof(float)) || (!(fieldInfo.FieldType != typeof(double)) || !(fieldInfo.FieldType != typeof(Decimal))))
							{
								EParamType type = (EParamType)0;
								if (fieldInfo.FieldType == typeof(float) || fieldInfo.FieldType == typeof(double) || fieldInfo.FieldType == typeof(Decimal))
									type = (EParamType)1;
								OptimizationParameter optimizationParameter = new OptimizationParameter(strategyRunner.StrategyName, fieldInfo.Name, parameterAttribute.Start, parameterAttribute.Stop, parameterAttribute.Step, type);
								dictionary[fieldInfo.Name] = optimizationParameter;
								this.parameterList.Add(optimizationParameter);
							}
						}
					}
				}
			}
		}