private void Btn_test_Click(object sender, RoutedEventArgs e) { try { tmrCallBgWorker.Interval = SettingClass.timmer > 0 ? SettingClass.timmer:500; tmrCallBgWorker.Start(); btn_connect.Content = "Starting"; btn_disconnect.Content = "Stop"; btn_connect.IsEnabled = false; btn_disconnect.IsEnabled = true; SettingClass = (SettingClass)SaveObject.Load_data(SaveObject.Pathsave); if (SettingClass.PLCTimeOut == 0) { SettingClass.PLCTimeOut = 3000; } if (SettingClass.timmer == 0) { SettingClass.timmer = 30000; } LoadDataMQCStarting(); CountRun = 1; // SettingClass = (SettingClass) SaveObject.Load_data(SaveObject.Pathsave); } catch (Exception exc) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "get data first test", exc.Message); } }
private void ConfigureWindow_Closed(object sender, EventArgs e) { if (System.IO.File.Exists(SaveObject.Pathsave)) { SettingClass = (SettingClass)SaveObject.Load_data(SaveObject.Pathsave); } }
protected void Button4_Click(object sender, EventArgs e) { SettingClass objsett = new SettingClass(); objsett.Ftname = txtftname.Text; objsett.Mdname = txtmdname.Text; objsett.Ltname = txtltname.Text; objsett.Ddob = txtudob.Text; objsett.Gender1 = radiomale.Text; objsett.Gender1 = radioFemale.Text; objsett.Course1 = stream.SelectedItem.Text; objsett.Batch1 = txtubatch.Text; objsett.Address = txtaddress.Text; objsett.Mob = txtmno.Text; objsett.Bldg = txtbg.Text; objsett.Emaill = txtuemail.Text; objsett.Aemail = txtaemail.Text; objsett.Uid = Convert.ToString(Session["Userid"]); string filename = Path.GetFileName(userphoto.PostedFile.FileName); string ext = Path.GetExtension(filename); if (ext.ToLower() == ".jpg" || ext.ToLower() == ".bmp" || ext.ToLower() == ".png" || ext.ToLower() == ".jpeg") { string src = Server.MapPath("~/Photo") + "\\" + txtftname.Text + ".JPG"; userphoto.PostedFile.SaveAs(src); string picpath = "~/Photo/" + txtftname.Text + ".JPG"; objsett.Photo = picpath; } objsett.InsertStudent(); }
public StragClass() : base() { CommSetting = new SettingClass(); //SetDefaultValueAttribute(); StagSetting = new StagConfigSetting(); StagSetting = this.getInitStagSetting(); }
public BackTestClass(long From, long buffCnt, SettingClass setting) { BegExpect = From; LoopCnt = buffCnt; CurrSetting = setting; testIndex = 0; }
readonly XmlSerializer xsSets = new XmlSerializer(typeof(SettingClass));//сериализер для настроек //открывает настройки, если нету - создаёт private void OpenOrCreateSets() { try//пытаемся загрузить настройки { using (FileStream fs = File.OpenRead(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Binder\settings.xml")) { sets = (SettingClass)xsSets.Deserialize(fs); } } catch { SaveSets(); }//если не получилось то сохраняем стандартные }
void Set() // 初期化。 { // フォルダの確認。 if (!Directory.Exists(filePath)) { Debug.Log("FileManager:初回起動です。フォルダを作成します。ファイルの保存場所は:" + filePath); Directory.CreateDirectory(filePath); } SettingClass.Load(); Setting.PlayCount++; Setting.PlayTime += Setting.PlayEndTime; SettingClass.Save(); }
public BackTestClass(DataTypePoint _dtpName, long FromE, long buffCnt, SettingClass setting, long EndE = 0) { dtp = _dtpName; BegExpect = FromE; EndExpect = EndE; LoopCnt = buffCnt; if (_dtpName.DataType.ToUpper().Equals("CN_STOCK_A")) { //LoopCnt = 1000 * 60 * 60 * 24 * buffCnt;//1000*60*60*24 一天 } CurrSetting = setting; testIndex = 0; }
/// <summary> /// /// </summary> /// <param name="el">当期数据</param> /// <param name="CommSetting">通用设置</param> /// <param name="ExistChances">需要分配给组的未关闭的数据</param> public bool initRunningData(SettingClass CommSetting, List <ChanceClass <T> > ExistChances) { ////if (el.Count>this.UseStrag.ReviewExpectCnt) ////{ //// return false; ////} //未关闭列表只代表服务器计算,未包括客户自定义的。所以不是全部,要和数据库合并才全面 CurrSetting = CommSetting; CurrExistChanceList = new Dictionary <string, ChanceClass <T> >(); //Log("错误", "并没有","测试"); //ToLog("计算服务", "策略执行准备", "为每个组合分配未关闭的机会"); for (int i = 0; i < ExistChances.Count; i++) { ChanceClass <T> cc = ExistChances[i]; //Log("错误", cc.ChanceCode, cc.ToDetailString()); bool Matched = false; if (this.AllNoClosedChances.ContainsKey(cc.GUID))//先检查内存,如果已经存在,直接加入 { if (!CurrExistChanceList.ContainsKey(cc.GUID)) { CurrExistChanceList.Add(cc.GUID, cc); } continue; } foreach (string j in this.UseStrags.Keys)//检查数据表,如果该机会是在本组所拥有的表内 { if (j == cc.StragId) { if (!CurrExistChanceList.ContainsKey(cc.GUID)) { CurrExistChanceList.Add(cc.GUID, cc); } else { ToLog("计算服务", "相同的策略出现了同一个机会", string.Format("策略{0}:{1}", cc.StragId, cc.ChanceCode)); } Matched = true; break; } } if (!Matched) { //ToLog("计算服务", "该机会不隶属于任何策略", cc.ChanceCode);//用户自定义机会,等会处理 } } AllNoClosedChances = new Dictionary <string, ChanceClass <T> >(); //ToLog("计算服务", "策略执行准备", string.Format("为本组合分配未关闭的机会数为{0};", CurrExistChanceList.Count)); return(true); }
public void ReadAndCheckValuesForApplicationAndEnvironment() { //Arrange SqliteConnection connection = new SqliteConnection("Data Source=InMemorySample;Mode=Memory;Cache=Shared"); ConfigurationBuilder configuration = new ConfigurationBuilder(); configuration.Sources.Clear(); configuration.AddEFCoreConfiguration <PersonDbContext>(options => options.UseSqlite(connection)); configuration.AddEFCoreConfiguration <PersonDbContext>(options => options.UseSqlite(connection), application: "Mobile", environment: "Development"); //Act IConfigurationRoot configurationRoot = configuration.Build(); //Assert Assert.Equal("Answer to the Ultimate Question of Life, the Universe, and Everything", configurationRoot.GetValue <string>("StringValue")); Assert.Equal(42, configurationRoot.GetValue <int>("IntegerValue")); Assert.True(configurationRoot.GetValue <bool>("BooleanValue")); Assert.Equal("Ich komme aus der Tuerkei!", configurationRoot.GetValue <string>("NestedValues:level1value:level2value")); Assert.Equal(10, configurationRoot.GetSection("ArrayValue").GetChildren().Count()); for (int i = 0; i < 10; i++) { Assert.Equal(i + 1, configurationRoot.GetValue <int>($"ArrayValue:{i}")); } Assert.Equal(4, configurationRoot.GetSection("ListValue").GetChildren().Count()); for (int i = 0; i < 4; i++) { Assert.Equal(i + 1, configurationRoot.GetValue <int>($"ListValue:{i}:Attr1")); Assert.Equal($"{i + 1}", configurationRoot.GetValue <string>($"ListValue:{i}:Attr2")); } SettingClass settingClass = new SettingClass(); configurationRoot.Bind("ClassValue", settingClass); Assert.Equal("Wie alt bist du?", settingClass.StringValue); Assert.Equal(25, settingClass.IntegerValue); Assert.False(settingClass.BooleanValue); Assert.Equal("1.0.0", configurationRoot.GetValue <string>("Version")); Assert.Equal(1, configurationRoot.GetValue <int>("VersionNumber")); Assert.False(configurationRoot.GetValue <bool>("ForceToDownload")); }
public void ReadAndCheckValuesForEnvironment() { //Arrange DbConnection connection = new SqlConnection(_fixture.TestSettings.MssqlConnectionString); ConfigurationBuilder configuration = new ConfigurationBuilder(); configuration.Sources.Clear(); configuration.AddEFCoreConfiguration <PersonDbContext>(options => options.UseSqlServer(connection)); configuration.AddEFCoreConfiguration <PersonDbContext>(options => options.UseSqlServer(connection), environment: "Development"); //Act IConfigurationRoot configurationRoot = configuration.Build(); //Assert Assert.Equal("Answer to the Ultimate Question of Life, the Universe, and Everything", configurationRoot.GetValue <string>("StringValue")); Assert.Equal(41, configurationRoot.GetValue <int>("IntegerValue")); Assert.False(configurationRoot.GetValue <bool>("BooleanValue")); Assert.Equal("Ich komme aus Tuerkei!", configurationRoot.GetValue <string>("NestedValues:level1value:level2value")); Assert.Equal(10, configurationRoot.GetSection("ArrayValue").GetChildren().Count()); for (int i = 0; i < 10; i++) { Assert.Equal(10 - i, configurationRoot.GetValue <int>($"ArrayValue:{i}")); } Assert.Equal(4, configurationRoot.GetSection("ListValue").GetChildren().Count()); for (int i = 0; i < 4; i++) { Assert.Equal(4 - i, configurationRoot.GetValue <int>($"ListValue:{i}:Attr1")); Assert.Equal($"{4 - i}", configurationRoot.GetValue <string>($"ListValue:{i}:Attr2")); } SettingClass settingClass = new SettingClass(); configurationRoot.Bind("ClassValue", settingClass); Assert.Equal("Wie alt sind Sie?", settingClass.StringValue); Assert.Equal(41, settingClass.IntegerValue); Assert.True(settingClass.BooleanValue); }
/// <summary> /// 模拟回归 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_VirExchange_Click(object sender, EventArgs e) { StragRunPlanClass[] plans = this.runPlanPicker1.Plans; if (plans == null || plans.Length == 0) { return; } SCList = plans.ToList(); if (!RunVirExchange) { if (MessageBox.Show("确定开始模拟成交?", "确认", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } if (RunVirExchange) { if (MessageBox.Show("确定停止模拟成交?", "确认", MessageBoxButtons.YesNo) == DialogResult.No) { return; } try { if (th.ThreadState == ThreadState.Running) { th.Abort(); } } catch { } th = null; this.timer_Tip.Enabled = false; RunVirExchange = false; return; } this.RunVirExchange = true; //this.btn_VirExchange.Text = "停止"; //this.Cursor = Cursors.WaitCursor; //es = new ExchangeService(int.Parse(this.txt_InitCash.Text),double.Parse(this.txt_Odds.Text)); SettingClass setting = new SettingClass(); setting.SetGlobalSetting(this.globalSetting); setting.GrownMaxVal = int.Parse(this.txt_GrownMaxVal.Text); setting.GrownMinVal = int.Parse(this.txt_GrownMinVal.Text); setting.DispRows = int.Parse(this.txt_MinCols.Text); setting.minColTimes = new int[10]; setting.UseLocalWaveData = this.checkBox_UseBuffRsult.Checked; AssetUnitClass auc = new AssetUnitClass(); if (Program.AllSettings.AllAssetUnits.Count > 0)//如果存在资产管理单元,所有计划均绑定到第一个上进行测试 { auc = Program.AllSettings.AllAssetUnits.Values.First(); } es = auc.ExchangeServer; if (es != null) { es.Reset(); } //设置所有默认值 SCList.ForEach(p => p.PlanStrag.CommSetting = setting); SCList.ForEach(p => p.AssetUnitInfo = auc); SCList.ForEach(p => p.Running = true); //if (SCList.Count == 1) //{ // //SCList[0].PlanStrag = sc; SCList.ForEach(p => p.IncreamType = this.checkBox_CreamModel.Checked ? InterestType.CompoundInterest : InterestType.SimpleInterest); SCList.ForEach(p => p.AutoRunning = true); ////SCList.ForEach(p=>p.FixAmt = 1); ////SCList.ForEach(p=>p.FixRate = 0.01); SCList.ForEach(p => p.AllowMaxHoldTimeCnt = int.Parse(txt_AllowMaxHoldTimeCnt.Text)); if (SCList.Count == 1) { SCList.ForEach(p => p.PlanStrag.ChipCount = int.Parse(this.txt_ChipCnt.Text)); } //} #region 用新的计算进行回测 ////////////////for (int i = 0; i < 9; i++) ////////////////{ //////////////// TextBox tb = this.Controls.Find(string.Format("txt_minColTimes{0}", i + 1), true)[0] as TextBox; //////////////// setting.minColTimes[i] = int.Parse(tb.Text); ////////////////} ////////////////setting.MaxHoldingCnt = int.Parse(this.txt_MaxHoldChanceCnt.Text); ////////////////setting.Odds = double.Parse(this.txt_Odds.Text); ////////////////setting.InitCash = int.Parse(this.txt_InitCash.Text); ////////////////Assembly asmb = typeof(StragClass).Assembly;// Assembly.LoadFrom("EnterpriseServerBase.dll"); ////////////////btc = new BackTestClass(long.Parse(txt_begExpNo.Text), long.Parse(txt_LoopCnt.Text), setting); ////////////////////Type sct = asmb.GetType(ddl_StragName.SelectedValue.ToString()); ////////////////if (!checkBox_MixAll.Checked) ////////////////{ //////////////// ////sc = Activator.CreateInstance(sct) as StragClass; //////////////// sc.CommSetting = setting; //////////////// sc.ChipCount = int.Parse(this.txt_ChipCnt.Text); //////////////// sc.FixChipCnt = (this.txt_FixChipCnt.Text.Trim() == "0") ? false : true; //////////////// sc.ReviewExpectCnt = int.Parse(this.txt_reviewExpCnt.Text); //////////////// sc.InputMinTimes = int.Parse(this.txt_minInputTimes.Text); //////////////// if (sc.StagSetting.IsLongTermCalc) //////////////// { //////////////// sc.ReviewExpectCnt = sc.ReviewExpectCnt + sc.InputMinTimes; //////////////// } //////////////// sc.InputMaxTimes = int.Parse(this.txt_maxInputTimes.Text); //////////////// sc.ExcludeBS = this.chkb_exclueBS.Checked; //////////////// sc.ExcludeSD = this.chkb_exclueSD.Checked; //////////////// sc.BySer = this.chkb_bySer.Checked; //////////////// sc.OnlyBS = this.chkb_onlyBS.Checked; //////////////// sc.OnlySD = this.chkb_onlySD.Checked; //////////////// sc.GetRev = this.chkb_getRev.Checked; //////////////// if (sc is IProbCheckClass) //////////////// { //////////////// (sc as IProbCheckClass).StdvCnt = double.Parse(this.txt_StdvCnt.Text); //////////////// } //////////////// //sc.AllowMaxHoldTimeCnt = int.Parse(this.txt_AllowMaxHoldTimeCnt.Text); //////////////// sc.MinWinRate = double.Parse(this.txt_minRate.Text); //////////////// ////double p = double.Parse(this.txt_ChipCnt.Text) / setting.Odds; //////////////// ////double Normal_p = double.Parse(this.txt_ChipCnt.Text) / 10; //////////////// ////double b = double.Parse(this.txt_Odds.Text); //////////////// ////double q = 1 - p; //////////////// sc.StagSetting = sc.getInitStagSetting(); //////////////// ////sc.StagSetting.BaseType.ChipRate = (p * b - q) / b; //////////////// //sc.StagSetting.BaseType.IncrementType = this.checkBox_CreamModel.Checked ? InterestType.CompoundInterest : InterestType.SimpleInterest; //////////////// if (setting.UseLocalWaveData && sc is ProbWaveSelectStragClass)//是长期概率分布类 //////////////// { //////////////// DataTable dt = new PK10ProbWaveDataInterface().GetProWaveResult(long.Parse(txt_begExpNo.Text)); //////////////// (sc as ProbWaveSelectStragClass).LocalWaveData = new GuideResult(dt); //////////////// } //////////////// StragRunPlanClass sr = new StragRunPlanClass(); //////////////// sr.PlanStrag = sc; //////////////// sr.IncreamType = this.checkBox_CreamModel.Checked ? InterestType.CompoundInterest : InterestType.SimpleInterest; //////////////// sr.AutoRunning = true; //////////////// sr.FixAmt = 1; //////////////// sr.FixRate = 0.01; //////////////// SCList.Add(sr); ////////////////} ////////////////else ////////////////{ //////////////// for (int i = 2; i < 9; i++) //////////////// { //////////////// for (int j = 0; j < 2; j++) //////////////// { //////////////// StragClass sobj = Activator.CreateInstance(sct) as StragClass; //////////////// sobj.CommSetting = setting; //////////////// sobj.ChipCount = i; //////////////// sobj.FixChipCnt = (this.txt_FixChipCnt.Text.Trim() == "0") ? false : true; //////////////// sobj.ReviewExpectCnt = sobj.CommSetting.minColTimes[i - 1] + 1; //////////////// sobj.BySer = j==1; //////////////// sobj.MinWinRate = double.Parse(this.txt_minRate.Text); //////////////// //sobj.AllowMaxHoldTimeCnt = 100; //////////////// sobj.StagSetting = sobj.getInitStagSetting(); //////////////// //sobj.StagSetting.BaseType.IncrementType = this.checkBox_CreamModel.Checked ? InterestType.CompoundInterest : InterestType.SimpleInterest; //////////////// StragRunPlanClass sr = new StragRunPlanClass(); //////////////// sr.PlanStrag = sobj; //////////////// sr.IncreamType = this.checkBox_CreamModel.Checked ? InterestType.CompoundInterest : InterestType.SimpleInterest; //////////////// sr.AutoRunning = true; //////////////// sr.FixAmt = 1; //////////////// sr.FixRate = 0.01; //////////////// SCList.Add(sr); //////////////// } //////////////// } ////////////////} //////////////////sc.MinWinRate = double.Parse(this.txt_Odds.Text) *double.Parse(this.txt_minRate.Text); //////////////////凯利公式 (p*b-q)/b //////////////////凯利公式 (p*b-q)/b //////////////////////DialogResult rs = MessageBox.Show(sc.StagSetting.BaseType.ChipRate.ToString(), "胜率", MessageBoxButtons.OKCancel) ; //////////////////////if (rs == DialogResult.Cancel) //////////////////////{ ////////////////////// return; //////////////////////} #endregion //this.Cursor = Cursors.WaitCursor; this.chart1.Series.Clear(); //this.chart1.DataSource = null; this.timer_Tip.Interval = int.Parse(txt_Timer_Interval.Text) * 1000; timer_Tip.Tick += new EventHandler(timer_Tip_Tick); //this.timer_Tip.Enabled = true; this.timer_Tip.Enabled = true; //this.timer_Tip_Tick(null, null); //////try //////{ if (btc == null) { btc = btc = new BackTestClass(long.Parse(txt_begExpNo.Text), long.Parse(txt_LoopCnt.Text), setting); } th = new Thread(RunVirtual); th.Start(); return; //////} //////catch (Exception ce) //////{ ////// ret = new BackTestReturnClass(); ////// ret.ChanceList = new List<ChanceClass>(); ////// ret.Msg = ce.Message; ////// ret.succ = false; //////} }
/// <summary> /// 滚动测试 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_roundTest_Click(object sender, EventArgs e) { if (this.runPlanPicker1.Plans.Length == 0) { return; } this.Cursor = Cursors.WaitCursor; SettingClass setting = new SettingClass(); setting.GrownMaxVal = int.Parse(this.txt_GrownMaxVal.Text); setting.GrownMinVal = int.Parse(this.txt_GrownMinVal.Text); setting.DispRows = int.Parse(this.txt_MinCols.Text); setting.minColTimes = new int[10]; for (int i = 0; i < 9; i++) { TextBox tb = this.Controls.Find(string.Format("txt_minColTimes{0}", i + 1), true)[0] as TextBox; setting.minColTimes[i] = int.Parse(tb.Text); } btc = new BackTestClass(long.Parse(txt_begExpNo.Text), long.Parse(txt_LoopCnt.Text), setting); Assembly asmb = typeof(StragClass).Assembly; //////Type sct = asmb.GetType(ddl_StragName.SelectedValue.ToString()); //////StragClass sc = Activator.CreateInstance(sct) as StragClass; StragClass sc = this.runPlanPicker1.Plans[0].PlanStrag; sc.CommSetting = setting; sc.ChipCount = int.Parse(this.txt_ChipCnt.Text); sc.FixChipCnt = (this.txt_FixChipCnt.Text.Trim() == "0") ? false : true; sc.ReviewExpectCnt = int.Parse(this.txt_reviewExpCnt.Text); sc.InputMinTimes = int.Parse(this.txt_minInputTimes.Text); sc.InputMaxTimes = int.Parse(this.txt_maxInputTimes.Text); sc.ExcludeBS = this.chkb_exclueBS.Checked; sc.ExcludeSD = this.chkb_exclueSD.Checked; sc.BySer = this.chkb_bySer.Checked; sc.OnlyBS = this.chkb_onlyBS.Checked; sc.OnlySD = this.chkb_onlySD.Checked; this.runPlanPicker1.Plans[0].PlanStrag = sc; RoundBackTestReturnClass rbtr = null; try { int cycLong = int.Parse(txt_RoundCycLong.Text); int stepLong = int.Parse(txt_RoundStepLong.Text); rbtr = btc.RunRound(sc, cycLong, stepLong); } catch (Exception ce) { rbtr = new RoundBackTestReturnClass(); rbtr.Msg = ce.Message; rbtr.succ = false; } if (!rbtr.succ) { this.Cursor = Cursors.Default; MessageBox.Show(rbtr.Msg); return; } listView3.Items.Clear(); List <float> wins = rbtr.RoundWinRate; for (int i = 0; i < rbtr.RoundData.Count; i++) { ListViewItem lvi = new ListViewItem(); lvi.Text = (i + 1).ToString(); lvi.SubItems.Add(rbtr.RoundData[i].LoopCnt.ToString()); lvi.SubItems.Add(rbtr.RoundData[i].ChanceList.Count.ToString()); lvi.SubItems.Add(rbtr.RoundData[i].HoldCntDic[1].ToString()); lvi.SubItems.Add(wins[i].ToString()); listView3.Items.Add(lvi); } this.tabPage3.Show(); this.Cursor = Cursors.Default; MessageBox.Show(rbtr.Msg); }
private void DoSomething(BackgroundWorker worker, DoWorkEventArgs e) { SettingClass setting = new SettingClass(); setting.GrownMaxVal = int.Parse(this.txt_GrownMaxVal.Text); setting.GrownMinVal = int.Parse(this.txt_GrownMinVal.Text); setting.DispRows = int.Parse(this.txt_MinCols.Text); setting.minColTimes = new int[10]; for (int i = 0; i < 9; i++) { TextBox tb = this.Controls.Find(string.Format("txt_minColTimes{0}", i + 1), true)[0] as TextBox; setting.minColTimes[i] = int.Parse(tb.Text); } #region 老的调用逻辑改为和正式运行一样的通过注入选择的计划列表,运行。除了调试不写入表,其他处理一样。其实在正常处理里面也可以使用调试模式,那会导致停止服务后无法保留交易数据 //////////////////Assembly asmb = typeof(StragClass).Assembly;// Assembly.LoadFrom("EnterpriseServerBase.dll"); //////////////////btc = new BackTestClass(long.Parse(txt_begExpNo.Text), long.Parse(txt_LoopCnt.Text), setting); //////////////////Type sct = asmb.GetType(ddl_StragName.SelectedValue.ToString()); //////////////////StragClass sc = Activator.CreateInstance(sct) as StragClass; //////////////////sc.CommSetting = setting; //////////////////sc.ChipCount = int.Parse(this.txt_ChipCnt.Text); //////////////////sc.FixChipCnt = (this.txt_FixChipCnt.Text.Trim() == "0") ? false : true; //////////////////sc.ReviewExpectCnt = int.Parse(this.txt_reviewExpCnt.Text); //////////////////sc.InputMinTimes = int.Parse(this.txt_minInputTimes.Text); //////////////////sc.InputMaxTimes = int.Parse(this.txt_maxInputTimes.Text); //////////////////sc.ExcludeBS = this.chkb_exclueBS.Checked; //////////////////sc.ExcludeSD = this.chkb_exclueSD.Checked; //////////////////sc.BySer = this.chkb_bySer.Checked; //////////////////sc.OnlyBS = this.chkb_onlyBS.Checked; //////////////////sc.OnlySD = this.chkb_onlySD.Checked; //////////////////sc.GetRev = this.chkb_getRev.Checked; //////////////////if (sc is IProbCheckClass) //////////////////{ ////////////////// (sc as IProbCheckClass).StdvCnt = double.Parse(this.txt_StdvCnt.Text); //////////////////} //////////////////sc.MinWinRate = (double)double.Parse(this.txt_Odds.Text) / double.Parse(this.txt_ChipCnt.Text) / double.Parse(this.txt_minRate.Text); ////////////////////凯利公式 (p*b-q)/q ////////////////////////double p = 1 / sc.MinWinRate; ////////////////////////double b = double.Parse(this.txt_Odds.Text); ////////////////////////double q = 1 - p; ////////////////////////sc.StagSetting = sc.getInitStagSetting(); ////////////////////////sc.StagSetting.BaseType.ChipRate = (p * b - q) / q; ////////////////////////if (MessageBox.Show(sc.StagSetting.BaseType.ChipRate.ToString(), "胜率", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) ; ////////////////////////{ //////////////////////// return; ////////////////////////} #endregion btc = new BackTestClass(long.Parse(txt_begExpNo.Text), long.Parse(txt_LoopCnt.Text), setting); this.listView1.Items.Clear(); this.listView2.Items.Clear(); this.listView3.Items.Clear(); StragRunPlanClass[] plans = this.runPlanPicker1.Plans; if (plans.Length == 0) { return; } SCList = plans.ToList(); SCList.ForEach(p => p.PlanStrag.CommSetting = setting); SCList.ForEach(p => p.PlanStrag.ChipCount = int.Parse(this.txt_ChipCnt.Text)); SCList.ForEach(p => p.Running = true); SCList.ForEach(p => p.AutoRunning = true); SCList.ForEach(p => p.FixAmt = 1); SCList.ForEach(p => p.FixRate = 0.01); sc = SCList[0].PlanStrag; this.Cursor = Cursors.WaitCursor; timer_Tip.Tick += new EventHandler(RefreshList); this.timer_Tip.Interval = int.Parse(txt_Timer_Interval.Text) * 1000; this.timer_Tip.Enabled = true; Thread thrd = null; try { btc.FinishedProcess = new SuccEvent(Finished); btc.teststrag = sc; thrd = new Thread(new ThreadStart(btc.Run)); thrd.Start(); } catch (Exception ce) { ret = new BackTestReturnClass(); ret.ChanceList = new List <ChanceClass>(); ret.Msg = ce.Message; ret.succ = false; MessageBox.Show(ce.Message); } //this.RunVirExchange = true; this.Cursor = Cursors.Default; ////if (!ret.succ) //// MessageBox.Show(ret.Msg); ////RefreshList(null, null); ////while(true) ////{ //// Thread.Sleep(1000); //// RefreshList(null, null); //// if (thrd.ThreadState == ThreadState.Stopped) //// { //// break; //// } ////} ////this.timer_Tip.Enabled = false; ////RefreshList(); }
public void Calc() { try { ////if (!AllowCalc) return; DateTime currTime = DateTime.Now; ////int MaxViewCnt = Program.AllServiceConfig.AllRunningPlanGrps.Max(t=>t.Value.UseSPlans.ForEach(a=>Program.AllServiceConfig.AllStrags[a.GUID])))); ExpectList <T> el = CurrData; // Program.AllServiceConfig.LastDataSector; //Log("数据源", string.Format("数据条数:{0};最后数据:{1}", el.Count, el.LastData.ToString())); //if (CurrDataList.Count < MaxViewCnt) //{ // el = new ExpectReader().ReadNewestData(MaxViewCnt); //} //Log("计算准备", "获取未关闭的机会"); Dictionary <string, ChanceClass <T> > NoClosedChances = new Dictionary <string, ChanceClass <T> >(); NoClosedChances = CloseTheChances(this.IsTestBack); //关闭机会 this.FinishedThreads = 0; //完成数量置0 RunThreads = 0; Dictionary <string, CalcStragGroupClass <T> > testGrps = Program.AllServiceConfig.AllRunningPlanGrps as Dictionary <string, CalcStragGroupClass <T> >; if (!IsTestBack) { foreach (string key in testGrps.Keys) { ///修改:分组不用备份,每次策略都要获取前次的状态 ///先剔除状态异常的计划,然后再增加新的计划 ///CalcStragGroupClass<T> csc = Program.AllServiceConfig.AllRunningPlanGrps[key].Copy();//只用备份,允许窗体启动曾经停止的计划 CalcStragGroupClass <T> csc = Program.AllServiceConfig.AllRunningPlanGrps[key] as CalcStragGroupClass <T>; for (int i = csc.UseSPlans.Count - 1; i >= 0; i--) { //修改为检查计划的状态,前台程序修改的是计划表的状态 StragRunPlanClass <T> UsePlan = csc.UseSPlans[i]; if (!Program.AllServiceConfig.AllRunPlannings.ContainsKey(UsePlan.GUID)) { Log("计划表中已注销", UsePlan.Plan_Name); csc.UseSPlans.RemoveAt(i); csc.UseStrags.Remove(UsePlan.PlanStrag.GUID); continue; } StragRunPlanClass <T> spc = Program.AllServiceConfig.AllRunPlannings[UsePlan.GUID] as StragRunPlanClass <T>; if (!spc.Running) { Log("计划未启动", csc.UseSPlans[i].Plan_Name); csc.UseSPlans.RemoveAt(i); csc.UseStrags.Remove(UsePlan.PlanStrag.GUID); continue; } if (!InitServerClass.JudgeInRunTime(currTime, spc)) { Log("计划超时", csc.UseSPlans[i].Plan_Name); csc.UseSPlans.RemoveAt(i); csc.UseStrags.Remove(UsePlan.PlanStrag.GUID); //只清除计划,不清除策略????? continue; } } } Dictionary <string, CalcStragGroupClass <TimeSerialData> > allGrps = Program.AllServiceConfig.AllRunningPlanGrps as Dictionary <string, CalcStragGroupClass <TimeSerialData> >; //加入后续启动的计划 Program.AllServiceConfig.AllRunningPlanGrps = InitServerClass.InitCalcStrags <TimeSerialData>(DataPoint, ref allGrps, Program.AllServiceConfig.AllStrags as Dictionary <string, BaseStragClass <TimeSerialData> >, Program.AllServiceConfig.AllRunPlannings, Program.AllServiceConfig.AllAssetUnits, false, this.IsTestBack); } foreach (string key in Program.AllServiceConfig.AllRunningPlanGrps.Keys)//再次为计划组分配资源,保证策略和计划一直在内存。 { CalcStragGroupClass <T> csc = Program.AllServiceConfig.AllRunningPlanGrps[key] as CalcStragGroupClass <T>; //增加新的计划 SettingClass comSetting = new SettingClass(); comSetting.SetGlobalSetting(Program.AllServiceConfig.gc); List <ChanceClass <T> > NoClsList = NoClosedChances.Values.ToList(); //NoClsList.ForEach(a=>Log(a.ChanceCode,a.ToDetailString())); //Log("未关闭机会数量", NoClosedChances.Count.ToString()); //NoClsList.ForEach(a => Log("策略:", a.StragId)); if (!csc.initRunningData(comSetting, NoClsList)) { Log("为计划组分配通用参数", "配置计划组的通用参数失败,该组计划暂时不参与运算!"); continue; } RunThreads++; csc.Finished = new CalcStragGroupDelegate(CheckFinished); csc.GetNoClosedChances = new ReturnChances <T>(FillNoClosedChances); csc.GetAllStdDevList = new ReturnStdDevList(FillAllStdDev); //Program.AllServiceConfig.AllRunningPlanGrps[key] = csc;//要加吗?不知道,应该要加 } //分配完未关闭的数据后,将全局内存中所有未关闭机会列表清除 Program.AllServiceConfig.AllNoClosedChanceList = new Dictionary <string, ChanceClass <T> >() as Dictionary <string, ChanceClass <TimeSerialData> >; this.FinishedThreads = 0; foreach (string key in Program.AllServiceConfig.AllRunningPlanGrps.Keys)//再次为计划组分配资源,保证策略和计划一直在内存。 { //Log("计算组执行处理", key, Program.gc.NormalNoticeFlag); CalcStragGroupClass <T> csc = Program.AllServiceConfig.AllRunningPlanGrps[key] as CalcStragGroupClass <T>; //if (!IsTestBack && !csc.Running) // continue; csc.IsBackTest = IsTestBack; ThreadPool.QueueUserWorkItem(new WaitCallback(csc.Run), el); } } catch (Exception ce) { Log(ce.Message, ce.StackTrace, true); } }
public static SettingClass Init_CommSetting() { SettingClass sc = new SettingClass(); return(sc); }
//тут все ссылочные переменные, на которые надо поставить игнор //public Border bind = null;//основной элемент бинда //public Canvas can = null;//канвас, где все элементы бинда //public DockPanel NameDock = null;//док, где имя и кнопка редактирования имени //public Label nameLab = null;//лейбел имени бинда //public Label script1Lab = null;//лейбел для скрипта 1 бинда //public Label script2Lab = null;//лейбел для скрипта 2 бинда //public Button EnableButton = null;//кнопка включения/выключения бинда //public CheckBox IsToggleCheck = null;//комбобокс с выбором модификатора бинда //public DockPanel ChooseBindDock = null;//док, для хранения бинда //public TextBlock keyText = null;//текстблок для кнопки бинда //public ComboBox comboModifier1 = null;//комбобокс с выбором модификатора бинда1 //public ComboBox comboModifier2 = null;//комбобокс с выбором модификатора бинда2 public MainWindow()//конструктор этого окна { //подготавливаем сериализер для биндов { var overrides = new XmlAttributeOverrides(); var ignore = new XmlAttributes { XmlIgnore = true }; overrides.Add <Bind>(m => m.bind, ignore); overrides.Add <Bind>(m => m.can, ignore); overrides.Add <Bind>(m => m.ChooseBindDock, ignore); overrides.Add <Bind>(m => m.comboModifier1, ignore); overrides.Add <Bind>(m => m.comboModifier2, ignore); overrides.Add <Bind>(m => m.EnableButton, ignore); overrides.Add <Bind>(m => m.IsToggleCheck, ignore); overrides.Add <Bind>(m => m.keyText, ignore); overrides.Add <Bind>(m => m.NameDock, ignore); overrides.Add <Bind>(m => m.nameLab, ignore); overrides.Add <Bind>(m => m.script1Lab, ignore); overrides.Add <Bind>(m => m.script2Lab, ignore); Type t = typeof(Bind[]); xsBinds = new XmlSerializer(t, overrides); } if (Application.ResourceAssembly.Location.Split('\\').Last() != "Binder.exe")//возвращаем наше имя { File.Move(Application.ResourceAssembly.Location, Application.ResourceAssembly.Location.Replace(Application.ResourceAssembly.Location.Split('\\').Last(), "Binder.exe")); } if (Process.GetProcessesByName("Binder").Length > 1) { Application.Current.Shutdown(); } InitializeComponent(); OpenOrCreateSets();//загружаем настройки //применяем настройки if (sets.haveDefaultBindsPath) { try { OpenInPath(sets.defaultBindsPath); } catch//если не удалось открыть или найти файл сохранки то убираем это { MessageBox.Show("Файл " + sets.defaultBindsPath + " не найден!"); sets.defaultBindsPath = ""; sets.haveDefaultBindsPath = false; } } SettingClass.UnRegisterAutoRun(); if (sets.autoRun) { SettingClass.RegisterAutoRun(); } Hook.SetHook();//запускаем хукер ShowWindow(); Show(); if (sets.AutoRunHided) { HideWindow(); } LoadFuncsRunScripts.LoadScripts(); main = this; MouseHook.MouseMove += MousePos;//ставим обработчик //MouseHook.LocalHook = false; }
//настройки программы private void Settings_Click(object sender, RoutedEventArgs e) { stw = new SettingsWindow(); //создаём новое окно настроек //загружаем все настройки в окно настроек stw.SelectAutoBindsPath.IsEnabled = sets.haveDefaultBindsPath; //включаем выбор бинда поумолчанию, если надо stw.DefaultBindsPath.IsEnabled = sets.haveDefaultBindsPath; //включаем выбор бинда поумолчанию, если надо stw.AutoOpenBinds.IsChecked = sets.haveDefaultBindsPath; //включаем выбор бинда поумолчанию, если надо stw.DefaultBindsPath.Text = sets.defaultBindsPath; //вставляем путь до бинда по стандарту stw.AutorunCheckBox.IsChecked = sets.autoRun; //включаем/выключаем автозапуск stw.RunHided.IsChecked = sets.AutoRunHided; //включаем/выключаем скрытый запуск //при нажатии не чекбокс с выбором биндов поумолчанию stw.AutoOpenBinds.Click += (object seneder, RoutedEventArgs eBinds) => { stw.SelectAutoBindsPath.IsEnabled = stw.AutoOpenBinds.IsChecked.Value; stw.DefaultBindsPath.IsEnabled = stw.AutoOpenBinds.IsChecked.Value; sets.haveDefaultBindsPath = stw.AutoOpenBinds.IsChecked.Value; }; //при нажатии на кнопку выбора пути к файлу stw.SelectAutoBindsPath.Click += (object seneder, RoutedEventArgs eBinds) => { OpenFileDialog ofd = new OpenFileDialog() { FileName = lastOpenPath, DefaultExt = ".xml", Filter = "XML Files (.xml)|*.xml" }; //диалог открытия файла if (ofd.ShowDialog().Value) //если открыли { sets.defaultBindsPath = ofd.FileName; stw.DefaultBindsPath.Text = ofd.FileName; } }; //при изменении значения автозапуска stw.AutorunCheckBox.Click += (object seneder, RoutedEventArgs eBinds) => { sets.autoRun = stw.AutorunCheckBox.IsChecked.Value; SettingClass.UnRegisterAutoRun(); if (sets.autoRun) { SettingClass.RegisterAutoRun(); } }; //при изменении скрытого запуска stw.RunHided.Click += (object seneder, RoutedEventArgs eBinds) => { sets.AutoRunHided = stw.RunHided.IsChecked.Value; }; stw.Closing += (object seneder, System.ComponentModel.CancelEventArgs eBinds) => { SaveSets(); }; stw.ShowDialog(); stw.Activate(); }