/// <summary>
 /// If the provided order book entry exists in the price level a
 /// <code>MamdaOrderBookException</code> exception is thrown. Otherwise the
 /// method simply returns.
 /// </summary>
 /// <param name="entry">The entry whose presence in the level is being determined.</param>
 /// <exception cref="MamdaOrderBookException">Throws MamdaOrderBookException if the entry is found in the price</exception>
 public void checkNotExist(MamdaOrderBookEntry entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             throw new MamdaOrderBookException(
                       "attempted to add am existent entry: " + entry.getId());
         }
     }
 }
 /// <summary>
 /// Remove an order book entry from the price level.
 /// <see cref="MamdaOrderBookEntry"/>
 /// </summary>
 /// <param name="entry">The entry which is to be removed from the price level.</param>
 public void removeEntry(MamdaOrderBookEntry entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             mEntries.RemoveAt(i);
             return;
         }
     }
     if (mStrictChecking)
     {
         throw new MamdaOrderBookException(
                   "attempted to delete a non-existent entry: " + entry.getId());
     }
 }
 /// <summary>
 /// Update the details of an existing entry in the level.
 /// </summary>
 /// <param name="entry">An instance of <code>MamdaOrderBookEntry</code> with the
 /// new details for the entry in the level.</param>
 public void updateEntry(MamdaOrderBookEntry entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             existingEntry.setDetails(entry);
             return;
         }
     }
     if (mStrictChecking)
     {
         throw new MamdaOrderBookException(
                   "attempted to update a non-existent entry: " + entry.getId());
     }
 }
Пример #4
0
 /// <summary>
 /// Update the details of an existing entry in the level.
 /// </summary>
 /// <param name="entry">An instance of <code>MamdaOrderBookEntry</code> with the
 /// new details for the entry in the level.</param>
 public void updateEntry(MamdaOrderBookEntry  entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             existingEntry.setDetails(entry);
             return;
         }
     }
     if (mStrictChecking)
     {
         throw new MamdaOrderBookException(
             "attempted to update a non-existent entry: " + entry.getId());
     }
 }
Пример #5
0
 /// <summary>
 /// Remove an order book entry from the price level.
 /// <see cref="MamdaOrderBookEntry"/>
 /// </summary>
 /// <param name="entry">The entry which is to be removed from the price level.</param>
 public void removeEntry(MamdaOrderBookEntry  entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             mEntries.RemoveAt(i);
             return;
         }
     }
     if (mStrictChecking)
     {
         throw new MamdaOrderBookException (
             "attempted to delete a non-existent entry: " + entry.getId());
     }
 }
Пример #6
0
 /// <summary>
 /// If the provided order book entry exists in the price level a
 /// <code>MamdaOrderBookException</code> exception is thrown. Otherwise the
 /// method simply returns.
 /// </summary>
 /// <param name="entry">The entry whose presence in the level is being determined.</param>
 /// <exception cref="MamdaOrderBookException">Throws MamdaOrderBookException if the entry is found in the price</exception>
 public void checkNotExist(MamdaOrderBookEntry  entry)
 {
     for (int i = 0; i < mEntries.Count; i++)
     {
         MamdaOrderBookEntry existingEntry =
             (MamdaOrderBookEntry)mEntries[i];
         if (existingEntry.equalId(entry.getId()))
         {
             throw new MamdaOrderBookException(
                 "attempted to add am existent entry: " + entry.getId());
         }
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="lhs"></param>
        /// <param name="rhs"></param>
        public void setAsDifference(
            MamdaOrderBookPriceLevel lhs,
            MamdaOrderBookPriceLevel rhs)
        {
            int lhsBookSize = lhs.mEntries.Count;
            int rhsBookSize = rhs.mEntries.Count;
            int lhsIndex    = 0;
            int rhsIndex    = 0;

            while ((lhsIndex < lhsBookSize) && (rhsIndex < rhsBookSize))
            {
                string lhsId   = null;
                string rhsId   = null;
                long   lhsSize = 0;
                long   rhsSize = 0;
                MamdaOrderBookEntry lhsEntry = null;
                MamdaOrderBookEntry rhsEntry = null;

                if (lhsIndex < lhsBookSize)
                {
                    lhsEntry = (MamdaOrderBookEntry)lhs.mEntries[lhsIndex];
                    lhsId    = lhsEntry.getId();
                    lhsSize  = lhsEntry.getSize();
                }
                if (rhsIndex < rhsBookSize)
                {
                    rhsEntry = (MamdaOrderBookEntry)rhs.mEntries[rhsIndex];
                    rhsId    = rhsEntry.getId();
                    rhsSize  = rhsEntry.getSize();
                }

                if ((lhsId != null) && (rhsId != null))
                {
                    if (lhsId == rhsId)
                    {
                        // Same ID, maybe different size.
                        if (lhsSize != rhsSize)
                        {
                            MamdaOrderBookEntry updateEntry = new MamdaOrderBookEntry(rhsEntry);
                            updateEntry.setAction(MamdaOrderBookEntry.Actions.Update);
                            addEntry(updateEntry);
                        }
                        lhsIndex++;
                        rhsIndex++;
                        continue;
                    }
                    else
                    {
                        // Different ID (either something exists on the LHS
                        // and not on RHS or vice versa).
                        int rhsFound = findEntryAfter(rhs.mEntries, rhsIndex, lhsId);
                        if (rhsFound != rhsSize)
                        {
                            // The ID from the LHS was found on the RHS, so
                            // there must have been additional entries on the
                            // RHS, which we now need to add.
                            do
                            {
                                addEntry((MamdaOrderBookEntry)rhs.mEntries[rhsIndex]);
                                rhsIndex++;
                            }while (rhsIndex < rhsFound);
                        }
                        else
                        {
                            // The ID from the LHS was not present on the RHS,
                            // so add the LHS entry.  Note: it would probably
                            // be faster to iterate over the LHS side rather
                            // than begin the loop again.
                            addEntry((MamdaOrderBookEntry)lhs.mEntries[lhsIndex]);
                            lhsIndex++;
                        }
                    }
                }
            }
            if (mPrice != null && rhs.getPrice() != null)
            {
                mPrice.destroy();
            }
            mPrice = rhs.getPrice();
            setSizeChange(rhs.getSize() - lhs.getSize());
            setSize(rhs.getSize());
            setNumEntries(rhs.getNumEntries());
            setAction(Actions.Update);
            mTime = rhs.getTime();
            setSide(rhs.getSide());
        }