コード例 #1
0
ファイル: BookLifo.cs プロジェクト: nagyist/mkbiltek.trading
        //public new void SetAttributes(Dictionary<string, string> attributes, ref Dictionary<string, string> unusedAttributes)
        public new void AddSubElement(IStringifiable subElement)
        {
            Type type = subElement.GetType();

            if (type == typeof(RejectedFills.RecentKeyList))
            {
                m_RecentKeys = (RejectedFills.RecentKeyList)subElement;
            }
            else if (type == typeof(RejectedFills.RejectedFillEventArgs))
            {
                RejectedFills.RejectedFillEventArgs reject = (RejectedFills.RejectedFillEventArgs)subElement;
                bool isDuplicate = false;
                int  n           = 0;
                while ((!isDuplicate) && (n < m_RejectedFills.Count))
                {
                    isDuplicate = reject.OriginalFillEventArg.IsSameAs(m_RejectedFills[n].OriginalFillEventArg);
                    n++;
                }
                if (!isDuplicate)
                {
                    reject.Name = this.Name;// Temp- to add information
                    m_RejectedFills.Add(reject);
                }
            }
            else
            {
                base.AddSubElement(subElement);
            }
        }
コード例 #2
0
ファイル: BookLifo.cs プロジェクト: nagyist/mkbiltek.trading
        // *****************************************************************
        // ****                     Try Add()                           ****
        // *****************************************************************
        /// <summary>
        /// A fill event is presented to the book for acceptance.  The fill event is checked for validity,
        /// and if good added to the book. If not, a rejection event argument is created for caller.
        /// </summary>
        /// <param name="eventArg">fill event argument</param>
        /// <param name="rejection">rejection event create if false is returned</param>
        /// <returns>true if fill can be accepted, false if not.</returns>
        public new bool TryAdd(FillEventArgs eventArg, out RejectedFills.RejectedFillEventArgs rejection)          // Add a key workd override.
        {
            rejection = null;
            InstrumentKey key = eventArg.TTInstrumentKey;

            if (this.IsFillNew(eventArg, out rejection))
            {
                // Add fill to book
                Misty.Lib.OrderHubs.Fill aFill = eventArg.Fill;
                base.Add(aFill);
                // Update fill identification tables
                if (m_RecentKeys == null)
                {
                    m_RecentKeys = new RejectedFills.RecentKeyList();
                }
                if (!string.IsNullOrEmpty(eventArg.FillKey))
                {
                    m_RecentKeys.Add(eventArg.FillKey);
                }
                // Process rejections that are now accepted.
                if (eventArg.Type == FillType.UserAdjustment)
                {
                    int n = 0;
                    while (n < m_RejectedFills.Count)
                    {
                        if (m_RejectedFills[n].OriginalFillEventArg.IsSameAs(eventArg))
                        {
                            m_RejectedFills.RemoveAt(n);
                            break;
                        }
                        n++;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }


            /*
             * if (eventArg.Type == FillType.Historic || eventArg.Type == FillType.InitialPosition)
             * {   // If a fill is historic or initial, it needs to be verified that we have not already
             *  // incorporated this fill into our book in the past.
             *  // Other fills are blindly accepted since they should not have been seen before.
             *  if (this.IsFillNew(eventArg, out rejection))
             *  {
             *      base.Add(aFill);
             *      if (m_RecentKeys == null)
             *          m_RecentKeys = new RejectedFills.RecentKeyList();
             *      m_RecentKeys.Add(eventArg.FillKey);
             *  }
             *  else
             *  {
             *      return false;
             *  }
             * }
             * else
             * {   // Other kinds of fills; including "New" and "UserAdjustments" are always accepted as they
             *  // come in.
             *  base.Add(aFill);
             *  if (m_RecentKeys == null)
             *      m_RecentKeys = new RejectedFills.RecentKeyList();
             *  m_RecentKeys.Add(eventArg.FillKey);
             * }
             * return true;
             */
        } // TryAdd()