Exemple #1
0
        private void AddTrade(IFIXInstrument instrument, DateTime datetime, double price, int size)
        {
            var list = new List <BarFactory.zNxuFsXhPSM7NAan2D>();

            lock (this)
            {
                foreach (BarFactoryItem item in this.items)
                {
                    if (item.Enabled)
                    {
                        Hashtable local_2 = this.A3ELH6L4QJ[instrument] as Hashtable;
                        if (local_2 == null)
                        {
                            local_2 = new Hashtable();
                            this.A3ELH6L4QJ.Add(instrument, local_2);
                        }
                        SortedList local_3 = local_2[item.BarType] as SortedList;
                        if (local_3 == null)
                        {
                            local_3 = new SortedList();
                            local_2.Add(item.BarType, local_3);
                        }
                        switch (item.BarType)
                        {
                        case BarType.Time:
                            Bar bar = local_3[item.BarSize] as Bar;
                            if (bar == null)
                            {
                                DateTime local_5   = this.qJpLNA6Aiq(datetime, item.BarSize);
                                Bar      local_4_1 = new Bar(BarType.Time, item.BarSize, local_5, local_5, price, price, price, price, size, 0);
                                local_3.Add(item.BarSize, local_4_1);
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 0, local_4_1));
                                goto case BarType.Dynamic;
                            }
                            else
                            {
                                bar.EndTime = datetime;
                                if (price > bar.High)
                                {
                                    bar.High = price;
                                }
                                if (price < bar.Low)
                                {
                                    bar.Low = price;
                                }
                                bar.Close   = price;
                                bar.Volume += size;
                                goto case BarType.Dynamic;
                            }

                        case BarType.Tick:
                            BarFactory.l9JS6GiROvEy77Co1R local_6 = local_3[item.BarSize] as BarFactory.l9JS6GiROvEy77Co1R;
                            if (local_6 == null)
                            {
                                local_6     = new BarFactory.l9JS6GiROvEy77Co1R();
                                local_6.bar = new Bar(BarType.Tick, item.BarSize, datetime, datetime, price, price, price, price, (long)size, 0);
                                local_3.Add(item.BarSize, local_6);
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 0, local_6.bar));
                            }
                            else
                            {
                                local_6.bar.EndTime = datetime;
                                if (price > local_6.bar.High)
                                {
                                    local_6.bar.High = price;
                                }
                                if (price < local_6.bar.Low)
                                {
                                    local_6.bar.Low = price;
                                }
                                local_6.bar.Close   = price;
                                local_6.bar.Volume += size;
                                ++local_6.VMmLV7HilK;
                            }
                            if (local_6.VMmLV7HilK == item.BarSize)
                            {
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 1, local_6.bar));
                                local_3.Remove(item.BarSize);
                                goto case BarType.Dynamic;
                            }
                            else
                            {
                                goto case BarType.Dynamic;
                            }

                        case BarType.Volume:
                            Bar local_7 = local_3[item.BarSize] as Bar;
                            if (local_7 == null)
                            {
                                local_7 = new Bar(BarType.Volume, item.BarSize, datetime, datetime, price, price, price, price, size, 0);
                                local_3.Add(item.BarSize, local_7);
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 0, local_7));
                            }
                            else
                            {
                                local_7.EndTime = datetime;
                                if (price > local_7.High)
                                {
                                    local_7.High = price;
                                }
                                if (price < local_7.Low)
                                {
                                    local_7.Low = price;
                                }
                                local_7.Close   = price;
                                local_7.Volume += size;
                            }
                            if (local_7.Volume >= item.BarSize)
                            {
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 1, local_7));
                                local_3.Remove(item.BarSize);
                                goto case BarType.Dynamic;
                            }
                            else
                            {
                                goto case BarType.Dynamic;
                            }

                        case BarType.Range:
                            Bar local_8 = local_3[item.BarSize] as Bar;
                            if (local_8 == null)
                            {
                                Bar local_8_1 = new Bar(BarType.Range, item.BarSize, datetime, datetime, price, price, price, price, size, 0);
                                local_3.Add(item.BarSize, local_8_1);
                                list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 0, local_8_1));
                                goto case BarType.Dynamic;
                            }
                            else
                            {
                                local_8.EndTime = datetime;
                                if (price > local_8.High)
                                {
                                    local_8.High = price;
                                }
                                if (price < local_8.Low)
                                {
                                    local_8.Low = price;
                                }
                                local_8.Volume += size;
                                bool local_9 = false;
                                while (!local_9)
                                {
                                    if (10000.0 * (local_8.High - local_8.Low) >= item.BarSize)
                                    {
                                        Bar local_10 = new Bar(BarType.Range, item.BarSize, datetime, datetime, price, price, price, price, 0, 0);
                                        if (local_8.High == price)
                                        {
                                            local_8.High  = local_8.Low + item.BarSize / 10000.0;
                                            local_8.Close = local_8.High;
                                            local_10.Low  = local_8.High;
                                        }
                                        if (local_8.Low == price)
                                        {
                                            local_8.Low   = local_8.High - item.BarSize / 10000.0;
                                            local_8.Close = local_8.Low;
                                            local_10.High = local_8.Low;
                                        }
                                        list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 1, local_8));
                                        list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6) 0, local_10));
                                        local_3[item.BarSize] = local_10;
                                        if (10000.0 * (local_10.High - local_10.Low) >= item.BarSize)
                                        {
                                            local_8 = local_10;
                                            local_9 = false;
                                        }
                                        else
                                        {
                                            local_9 = true;
                                        }
                                    }
                                    else
                                    {
                                        local_9 = true;
                                    }
                                }
                                goto case BarType.Dynamic;
                            }

                        case BarType.Dynamic:
                            if (local_3.Count == 0)
                            {
                                local_2.Remove(item.BarType);
                                if (local_2.Count == 0)
                                {
                                    this.A3ELH6L4QJ.Remove(instrument);
                                    continue;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                        default:
                            throw new NotSupportedException("NotSupported: " + item.BarType);
                        }
                    }
                }
            }

            foreach (BarFactory.zNxuFsXhPSM7NAan2D nxuFsXhPsM7Naan2D in list)
            {
                switch (nxuFsXhPsM7Naan2D.XUfLqKE3Ac)
                {
                case (BarFactory.yPiBmEZIjD7IoCdXp6) 0:
                    Bar bar = nxuFsXhPsM7Naan2D.bar;
                    this.EmitNewBarOpen(bar, instrument);
                    if (bar.BarType == BarType.Time)
                    {
                        this.nxZL6NXVXL(bar.BeginTime.AddSeconds(bar.Size));
                        continue;
                    }
                    else
                    {
                        continue;
                    }

                case (BarFactory.yPiBmEZIjD7IoCdXp6) 1:
                    this.EmitNewBar(nxuFsXhPsM7Naan2D.bar, instrument);
                    continue;

                default:
                    continue;
                }
            }
        }
Exemple #2
0
		private void AddTrade(IFIXInstrument instrument, DateTime datetime, double price, int size)
		{
			var list = new List<BarFactory.zNxuFsXhPSM7NAan2D>();
			lock (this)
			{
				foreach (BarFactoryItem item in this.items)
				{
					if (item.Enabled)
					{
						Hashtable local_2 = this.A3ELH6L4QJ[instrument] as Hashtable;
						if (local_2 == null)
						{
							local_2 = new Hashtable();
							this.A3ELH6L4QJ.Add(instrument, local_2);
						}
						SortedList local_3 = local_2[item.BarType] as SortedList;
						if (local_3 == null)
						{
							local_3 = new SortedList();
							local_2.Add(item.BarType, local_3);
						}
						switch (item.BarType)
						{
							case BarType.Time:
								Bar bar = local_3[item.BarSize] as Bar;
								if (bar == null)
								{
									DateTime local_5 = this.qJpLNA6Aiq(datetime, item.BarSize);
									Bar local_4_1 = new Bar(BarType.Time, item.BarSize, local_5, local_5, price, price, price, price, size, 0);
									local_3.Add(item.BarSize, local_4_1);
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)0, local_4_1));
									goto case BarType.Dynamic;
								}
								else
								{
									bar.EndTime = datetime;
									if (price > bar.High)
										bar.High = price;
									if (price < bar.Low)
										bar.Low = price;
									bar.Close = price;
									bar.Volume += size;
									goto case BarType.Dynamic;
								}
							case BarType.Tick:
								BarFactory.l9JS6GiROvEy77Co1R local_6 = local_3[item.BarSize] as BarFactory.l9JS6GiROvEy77Co1R;
								if (local_6 == null)
								{
									local_6 = new BarFactory.l9JS6GiROvEy77Co1R();
									local_6.bar = new Bar(BarType.Tick, item.BarSize, datetime, datetime, price, price, price, price, (long)size, 0);
									local_3.Add(item.BarSize, local_6);
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)0, local_6.bar));
								}
								else
								{
									local_6.bar.EndTime = datetime;
									if (price > local_6.bar.High)
										local_6.bar.High = price;
									if (price < local_6.bar.Low)
										local_6.bar.Low = price;
									local_6.bar.Close = price;
									local_6.bar.Volume += size;
									++local_6.VMmLV7HilK;
								}
								if (local_6.VMmLV7HilK == item.BarSize)
								{
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)1, local_6.bar));
									local_3.Remove(item.BarSize);
									goto case BarType.Dynamic;
								}
								else
									goto case BarType.Dynamic;
							case BarType.Volume:
								Bar local_7 = local_3[item.BarSize] as Bar;
								if (local_7 == null)
								{
									local_7 = new Bar(BarType.Volume, item.BarSize, datetime, datetime, price, price, price, price, size, 0);
									local_3.Add(item.BarSize, local_7);
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)0, local_7));
								}
								else
								{
									local_7.EndTime = datetime;
									if (price > local_7.High)
										local_7.High = price;
									if (price < local_7.Low)
										local_7.Low = price;
									local_7.Close = price;
									local_7.Volume += size;
								}
								if (local_7.Volume >= item.BarSize)
								{
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)1, local_7));
									local_3.Remove(item.BarSize);
									goto case BarType.Dynamic;
								}
								else
									goto case BarType.Dynamic;
							case BarType.Range:
								Bar local_8 = local_3[item.BarSize] as Bar;
								if (local_8 == null)
								{
									Bar local_8_1 = new Bar(BarType.Range, item.BarSize, datetime, datetime, price, price, price, price, size, 0);
									local_3.Add(item.BarSize, local_8_1);
									list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)0, local_8_1));
									goto case BarType.Dynamic;
								}
								else
								{
									local_8.EndTime = datetime;
									if (price > local_8.High)
										local_8.High = price;
									if (price < local_8.Low)
										local_8.Low = price;
									local_8.Volume += size;
									bool local_9 = false;
									while (!local_9)
									{
										if (10000.0 * (local_8.High - local_8.Low) >= item.BarSize)
										{
											Bar local_10 = new Bar(BarType.Range, item.BarSize, datetime, datetime, price, price, price, price, 0, 0);
											if (local_8.High == price)
											{
												local_8.High = local_8.Low + item.BarSize / 10000.0;
												local_8.Close = local_8.High;
												local_10.Low = local_8.High;
											}
											if (local_8.Low == price)
											{
												local_8.Low = local_8.High - item.BarSize / 10000.0;
												local_8.Close = local_8.Low;
												local_10.High = local_8.Low;
											}
											list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)1, local_8));
											list.Add(new BarFactory.zNxuFsXhPSM7NAan2D((BarFactory.yPiBmEZIjD7IoCdXp6)0, local_10));
											local_3[item.BarSize] = local_10;
											if (10000.0 * (local_10.High - local_10.Low) >= item.BarSize)
											{
												local_8 = local_10;
												local_9 = false;
											}
											else
												local_9 = true;
										}
										else
											local_9 = true;
									}
									goto case BarType.Dynamic;
								}
							case BarType.Dynamic:
								if (local_3.Count == 0)
								{
									local_2.Remove(item.BarType);
									if (local_2.Count == 0)
									{
										this.A3ELH6L4QJ.Remove(instrument);
										continue;
									}
									else
										continue;
								}
								else
									continue;
							default:
								throw new NotSupportedException("NotSupported: " + item.BarType);
						}
					}
				}
			}

			foreach (BarFactory.zNxuFsXhPSM7NAan2D nxuFsXhPsM7Naan2D in list)
			{
				switch (nxuFsXhPsM7Naan2D.XUfLqKE3Ac)
				{
					case (BarFactory.yPiBmEZIjD7IoCdXp6) 0:
						Bar bar = nxuFsXhPsM7Naan2D.bar;
						this.EmitNewBarOpen(bar, instrument);
						if (bar.BarType == BarType.Time)
						{
							this.nxZL6NXVXL(bar.BeginTime.AddSeconds(bar.Size));
							continue;
						}
						else
							continue;
					case (BarFactory.yPiBmEZIjD7IoCdXp6) 1:
						this.EmitNewBar(nxuFsXhPsM7Naan2D.bar, instrument);
						continue;
					default:
						continue;
				}
			}
		}