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 }); }
public AParam(EParamType eParamType, string paramName, bool bSyncToClient, bool bSaveToDB) { this.eParamType = eParamType; this.paramName = paramName; this.bSyncToClient = bSyncToClient; this.bSaveToDB = bSaveToDB; }
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); } } } } } }
public void SetParamType(int NParam, EParamType Type) { if (NParam + 1 > this.fNParam) { this.SetNParam(NParam + 1); } this.fParamType[NParam] = Type; }
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)); }
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; }
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; }
//根据名字 解析类型 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; } } }
protected void RegisterParam(EParamType eParamType, string paramName, bool bSyncToClient = true, bool bSaveToDB = true) { dParams.Add(paramName, new AParam(eParamType, paramName, bSyncToClient, bSaveToDB)); }
public CustomParam( EParamType eType , string paramName ) { m_type = eType; m_paramName = paramName; }
public void SetParamType(int NParam, EParamType Type) { if (NParam + 1 > this.fNParam) this.SetNParam(NParam + 1); this.fParamType[NParam] = Type; }
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; }
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; }
public string mfParseFX_Parameter(string buf, EParamType eType, string szName) => throw new NotImplementedException();