Beispiel #1
0
 internal void OnLevel2(Level2Update update)
 {
     if (this.strategy != null && this.strategy.status == StrategyStatus.Running)
     {
         this.strategy.OnLevel2_(update);
     }
 }
Beispiel #2
0
        internal void OnLevel2Update(Level2Update update)
        {
            OrderBook orderBook = this.book[update.instrumentId];

            if (orderBook == null)
            {
                orderBook = new OrderBook();
                this.book[update.instrumentId] = orderBook;
            }
            orderBook.Set(update);
        }
		public override object Read(BinaryReader reader)
		{
			Level2Update level2Update = new Level2Update();
			reader.ReadByte();
			level2Update.dateTime = DateTime.FromBinary(reader.ReadInt64());
			level2Update.providerId = reader.ReadByte();
			level2Update.instrumentId = reader.ReadInt32();
			int num = reader.ReadInt32();
			level2Update.entries = new Level2[num];
			for (int i = 0; i < num; i++)
			{
				level2Update.entries[i] = (Level2)this.streamerManager.Deserialize(reader);
			}
			return level2Update;
		}
        public override void Write(BinaryWriter writer, object obj)
        {
            Level2Update level2Update = (Level2Update)obj;

            writer.Write(0);
            writer.Write(level2Update.dateTime.ToBinary());
            writer.Write(level2Update.providerId);
            writer.Write(level2Update.instrumentId);
            writer.Write(level2Update.entries.Length);
            Level2[] entries = level2Update.entries;
            for (int i = 0; i < entries.Length; i++)
            {
                Level2 obj2 = entries[i];
                this.streamerManager.Serialize(writer, obj2);
            }
        }
Beispiel #5
0
        internal virtual void OnLevel2_(Level2Update update)
        {
            if (this.raiseEvents)
            {
                this.OnLevel2(this.framework.InstrumentManager.GetById(update.instrumentId), update);
            }
            LinkedList <Strategy> linkedList = this.strategiesByInstrument[update.instrumentId];

            if (linkedList != null)
            {
                for (LinkedListNode <Strategy> linkedListNode = linkedList.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
                {
                    linkedListNode.Data.OnLevel2_(update);
                }
            }
        }
Beispiel #6
0
        private void OnLevel2Update(Event e)
        {
            this.data_count += 1L;
            Level2Update level2Update = (Level2Update)e;

            if (this.framework.Clock.Mode == ClockMode.Simulation)
            {
                this.framework.Clock.DateTime = level2Update.dateTime;
            }
            else
            {
                level2Update.dateTime = this.framework.Clock.DateTime;
            }
            this.framework.dataManager.OnLevel2Update(level2Update);
            this.framework.providerManager.executionSimulator.OnLevel2(level2Update);
            this.framework.StrategyManager.OnLevel2(level2Update);
        }
        public override object Read(BinaryReader reader)
        {
            Level2Update level2Update = new Level2Update();

            reader.ReadByte();
            level2Update.dateTime     = DateTime.FromBinary(reader.ReadInt64());
            level2Update.providerId   = reader.ReadByte();
            level2Update.instrumentId = reader.ReadInt32();
            int num = reader.ReadInt32();

            level2Update.entries = new Level2[num];
            for (int i = 0; i < num; i++)
            {
                level2Update.entries[i] = (Level2)this.streamerManager.Deserialize(reader);
            }
            return(level2Update);
        }
Beispiel #8
0
        internal void Set(Level2Update update)
        {
            Level2[] entries = update.entries;
            for (int i = 0; i < entries.Length; i++)
            {
                Level2       level = entries[i];
                IList <Tick> list  = null;
                switch (level.side)
                {
                case Level2Side.Bid:
                    list = this.bids;
                    break;

                case Level2Side.Ask:
                    list = this.asks;
                    break;
                }
                switch (level.action)
                {
                case Level2UpdateAction.New:
                    list.Insert(level.position, new Tick(level));
                    break;

                case Level2UpdateAction.Change:
                    list[level.position].size = level.size;
                    break;

                case Level2UpdateAction.Delete:
                    list.RemoveAt(level.position);
                    break;

                case Level2UpdateAction.Reset:
                    list.Clear();
                    break;
                }
            }
        }
Beispiel #9
0
 internal virtual void OnLevel2_(Level2Update update)
 {
     if (this.raiseEvents)
     {
         this.OnLevel2(this.framework.InstrumentManager.GetById(update.instrumentId), update);
     }
     LinkedList<Strategy> linkedList = this.strategiesByInstrument[update.instrumentId];
     if (linkedList != null)
     {
         for (LinkedListNode<Strategy> linkedListNode = linkedList.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
         {
             linkedListNode.Data.OnLevel2_(update);
         }
     }
 }
Beispiel #10
0
 public void OnLevel2(Level2Update update)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 protected internal virtual void OnLevel2(Instrument instrument, Level2Update update)
 {
 }
Beispiel #12
0
		public void OnLevel2(Level2Update update)
		{
		}
Beispiel #13
0
 internal void Set(Level2Update update)
 {
     Level2[] entries = update.entries;
     for (int i = 0; i < entries.Length; i++)
     {
         Level2 level = entries[i];
         IList<Tick> list = null;
         switch (level.side)
         {
         case Level2Side.Bid:
             list = this.bids;
             break;
         case Level2Side.Ask:
             list = this.asks;
             break;
         }
         switch (level.action)
         {
         case Level2UpdateAction.New:
             list.Insert(level.position, new Tick(level));
             break;
         case Level2UpdateAction.Change:
             list[level.position].size = level.size;
             break;
         case Level2UpdateAction.Delete:
             list.RemoveAt(level.position);
             break;
         case Level2UpdateAction.Reset:
             list.Clear();
             break;
         }
     }
 }
Beispiel #14
0
 public void OnLevel2(Level2Update update)
 {
 }
Beispiel #15
0
 protected internal virtual void OnLevel2(Instrument instrument, Level2Update update)
 {
 }
Beispiel #16
0
 internal void OnLevel2(Level2Update update)
 {
     if (this.strategy != null && this.strategy.status == StrategyStatus.Running)
     {
         this.strategy.OnLevel2_(update);
     }
 }
Beispiel #17
0
		internal void OnLevel2Update(Level2Update update)
		{
			OrderBook orderBook = this.book[update.instrumentId];
			if (orderBook == null)
			{
				orderBook = new OrderBook();
				this.book[update.instrumentId] = orderBook;
			}
			orderBook.Set(update);
		}