Exemple #1
0
 private void EmitChanged(MDSide side, MDOperation operation, int position)
 {
     if (this.Changed != null)
     {
         this.Changed(this, new OrderBookEventArgs(side, operation, position));
     }
 }
Exemple #2
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;
 }
        internal static BidAsk Convert(MDSide side)
        {
            switch (side)
            {
            case MDSide.Bid:
                return(BidAsk.Bid);

            case MDSide.Ask:
                return(BidAsk.Ask);

            default:
                throw new NotSupportedException(string.Format("MDSide is not supported - {0}", side));
            }
        }
Exemple #4
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);
            }
        }
        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));
            }
        }
Exemple #6
0
        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 != -1 && size != -1)
            {
                EmitNewMarketDepth(instrument, new MarketDepth(datatime, "", position, insert, ask, price, size));
            }
        }
Exemple #7
0
		private void EmitChanged(MDSide side, MDOperation operation, int position)
		{
			if (this.Changed != null)
				this.Changed(this, new OrderBookEventArgs(side, operation, position));
		}
        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);
        }
Exemple #9
0
 public OrderBookEventArgs(MDSide size, MDOperation operation, int position) : base()
 {
     this.Side      = size;
     this.Operation = operation;
     this.Position  = position;
 }
		internal static BidAsk Convert(MDSide side)
		{
			switch (side)
			{
			case MDSide.Bid:
				return BidAsk.Bid;
			case MDSide.Ask:
				return BidAsk.Ask;
			default:
				throw new NotSupportedException(string.Format("MDSide is not supported - {0}", side));
			}
		}
Exemple #11
0
        public OrderBookEventArgs(MDSide size, MDOperation operation, int position) : base()
		{
			this.Side = size;
			this.Operation = operation;
			this.Position = position;
		}
Exemple #12
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);
			}
		}
Exemple #13
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)
		{

		}
Exemple #14
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;
		}
Exemple #15
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)
 {
 }