Пример #1
0
 public void RegistParam(string sparam, EParamType eParamType = EParamType.String)
 {
     dParams.Add(sparam, new AParam()
     {
         paramName = sparam, paramValue = "", eParamType = eParamType
     });
 }
 public void RegistParam(string sparam, EParamType eParamType = EParamType.String, bool bSaveToDB = true, bool bSyncToClient = true)
 {
     dParams.Add(sparam, new AParam()
     {
         paramName = sparam, paramValue = "", eParamType = eParamType, bSyncToClient = bSyncToClient, bSaveToDB = bSaveToDB
     });
 }
Пример #3
0
 public AParam(EParamType eParamType, string paramName, bool bSyncToClient, bool bSaveToDB)
 {
     this.eParamType    = eParamType;
     this.paramName     = paramName;
     this.bSyncToClient = bSyncToClient;
     this.bSaveToDB     = bSaveToDB;
 }
Пример #4
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);
                     }
                 }
             }
         }
     }
 }
Пример #5
0
 public void SetParamType(int NParam, EParamType Type)
 {
     if (NParam + 1 > this.fNParam)
     {
         this.SetNParam(NParam + 1);
     }
     this.fParamType[NParam] = Type;
 }
Пример #6
0
 public void RegistParam(string sparam, EParamType eParamType = EParamType.String, bool bSaveToDB = true, bool bSyncToClient = true)
 {
     if (dParams.ContainsKey(sparam))
     {
         throw new Exception($"Already registered {sparam}");
     }
     dParams.Add(sparam, new AParam(eParamType, sparam, bSyncToClient, bSaveToDB));
 }
Пример #7
0
		public OptimizationParameter(string strategy, string name, double start, double stop, double step, EParamType type)
		{
			this.Strategy = strategy;
			this.Type = type;
			this.Name = name;
			this.Start = start;
			this.Stop = stop;
			this.Step = step;
			this.Enabled = true;
		}
Пример #8
0
        public void SetNParam(int NParam)
        {
            if (NParam <= this.fNParam)
            {
                return;
            }
            double[]     numArray1       = new double[NParam];
            EParamType[] eparamTypeArray = new EParamType[NParam];
            string[]     strArray        = new string[NParam];
            double[]     numArray2       = new double[NParam];
            double[]     numArray3       = new double[NParam];
            bool[]       flagArray       = new bool[NParam];
            double[]     numArray4       = new double[NParam];
            int          num             = Math.Min(this.fNParam, NParam);

            if (this.fNParam != 0)
            {
                for (int index = 0; index < num; ++index)
                {
                    numArray1[index]       = this.fParam[index];
                    eparamTypeArray[index] = this.fParamType[index];
                    strArray[index]        = this.fParamName[index];
                    numArray2[index]       = this.fLowerBound[index];
                    numArray3[index]       = this.fUpperBound[index];
                    flagArray[index]       = this.fIsParamFixed[index];
                    numArray4[index]       = this.fSteps[index];
                }
            }
            this.fParam        = numArray1;
            this.fParamType    = eparamTypeArray;
            this.fParamName    = strArray;
            this.fLowerBound   = numArray2;
            this.fUpperBound   = numArray3;
            this.fIsParamFixed = flagArray;
            this.fSteps        = numArray4;
            for (int index = this.fNParam; index < NParam; ++index)
            {
                this.fParamType[index]    = EParamType.Float;
                this.fParamName[index]    = "";
                this.fLowerBound[index]   = double.NegativeInfinity;
                this.fUpperBound[index]   = double.PositiveInfinity;
                this.fIsParamFixed[index] = false;
                this.fSteps[index]        = 0.0;
            }
            this.fNParam = NParam;
        }
Пример #9
0
    //根据名字 解析类型
    public void ParseParamType()
    {
        if (mType.EndsWith("[]")) //数组
        {
            switch (mType)
            {
            case "byte[]":
                mParamType = EParamType.eParamType_Byte_Array;
                mArrayType = "byte";
                break;

            case "short[]":
                mParamType = EParamType.eParamType_Short_Array;
                mArrayType = "short";
                break;

            case "ushort[]":
                mParamType = EParamType.eParamType_UShort_Array;
                mArrayType = "ushort";
                break;

            case "int[]":
                mParamType = EParamType.eParamType_Int_Array;
                mArrayType = "int";
                break;

            case "uint[]":
                mParamType = EParamType.eParamType_UInt_Array;
                mArrayType = "uint";
                break;

            case "long[]":
                mParamType = EParamType.eParamType_Long_Array;
                mArrayType = "long";
                break;

            case "ulong[]":
                mParamType = EParamType.eParamType_ULong_Array;
                mArrayType = "ulong";
                break;

            case "string[]":
                mParamType = EParamType.eParamType_String_Array;
                mArrayType = "string";
                break;

            default:
                mParamType = EParamType.eParamType_OtherData_Array;
                mArrayType = mType.Replace("[]", "");
                break;
            }
        }
        else    //普通数据
        {
            switch (mType)
            {
            case "byte": mParamType = EParamType.eParamType_Byte; break;

            case "short": mParamType = EParamType.eParamType_Short; break;

            case "ushort": mParamType = EParamType.eParamType_UShort; break;

            case "int": mParamType = EParamType.eParamType_Int; break;

            case "uint": mParamType = EParamType.eParamType_UInt; break;

            case "long": mParamType = EParamType.eParamType_Long; break;

            case "ulong": mParamType = EParamType.eParamType_ULong; break;

            case "string": mParamType = EParamType.eParamType_String; break;

            default: mParamType = EParamType.eParamType_OtherData; break;
            }
        }
    }
Пример #10
0
 protected void RegisterParam(EParamType eParamType, string paramName, bool bSyncToClient = true, bool bSaveToDB = true)
 {
     dParams.Add(paramName, new AParam(eParamType, paramName, bSyncToClient, bSaveToDB));
 }
Пример #11
0
 public CustomParam( EParamType eType , string paramName )
 {
     m_type = eType;
     m_paramName = paramName;
 }
Пример #12
0
		public void SetParamType(int NParam, EParamType Type)
		{
			if (NParam + 1 > this.fNParam)
				this.SetNParam(NParam + 1);
			this.fParamType[NParam] = Type;
		}
Пример #13
0
		public void SetNParam(int NParam)
		{
			if (NParam <= this.fNParam)
				return;
			double[] numArray1 = new double[NParam];
			EParamType[] eparamTypeArray = new EParamType[NParam];
			string[] strArray = new string[NParam];
			double[] numArray2 = new double[NParam];
			double[] numArray3 = new double[NParam];
			bool[] flagArray = new bool[NParam];
			double[] numArray4 = new double[NParam];
			int num = Math.Min(this.fNParam, NParam);
			if (this.fNParam != 0)
			{
				for (int index = 0; index < num; ++index)
				{
					numArray1[index] = this.fParam[index];
					eparamTypeArray[index] = this.fParamType[index];
					strArray[index] = this.fParamName[index];
					numArray2[index] = this.fLowerBound[index];
					numArray3[index] = this.fUpperBound[index];
					flagArray[index] = this.fIsParamFixed[index];
					numArray4[index] = this.fSteps[index];
				}
			}
			this.fParam = numArray1;
			this.fParamType = eparamTypeArray;
			this.fParamName = strArray;
			this.fLowerBound = numArray2;
			this.fUpperBound = numArray3;
			this.fIsParamFixed = flagArray;
			this.fSteps = numArray4;
			for (int index = this.fNParam; index < NParam; ++index)
			{
				this.fParamType[index] = EParamType.Float;
				this.fParamName[index] = "";
				this.fLowerBound[index] = double.NegativeInfinity;
				this.fUpperBound[index] = double.PositiveInfinity;
				this.fIsParamFixed[index] = false;
				this.fSteps[index] = 0.0;
			}
			this.fNParam = NParam;
		}
Пример #14
0
 public OptimizationParameter(string strategy, string name, double start, double stop, double step, EParamType type)
 {
     this.Strategy = strategy;
     this.Type     = type;
     this.Name     = name;
     this.Start    = start;
     this.Stop     = stop;
     this.Step     = step;
     this.Enabled  = true;
 }
Пример #15
0
 public string mfParseFX_Parameter(string buf, EParamType eType, string szName) => throw new NotImplementedException();