Esempio n. 1
0
        internal static OrderBookAction Convert(MDOperation operation)
        {
            switch (operation)
            {
            case MDOperation.Insert:
                return(OrderBookAction.Insert);

            case MDOperation.Update:
                return(OrderBookAction.Update);

            case MDOperation.Delete:
                return(OrderBookAction.Delete);

            case (MDOperation)3:
                break;

            case MDOperation.Reset:
                return(OrderBookAction.Reset);

            default:
                if (operation == MDOperation.Undefined)
                {
                    return(OrderBookAction.Undefined);
                }
                break;
            }
            throw new NotSupportedException(string.Format("MDOperation is not supported - {0}", operation));
        }
        private bool EmitNewMarketDepth(Instrument instrument, DateTime datatime, int position, MDSide ask, double price, int size)
        {
            bool        bRet   = false;
            MDOperation insert = MDOperation.Update;

            if (MDSide.Ask == ask)
            {
                if (position >= instrument.OrderBook.Ask.Count)
                {
                    insert = MDOperation.Insert;
                }
            }
            else
            {
                if (position >= instrument.OrderBook.Bid.Count)
                {
                    insert = MDOperation.Insert;
                }
            }

            if (price != 0 && size != 0)
            {
                EmitNewMarketDepth(instrument, new MarketDepth(datatime, "", position, insert, ask, price, size));
                bRet = true;
            }
            return(bRet);
        }
Esempio n. 3
0
 private void EmitChanged(MDSide side, MDOperation operation, int position)
 {
     if (this.Changed != null)
     {
         this.Changed(this, new OrderBookEventArgs(side, operation, position));
     }
 }
        private void EmitNewMarketDepth(Instrument instrument, DateTime datatime, int position, MDSide ask, double price, int size)
        {
            MDOperation insert = MDOperation.Update;

            if (MDSide.Ask == ask)
            {
                if (position >= instrument.OrderBook.Ask.Count)
                {
                    insert = MDOperation.Insert;
                }
            }
            else
            {
                if (position >= instrument.OrderBook.Bid.Count)
                {
                    insert = MDOperation.Insert;
                }
            }

            if (price != 0 && size != 0)
            {
                EmitNewMarketDepth(instrument, new MarketDepth(datatime, "", position, insert, ask, price, size));
            }
            else
            {
                insert = MDOperation.Delete;
                EmitNewMarketDepth(instrument, new MarketDepth(datatime, "", position, insert, ask, price, size));
            }
        }
Esempio n. 5
0
 public MarketDepth(DateTime datetime, byte providerId, string marketMaker, string source, int position, MDOperation operation, MDSide side, double price, int size)
 {
     this.dateTime    = datetime;
     this.providerId  = providerId;
     this.MarketMaker = marketMaker;
     this.source      = source;
     this.position    = position;
     this.operation   = operation;
     this.side        = side;
     this.price       = price;
     this.size        = size;
 }
Esempio n. 6
0
        public virtual void ReadFrom(BinaryReader reader)
        {
            byte num = reader.ReadByte();

            switch (num)
            {
            case (byte)1:
                this.dateTime    = new DateTime(reader.ReadInt64());
                this.MarketMaker = reader.ReadString();
                this.Source      = reader.ReadString();
                this.Side        = (MDSide)reader.ReadByte();
                this.Price       = Math.Round((double)reader.ReadSingle(), 4);
                this.Size        = reader.ReadInt32();
                this.ProviderId  = reader.ReadByte();
                this.Position    = -1;
                this.Operation   = MDOperation.Undefined;
                break;

            case (byte)2:
                this.dateTime    = new DateTime(reader.ReadInt64());
                this.MarketMaker = reader.ReadString();
                this.source      = reader.ReadString();
                this.side        = (MDSide)reader.ReadByte();
                this.price       = Math.Round((double)reader.ReadSingle(), 4);
                this.size        = reader.ReadInt32();
                this.providerId  = reader.ReadByte();
                this.position    = reader.ReadInt32();
                this.operation   = (MDOperation)reader.ReadByte();
                break;

            case (byte)3:
                this.dateTime    = new DateTime(reader.ReadInt64());
                this.MarketMaker = reader.ReadString();
                this.source      = reader.ReadString();
                this.side        = (MDSide)reader.ReadByte();
                this.price       = reader.ReadDouble();
                this.size        = reader.ReadInt32();
                this.providerId  = reader.ReadByte();
                this.position    = reader.ReadInt32();
                this.operation   = (MDOperation)reader.ReadByte();
                break;

            default:
                throw new Exception("" + (object)num);
            }
        }
Esempio n. 7
0
		private void EmitChanged(MDSide side, MDOperation operation, int position)
		{
			if (this.Changed != null)
				this.Changed(this, new OrderBookEventArgs(side, operation, position));
		}
Esempio n. 8
0
 public OrderBookEventArgs(MDSide size, MDOperation operation, int position) : base()
 {
     this.Side      = size;
     this.Operation = operation;
     this.Position  = position;
 }
Esempio n. 9
0
		internal static OrderBookAction Convert(MDOperation operation)
		{
			switch (operation)
			{
			case MDOperation.Insert:
				return OrderBookAction.Insert;
			case MDOperation.Update:
				return OrderBookAction.Update;
			case MDOperation.Delete:
				return OrderBookAction.Delete;
			case (MDOperation)3:
				break;
			case MDOperation.Reset:
				return OrderBookAction.Reset;
			default:
				if (operation == MDOperation.Undefined)
				{
					return OrderBookAction.Undefined;
				}
				break;
			}
			throw new NotSupportedException(string.Format("MDOperation is not supported - {0}", operation));
		}
Esempio n. 10
0
        public OrderBookEventArgs(MDSide size, MDOperation operation, int position) : base()
		{
			this.Side = size;
			this.Operation = operation;
			this.Position = position;
		}
Esempio n. 11
0
		public virtual void ReadFrom(BinaryReader reader)
		{
			byte num = reader.ReadByte();
			switch (num)
			{
				case (byte) 1:
					this.dateTime = new DateTime(reader.ReadInt64());
					this.MarketMaker = reader.ReadString();
					this.Source = reader.ReadString();
					this.Side = (MDSide)reader.ReadByte();
					this.Price = Math.Round((double)reader.ReadSingle(), 4);
					this.Size = reader.ReadInt32();
					this.ProviderId = reader.ReadByte();
					this.Position = -1;
					this.Operation = MDOperation.Undefined;
					break;
				case (byte) 2:
					this.dateTime = new DateTime(reader.ReadInt64());
					this.MarketMaker = reader.ReadString();
					this.source = reader.ReadString();
					this.side = (MDSide)reader.ReadByte();
					this.price = Math.Round((double)reader.ReadSingle(), 4);
					this.size = reader.ReadInt32();
					this.providerId = reader.ReadByte();
					this.position = reader.ReadInt32();
					this.operation = (MDOperation)reader.ReadByte();
					break;
				case (byte) 3:
					this.dateTime = new DateTime(reader.ReadInt64());
					this.MarketMaker = reader.ReadString();
					this.source = reader.ReadString();
					this.side = (MDSide)reader.ReadByte();
					this.price = reader.ReadDouble();
					this.size = reader.ReadInt32();
					this.providerId = reader.ReadByte();
					this.position = reader.ReadInt32();
					this.operation = (MDOperation)reader.ReadByte();
					break;
				default:
					throw new Exception("" + (object)num);
			}
		}
Esempio n. 12
0
		public MarketDepth(DateTime datetime, string marketMaker, int position, MDOperation operation, MDSide side, double price, int size) : this(datetime, 0, marketMaker, String.Empty, position, operation, side, price, size)
		{

		}
Esempio n. 13
0
		public MarketDepth(DateTime datetime, byte providerId, string marketMaker, string source, int position, MDOperation operation, MDSide side, double price, int size)
		{
			this.dateTime = datetime;
			this.providerId = providerId;
			this.MarketMaker = marketMaker;
			this.source = source;
			this.position = position;
			this.operation = operation;
			this.side = side;
			this.price = price;
			this.size = size;
		}
Esempio n. 14
0
 public MarketDepth(DateTime datetime, string marketMaker, int position, MDOperation operation, MDSide side, double price, int size) : this(datetime, 0, marketMaker, String.Empty, position, operation, side, price, size)
 {
 }