private void RunPolicies(SecurityInfo si, bool getCount) { for (int i = 0; i < barIntervals.Count; i++) { for (int barCount = btParameter.BarCountFrom; barCount <= btParameter.BarCountTo; barCount += btParameter.BarCountStep) { for (double ZhiYingBeiShu = btParameter.ZhiYingBeiShuFrom; ZhiYingBeiShu <= btParameter.ZhiYingBeiShuTo; ZhiYingBeiShu += btParameter.ZhiYingBeiShuStep) { for (double HuiCheBiLi = btParameter.HuiCheBiLiFrom; HuiCheBiLi <= btParameter.HuiCheBiLiTo; HuiCheBiLi += btParameter.HuiCheBiLiStep) { for (double ZhiSunBiLi = btParameter.ZhiSunBiLiFrom; ZhiSunBiLi <= btParameter.ZhiSunBiLiTo; ZhiSunBiLi += btParameter.ZhiSunBiLiStep) { Parameter parameter = new Parameter(); parameter.DebugModel = true; parameter.BarInteval = barIntervals[i]; parameter.BarCount = barCount; parameter.ZhiYingBeiShu = ZhiYingBeiShu; parameter.HuiCheBiLi = HuiCheBiLi; parameter.ZhiSunBiLi = ZhiSunBiLi; parameter.IsReal = false; parameter.StartDate = btParameter.StartDate; parameter.EndDate = btParameter.EndDate; parameter.qty = btParameter.Qty; PolicyProperties pp = new PolicyProperties(); pp.IsLianDong = false; pp.IsSim = true; Policy p = new Policy(si, parameter, pp); policys.Add(p); } } } } } }
private void btn_stock_Click(object sender, EventArgs e) { inifile.WriteString("daterange", "fromdate", this.dateTimePicker1.Value.Date.ToString("yyyy-MM-dd")); inifile.WriteString("daterange", "todate", this.dateTimePicker2.Value.Date.ToString("yyyy-MM-dd")); List <RunningPolicy> policies = new List <RunningPolicy>(); for (int i = 0; i < this.grid_stocks.Rows.Count; i++) { string code = this.grid_stocks.Rows[i].Cells[0].Value.ToString().Trim(); string name = this.grid_stocks.Rows[i].Cells[1].Value.ToString().Trim(); string market = this.grid_stocks.Rows[i].Cells[2].Value.ToString(); SecurityInfo si = GlobalValue.GetFutureByCodeAndMarket(code, market); string programname = this.grid_stocks.Rows[i].Cells[5].Value.ToString(); string dllname = programname.Substring(0, programname.Length - 4); Assembly assembly = ((GridRowTag)this.grid_stocks.Rows[i].Tag).assembly; Type ClassPolicy = assembly.GetType(string.Format("{0}.Policy", dllname)); Object o = ((GridRowTag)this.grid_stocks.Rows[i].Tag).parameter; PolicyProperties pp = new PolicyProperties(); pp.Account = string.Empty; pp.IsLianDong = false; pp.IsSim = true; Object ObjectPolicy = assembly.CreateInstance(ClassPolicy.FullName, true, BindingFlags.CreateInstance, null, new object[] { si, o, pp }, null, null); policies.Add((RunningPolicy)ObjectPolicy); } this.MainForm.AddStock(policies); this.Close(); }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; this.policyName = string.Format("{0}%{1}%{2}%{3}", PName, si.Code, parameter.Bz1, parameter.Bz2); this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.MinValue.Date; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); lockObject = new object(); this.isLiveDataProcessor = true; MomList = new List <double>(); MomAbsList = new List <double>(); DieBars = new List <DieBar>(); tps = new List <TradePoints>(); lock_tps = new object(); eosusdtsi = GlobalValue.GetFutureByCodeAndMarket(parameter.Bz1, si.Market); eosbtcsi = GlobalValue.GetFutureByCodeAndMarket(parameter.Bz2, si.Market); }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; string name = PName; this.policyName = name; this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.Now; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); this.isLiveDataProcessor = true; tps = new ConcurrentDictionary <Guid, PTradePoints>(); if (!parameter.DebugModel) { InitArgs(); } }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; this.policyName = PName; this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.Now; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); this.isLiveDataProcessor = true; tps = new ConcurrentDictionary <Guid, TradePoints>(); SecondSi = GlobalValue.GetFutureByCodeAndMarket(parameter.SecondCode, parameter.SecondMarket); SecondTick = new TickData(); }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; this.policyName = PName + "-" + parameter.BarInteval + "-" + parameter.BarCount + "-" + parameter.TimeCycle.ToString() + "-" + parameter.ZhiYingBeiShu.ToString(); this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.Now; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); this.isLiveDataProcessor = true; tps = new ConcurrentDictionary <Guid, PTradePoints>(); }
private void cbt_ok_Click(object sender, EventArgs e) { List <RunningPolicy> policies = new List <RunningPolicy>(); //for (int i = 0; i < this.grid_stocks.Rows.Count; i++) //{ // string code = this.grid_stocks.Rows[i].Cells[0].Value.ToString().Trim(); // string name = this.grid_stocks.Rows[i].Cells[1].Value.ToString().Trim(); // byte market = System.Convert.ToByte(this.grid_stocks.Rows[i].Cells[2].Value); // SecurityInfo si = new SecurityInfo(code, name, market); // string programname = this.grid_stocks.Rows[i].Cells[5].Value.ToString(); // string dllname = programname.Substring(0, programname.Length - 4); // Assembly assembly = ((GridRowTag)this.grid_stocks.Rows[i].Tag).assembly; // Type ClassPolicy = assembly.GetType(string.Format("{0}.Policy", dllname)); // Object o = ((GridRowTag)this.grid_stocks.Rows[i].Tag).parameter; // PolicyProperties pp = new PolicyProperties(); // pp.IsLianDong = false; // pp.IsSim = isSim; // pp.Account = stockAccount; // Object ObjectPolicy = assembly.CreateInstance(ClassPolicy.FullName, true, BindingFlags.CreateInstance, null, new object[] { si, o, pp }, null, null); // policies.Add((RunningPolicy)ObjectPolicy); //} for (int i = grid_stockX.Rows.Fixed; i < this.grid_stockX.Rows.Count; i++) { string code = this.grid_stockX.Rows[i][0].ToString(); string name = this.grid_stockX.Rows[i][1].ToString(); string market = this.grid_stockX.Rows[i][2].ToString(); SecurityInfo si = GlobalValue.GetFutureByCodeAndMarket(code, market); string programname = this.grid_stockX.Rows[i][5].ToString(); string dllname = programname.Substring(0, programname.Length - 4); Assembly assembly = ((GridRowTag)this.grid_stockX.Rows[i].UserData).assembly; Type ClassPolicy = assembly.GetType(string.Format("{0}.Policy", dllname)); object o = ((GridRowTag)this.grid_stockX.Rows[i].UserData).parameter; PolicyProperties pp = new PolicyProperties(); pp.IsLianDong = false; pp.IsSim = isSim; pp.Account = stockAccount; Object ObjectPolicy = assembly.CreateInstance(ClassPolicy.FullName, true, BindingFlags.CreateInstance, null, new object[] { si, o, pp }, null, null); policies.Add((RunningPolicy)ObjectPolicy); } AddPolicies(policies); //this.MainForm.AddStock(policies); this.Close(); }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; this.policyName = string.Format("{0}-{1}s-{2}-{3}-{4}", PName, rpp.BarInteval.ToString(), rpp.BarCountIn.ToString(), rpp.Ratio.ToString(), rpp.CodeName); this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); LiveBarsIn = new List <DieBar>(); LiveBarsOut = new List <DieBar>(); //if (!parameter.Debug) //if (!parameter.Debug) //{ //LoadHistoryBars(); //} //LoadHistoryBars(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.MinValue.Date; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); lockObject = new object(); this.isLiveDataProcessor = true; tps = new List <TradePoints>(); lock_tps = new object(); signInHighPrice = 0; signOutHighPrice = 0; signInLowPrice = 1000000; signOutLowPrice = 1000000; Ratio = 0; }
private void RunPolicies(SecurityInfo si, bool getCount) { for (int BarInteval = btParameter.BarIntevalFrom; BarInteval < btParameter.BarIntevalTo; BarInteval += btParameter.BarIntevalStep) { for (int BarCountIn = btParameter.BarCountInFrom; BarCountIn < btParameter.BarCountInTo; BarCountIn += btParameter.BarIntevalStep) { for (int BarCountOut = btParameter.BarCountOutFrom; BarCountOut < btParameter.BarCountOutTo; BarCountOut += btParameter.BarCountOutStep) { for (decimal Ratio = (decimal)btParameter.RatioFrom; Ratio < (decimal)btParameter.RatioTo; Ratio += (decimal)btParameter.RatioStep) { Parameter parameter = new Parameter(); parameter.StartTime = new TimeSpan(0, 0, 0); parameter.EndTime = new TimeSpan(23, 59, 59); parameter.BarInteval = 60; parameter.Fee = btParameter.Fee; parameter.Debug = true; parameter.BarInteval = BarInteval; parameter.BarCountIn = BarCountIn; parameter.BarCountOut = BarCountOut; parameter.Ratio = (double)Ratio; //parameter.BarInteval = BarInteval; parameter.IsReal = false; parameter.StartDate = btParameter.StartDate; parameter.EndDate = btParameter.EndDate; parameter.qty = btParameter.Qty; PolicyProperties pp = new PolicyProperties(); pp.IsLianDong = false; pp.IsSim = true; Policy p = new Policy(si, parameter, pp); policys.Add(p); } } } } }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; string name = PName + "-" + parameter.BarInteval.ToString() + "-" + parameter.BarCount.ToString() + "-" + parameter.ZhiYingBeiShu.ToString() + "-" + parameter.HuiCheBiLi.ToString() + "-" + parameter.ZhiSunBiLi.ToString(); name = name.Replace(".", ""); this.policyName = name; this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.Now; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); this.isLiveDataProcessor = true; tps = new ConcurrentDictionary <Guid, PTradePoints>(); ArrayX = new double[parameter.BarCount]; for (int i = 0; i < parameter.BarCount; i++) { ArrayX[i] = i; } if (!parameter.DebugModel) { InitArgs(); } }
private void RunPolicies(SecurityInfo si, bool getCount) { for (int timeCycle = btParameter.TimeCycleFrom; timeCycle <= btParameter.TimeCycleTo; timeCycle += btParameter.TimeCycleStep) { for (double zhiYingBeiShu = btParameter.ZhiYingBeiShuFrom; zhiYingBeiShu <= btParameter.ZhiYingBeiShuTo; zhiYingBeiShu += btParameter.ZhiYingBeiShuStep) { for (int barCount = btParameter.BarCountFrom; barCount <= btParameter.BarCountTo; barCount += btParameter.BarCountStep) { for (int i = 0; i < BarIntevals.Count; i++) { if (BarIntevals[i] / 60 * barCount < 240) { Parameter parameter = new Parameter(); parameter.DebugModel = true; parameter.TimeCycle = timeCycle; parameter.ZhiYingBeiShu = zhiYingBeiShu; parameter.BarCount = barCount; parameter.BarInteval = BarIntevals[i]; parameter.JiaCangCiShu = 3; parameter.JiaCangJiaGeBeiShu = 0.5; //parameter.BarInteval = BarInteval; parameter.IsReal = false; parameter.StartDate = btParameter.StartDate; parameter.EndDate = btParameter.EndDate; parameter.qty = btParameter.Qty; PolicyProperties pp = new PolicyProperties(); pp.IsLianDong = false; pp.IsSim = true; Policy p = new Policy(si, parameter, pp); policys.Add(p); } } } } } }
public Policy(SecurityInfo si, Parameter rpp, PolicyProperties pp) { this.isSim = pp.IsSim; this.SecInfo = si; this.stockAccount = pp.Account; this.parameter = rpp; this.policyName = PName + "_" + parameter.EFast.ToString() + "_" + parameter.XFast.ToString() + "_" + parameter.ESlow.ToString() + "_" + parameter.XSlow.ToString(); this.startDate = rpp.StartDate; this.endDate = rpp.EndDate; this.inteval = rpp.Inteval; this.isReal = rpp.IsReal; this.policyguid = Guid.NewGuid(); LiveBarsIn = new List <DieBar>(); LiveBarsOut = new List <DieBar>(); list_efast = new List <double>(); list_xfast = new List <double>(); list_eslow = new List <double>(); list_xslow = new List <double>(); list_init_all = new List <double>(); last_maefast = 0; last_maxfast = 0; last_maeslow = 0; last_maxslow = 0; //lastminute = -1; last_high = 0; last_low = 9999; init_high = 0; init_low = 9999; has_pull_data = false; long_position = 0; short_position = 0; open_complete = 0; close_complete = 0; step = 0; //if (!parameter.Debug) //if (parameter.Debug) //{ // LoadHistoryBars(); //} initialDataReceiver(); InitialDataProcessor(); currentDay = DateTime.MinValue.Date; openPoints = new List <OpenPoint>(); IsSimulateFinished = false; //isOpened = false; if (rpp.save) { SaveParameter(rpp); } currentTick = new TickData(); lockObject = new object(); this.isLiveDataProcessor = true; tps = new List <TradePoints>(); lock_tps = new object(); signInHighPrice = 0; signOutHighPrice = 0; signInLowPrice = 1000000; signOutLowPrice = 1000000; Ratio = 0; }