コード例 #1
0
ファイル: Simulator.cs プロジェクト: heber/FreeOQ
		private void mSHpPJSw9()
		{
			try
			{
				Clock.ClockMode = ClockMode.Simulation;
				if (!this.InputSeries.Contains(this.XyXefUib4X))
					this.InputSeries.Add(this.XyXefUib4X);
				this.CurrentState = SimulatorState.Running;
				this.EmitStateChanged();
				this.EmitEnterSimulation();
				foreach (Interval interval in this.Intervals)
				{
					if (!this.SmCegm8IIv)
						break;
					Clock.SetDateTime(interval.Begin);
					this.EmitEnterInterval(interval);
					this.fP9emgbM6c = this.UseReversedArray ? (ArrayList)new ReversibleArrayList() : new ArrayList();
					this.ObjectsInInterval = 0;
					foreach (IDataSeries dataSeries in new ArrayList(this.InputSeries))
					{
						int index = dataSeries.IndexOf(interval.Begin, SearchOption.Next);
						int num1 = dataSeries.IndexOf(interval.End.AddMilliseconds(1.0), SearchOption.Prev);
						if (index != -1 && index <= num1)
						{
							MML451mtycDm65B2By l451mtycDm65B2By = new MML451mtycDm65B2By();
							l451mtycDm65B2By.series = dataSeries;
							l451mtycDm65B2By.data = dataSeries[index] as IDataObject;
							l451mtycDm65B2By.cx20cOlf0 = index + 1;
							l451mtycDm65B2By.YJQP0P9Gt = num1;
							this.fP9emgbM6c.Add(l451mtycDm65B2By);
							int num2 = l451mtycDm65B2By.data is Bar ? 2 : 1;
							this.ObjectsInInterval += (num1 - index + 1) * num2;
						}
					}
					if (this.fP9emgbM6c.Count > 0)
					{
						this.fP9emgbM6c.Sort();
						DateTime dateTime1 = (this.fP9emgbM6c[0] as MML451mtycDm65B2By).data.DateTime;
						DateTime datetime = this.simulationMode == SimulationMode.MaxSpeed ? interval.End.AddYears(1) : dateTime1;
						DateTime dateTime2 = this.step == 0 ? DateTime.MaxValue : dateTime1.AddSeconds((double)this.step);
						DateTime dateTime3 = DateTime.Now;
						DateTime dateTime4 = datetime;
						while (this.fP9emgbM6c.Count > 0 && this.SmCegm8IIv)
						{
							bool flag;
							do
							{
								if (this.paused)
								{
									this.CurrentState = SimulatorState.Paused;
									this.EmitStateChanged();
									DateTime now1 = DateTime.Now;
									while (this.paused)
										Thread.Sleep(1);
									DateTime now2 = DateTime.Now;
									if (this.SmCegm8IIv)
									{
										if (this.simulationMode == SimulationMode.UserDefinedSpeed)
											dateTime3 = dateTime3.AddTicks(now2.Ticks - now1.Ticks);
										if (this.simulationMode == SimulationMode.MaxSpeed && dateTime2 < Clock.Now)
											dateTime2 = Clock.Now.AddSeconds((double)this.step);
										this.CurrentState = SimulatorState.Running;
										this.EmitStateChanged();
									}
								}
								if (this.SmCegm8IIv)
								{
									flag = false;
									MML451mtycDm65B2By l451mtycDm65B2By = this.fP9emgbM6c[0] as MML451mtycDm65B2By;
									if (this.simulationMode == SimulationMode.UserDefinedSpeed && datetime >= dateTime2 || this.simulationMode == SimulationMode.MaxSpeed && l451mtycDm65B2By.data.DateTime >= dateTime2)
									{
										dateTime2 = dateTime2.AddSeconds((double)this.step);
										if (this.StepEnabled)
										{
											this.paused = true;
											flag = true;
											goto label_40;
										}
									}
									if (datetime >= l451mtycDm65B2By.data.DateTime)
									{
										this.fP9emgbM6c.RemoveAt(0);
										if (l451mtycDm65B2By.data is Bar || l451mtycDm65B2By.data is Oym5lJOEeXmP9gbM6c)
										{
											if (l451mtycDm65B2By is y2ITxtBCMk4LU5vNC2)
											{
												Oym5lJOEeXmP9gbM6c oym5lJoEeXmP9gbM6c = l451mtycDm65B2By.data as Oym5lJOEeXmP9gbM6c;
												y2ITxtBCMk4LU5vNC2 itxtBcMk4Lu5vNc2 = l451mtycDm65B2By as y2ITxtBCMk4LU5vNC2;
												itxtBcMk4Lu5vNc2.bar.High = oym5lJoEeXmP9gbM6c.tY00OUm9S0.High;
												itxtBcMk4Lu5vNc2.bar.Low = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Low;
												itxtBcMk4Lu5vNc2.bar.Close = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Close;
												itxtBcMk4Lu5vNc2.bar.Volume = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Volume;
												itxtBcMk4Lu5vNc2.bar.OpenInt = oym5lJoEeXmP9gbM6c.tY00OUm9S0.OpenInt;
												itxtBcMk4Lu5vNc2.bar.EndTime = oym5lJoEeXmP9gbM6c.tY00OUm9S0.EndTime;
												itxtBcMk4Lu5vNc2.bar.IsComplete = true;
												itxtBcMk4Lu5vNc2.data = (IDataObject)itxtBcMk4Lu5vNc2.bar;
											}
											else
											{
												Bar bar = l451mtycDm65B2By.data as Bar;
												y2ITxtBCMk4LU5vNC2 itxtBcMk4Lu5vNc2 = new y2ITxtBCMk4LU5vNC2();
												itxtBcMk4Lu5vNc2.bar = bar;
												itxtBcMk4Lu5vNc2.series = l451mtycDm65B2By.series;
												itxtBcMk4Lu5vNc2.data = (IDataObject)new Oym5lJOEeXmP9gbM6c(bar);
												itxtBcMk4Lu5vNc2.cx20cOlf0 = 1;
												itxtBcMk4Lu5vNc2.YJQP0P9Gt = 0;
												itxtBcMk4Lu5vNc2.data.DateTime = bar.EndTime;
												this.mTh23qh0l(this.fP9emgbM6c, (MML451mtycDm65B2By)itxtBcMk4Lu5vNc2);
												bar.High = bar.Open;
												bar.Low = bar.Open;
												bar.Close = bar.Open;
												bar.Volume = 0L;
												bar.OpenInt = 0L;
												bar.IsComplete = false;
											}
										}
										this.QYkhWyHA5(l451mtycDm65B2By.series, l451mtycDm65B2By.data);
										if (l451mtycDm65B2By.cx20cOlf0 <= l451mtycDm65B2By.YJQP0P9Gt)
										{
											l451mtycDm65B2By.data = l451mtycDm65B2By.series[l451mtycDm65B2By.cx20cOlf0] as IDataObject;
											++l451mtycDm65B2By.cx20cOlf0;
											this.mTh23qh0l(this.fP9emgbM6c, l451mtycDm65B2By);
										}
										else if (l451mtycDm65B2By.series == this.XyXefUib4X)
											this.XyXefUib4X.Clear();
										flag = this.fP9emgbM6c.Count > 0;
									}
									label_40:
									;
								}
								else
									break;
							}
							while (flag);
							if (this.simulationMode == SimulationMode.UserDefinedSpeed)
							{
								Clock.SetDateTime(datetime);
								Thread.Sleep(1);
								DateTime now = DateTime.Now;
								datetime = dateTime4.Add(new TimeSpan((long)((double)(now - dateTime3).Ticks * this.speedMultiplier)));
							}
						}
					}
					Clock.FireAllReminders();
					this.EmitLeaveInterval(interval);
				}
			}
			finally
			{
				Clock.ClockMode = ClockMode.Realtime;
				this.EmitExitSimulation();
				this.XyXefUib4X.Clear();
				this.CurrentState = SimulatorState.Stopped;
				this.EmitStateChanged();
			}
		}
コード例 #2
0
ファイル: Simulator.cs プロジェクト: zhuzhenping/FreeOQ
        private void mSHpPJSw9()
        {
            try
            {
                Clock.ClockMode = ClockMode.Simulation;
                if (!this.InputSeries.Contains(this.XyXefUib4X))
                {
                    this.InputSeries.Add(this.XyXefUib4X);
                }
                this.CurrentState = SimulatorState.Running;
                this.EmitStateChanged();
                this.EmitEnterSimulation();
                foreach (Interval interval in this.Intervals)
                {
                    if (!this.SmCegm8IIv)
                    {
                        break;
                    }
                    Clock.SetDateTime(interval.Begin);
                    this.EmitEnterInterval(interval);
                    this.fP9emgbM6c        = this.UseReversedArray ? (ArrayList) new ReversibleArrayList() : new ArrayList();
                    this.ObjectsInInterval = 0;
                    foreach (IDataSeries dataSeries in new ArrayList(this.InputSeries))
                    {
                        int index = dataSeries.IndexOf(interval.Begin, SearchOption.Next);
                        int num1  = dataSeries.IndexOf(interval.End.AddMilliseconds(1.0), SearchOption.Prev);
                        if (index != -1 && index <= num1)
                        {
                            MML451mtycDm65B2By l451mtycDm65B2By = new MML451mtycDm65B2By();
                            l451mtycDm65B2By.series    = dataSeries;
                            l451mtycDm65B2By.data      = dataSeries[index] as IDataObject;
                            l451mtycDm65B2By.cx20cOlf0 = index + 1;
                            l451mtycDm65B2By.YJQP0P9Gt = num1;
                            this.fP9emgbM6c.Add(l451mtycDm65B2By);
                            int num2 = l451mtycDm65B2By.data is Bar ? 2 : 1;
                            this.ObjectsInInterval += (num1 - index + 1) * num2;
                        }
                    }
                    if (this.fP9emgbM6c.Count > 0)
                    {
                        this.fP9emgbM6c.Sort();
                        DateTime dateTime1 = (this.fP9emgbM6c[0] as MML451mtycDm65B2By).data.DateTime;
                        DateTime datetime  = this.simulationMode == SimulationMode.MaxSpeed ? interval.End.AddYears(1) : dateTime1;
                        DateTime dateTime2 = this.step == 0 ? DateTime.MaxValue : dateTime1.AddSeconds((double)this.step);
                        DateTime dateTime3 = DateTime.Now;
                        DateTime dateTime4 = datetime;
                        while (this.fP9emgbM6c.Count > 0 && this.SmCegm8IIv)
                        {
                            bool flag;
                            do
                            {
                                if (this.paused)
                                {
                                    this.CurrentState = SimulatorState.Paused;
                                    this.EmitStateChanged();
                                    DateTime now1 = DateTime.Now;
                                    while (this.paused)
                                    {
                                        Thread.Sleep(1);
                                    }
                                    DateTime now2 = DateTime.Now;
                                    if (this.SmCegm8IIv)
                                    {
                                        if (this.simulationMode == SimulationMode.UserDefinedSpeed)
                                        {
                                            dateTime3 = dateTime3.AddTicks(now2.Ticks - now1.Ticks);
                                        }
                                        if (this.simulationMode == SimulationMode.MaxSpeed && dateTime2 < Clock.Now)
                                        {
                                            dateTime2 = Clock.Now.AddSeconds((double)this.step);
                                        }
                                        this.CurrentState = SimulatorState.Running;
                                        this.EmitStateChanged();
                                    }
                                }
                                if (this.SmCegm8IIv)
                                {
                                    flag = false;
                                    MML451mtycDm65B2By l451mtycDm65B2By = this.fP9emgbM6c[0] as MML451mtycDm65B2By;
                                    if (this.simulationMode == SimulationMode.UserDefinedSpeed && datetime >= dateTime2 || this.simulationMode == SimulationMode.MaxSpeed && l451mtycDm65B2By.data.DateTime >= dateTime2)
                                    {
                                        dateTime2 = dateTime2.AddSeconds((double)this.step);
                                        if (this.StepEnabled)
                                        {
                                            this.paused = true;
                                            flag        = true;
                                            goto label_40;
                                        }
                                    }
                                    if (datetime >= l451mtycDm65B2By.data.DateTime)
                                    {
                                        this.fP9emgbM6c.RemoveAt(0);
                                        if (l451mtycDm65B2By.data is Bar || l451mtycDm65B2By.data is Oym5lJOEeXmP9gbM6c)
                                        {
                                            if (l451mtycDm65B2By is y2ITxtBCMk4LU5vNC2)
                                            {
                                                Oym5lJOEeXmP9gbM6c oym5lJoEeXmP9gbM6c = l451mtycDm65B2By.data as Oym5lJOEeXmP9gbM6c;
                                                y2ITxtBCMk4LU5vNC2 itxtBcMk4Lu5vNc2   = l451mtycDm65B2By as y2ITxtBCMk4LU5vNC2;
                                                itxtBcMk4Lu5vNc2.bar.High       = oym5lJoEeXmP9gbM6c.tY00OUm9S0.High;
                                                itxtBcMk4Lu5vNc2.bar.Low        = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Low;
                                                itxtBcMk4Lu5vNc2.bar.Close      = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Close;
                                                itxtBcMk4Lu5vNc2.bar.Volume     = oym5lJoEeXmP9gbM6c.tY00OUm9S0.Volume;
                                                itxtBcMk4Lu5vNc2.bar.OpenInt    = oym5lJoEeXmP9gbM6c.tY00OUm9S0.OpenInt;
                                                itxtBcMk4Lu5vNc2.bar.EndTime    = oym5lJoEeXmP9gbM6c.tY00OUm9S0.EndTime;
                                                itxtBcMk4Lu5vNc2.bar.IsComplete = true;
                                                itxtBcMk4Lu5vNc2.data           = (IDataObject)itxtBcMk4Lu5vNc2.bar;
                                            }
                                            else
                                            {
                                                Bar bar = l451mtycDm65B2By.data as Bar;
                                                y2ITxtBCMk4LU5vNC2 itxtBcMk4Lu5vNc2 = new y2ITxtBCMk4LU5vNC2();
                                                itxtBcMk4Lu5vNc2.bar           = bar;
                                                itxtBcMk4Lu5vNc2.series        = l451mtycDm65B2By.series;
                                                itxtBcMk4Lu5vNc2.data          = (IDataObject) new Oym5lJOEeXmP9gbM6c(bar);
                                                itxtBcMk4Lu5vNc2.cx20cOlf0     = 1;
                                                itxtBcMk4Lu5vNc2.YJQP0P9Gt     = 0;
                                                itxtBcMk4Lu5vNc2.data.DateTime = bar.EndTime;
                                                this.mTh23qh0l(this.fP9emgbM6c, (MML451mtycDm65B2By)itxtBcMk4Lu5vNc2);
                                                bar.High       = bar.Open;
                                                bar.Low        = bar.Open;
                                                bar.Close      = bar.Open;
                                                bar.Volume     = 0L;
                                                bar.OpenInt    = 0L;
                                                bar.IsComplete = false;
                                            }
                                        }
                                        this.QYkhWyHA5(l451mtycDm65B2By.series, l451mtycDm65B2By.data);
                                        if (l451mtycDm65B2By.cx20cOlf0 <= l451mtycDm65B2By.YJQP0P9Gt)
                                        {
                                            l451mtycDm65B2By.data = l451mtycDm65B2By.series[l451mtycDm65B2By.cx20cOlf0] as IDataObject;
                                            ++l451mtycDm65B2By.cx20cOlf0;
                                            this.mTh23qh0l(this.fP9emgbM6c, l451mtycDm65B2By);
                                        }
                                        else if (l451mtycDm65B2By.series == this.XyXefUib4X)
                                        {
                                            this.XyXefUib4X.Clear();
                                        }
                                        flag = this.fP9emgbM6c.Count > 0;
                                    }
label_40:
                                    ;
                                }
                                else
                                {
                                    break;
                                }
                            }while (flag);
                            if (this.simulationMode == SimulationMode.UserDefinedSpeed)
                            {
                                Clock.SetDateTime(datetime);
                                Thread.Sleep(1);
                                DateTime now = DateTime.Now;
                                datetime = dateTime4.Add(new TimeSpan((long)((double)(now - dateTime3).Ticks * this.speedMultiplier)));
                            }
                        }
                    }
                    Clock.FireAllReminders();
                    this.EmitLeaveInterval(interval);
                }
            }
            finally
            {
                Clock.ClockMode = ClockMode.Realtime;
                this.EmitExitSimulation();
                this.XyXefUib4X.Clear();
                this.CurrentState = SimulatorState.Stopped;
                this.EmitStateChanged();
            }
        }