예제 #1
0
 /// <summary>
 /// Deep copies the calling PriceLevel to the PriceLevel object specified as a parameter.
 /// </summary>
 /// <param name="destinationPriceLevel"></param>
 public void CopyInto(PriceLevel destinationPriceLevel)
 {
     destinationPriceLevel.Price = Price;
     destinationPriceLevel.Size = Size;
     destinationPriceLevel.UpdateTime = UpdateTime;
     destinationPriceLevel.NumberOfOrders = NumberOfOrders;
 }
예제 #2
0
        private void InitializeOrderBook(int depth)
        {
            Bid = new PriceLevel[11];
            Ask = new PriceLevel[11];

            for (int i = 0; i < depth + 1; i++)
            {
                Bid[i] = PriceLevel.GetDummy();
                Ask[i] = PriceLevel.GetDummy();
            }
        }
예제 #3
0
        private void MergeDepth(PriceLevel impliedDepthLevel, PriceLevel consolidatedDepthLevel)
        {
            consolidatedDepthLevel.Size       += impliedDepthLevel.Size;
            consolidatedDepthLevel.ImpliedSize = impliedDepthLevel.Size;

            if (impliedDepthLevel.UpdateTime > consolidatedDepthLevel.UpdateTime)
            {
                consolidatedDepthLevel.UpdateTime = impliedDepthLevel.UpdateTime;
            }

            consolidatedDepthLevel.HasImpliedSize = true;
        }
예제 #4
0
        private void InsertIntoNonNullLevel(PriceLevel[] consolidatedDepth, PriceLevel impliedDepthLevel, int outrightDepth, int insertionPoint)
        {
            ShiftDepthLevelsDown(consolidatedDepth, from: outrightDepth, to: insertionPoint);

            impliedDepthLevel.CopyInto(consolidatedDepth[insertionPoint]);
        }
예제 #5
0
 private void InsertIntoNullLevel(PriceLevel impliedDepthLevel, PriceLevel consolidatedDepthLevel)
 {
     impliedDepthLevel.CopyInto(consolidatedDepthLevel);
 }
예제 #6
0
 private void InsertIntoNullLevel(PriceLevel impliedDepthLevel, PriceLevel consolidatedDepthLevel)
 {
     impliedDepthLevel.CopyInto(consolidatedDepthLevel);
 }
예제 #7
0
        private void InsertIntoNonNullLevel(PriceLevel[] consolidatedDepth, PriceLevel impliedDepthLevel, int outrightDepth, int insertionPoint)
        {
            ShiftDepthLevelsDown(consolidatedDepth, from: outrightDepth, to: insertionPoint);

            impliedDepthLevel.CopyInto(consolidatedDepth[insertionPoint]);
        }
예제 #8
0
        private void MergeDepth(PriceLevel impliedDepthLevel, PriceLevel consolidatedDepthLevel)
        {
            consolidatedDepthLevel.Size += impliedDepthLevel.Size;
            consolidatedDepthLevel.ImpliedSize = impliedDepthLevel.Size;

            if (impliedDepthLevel.UpdateTime > consolidatedDepthLevel.UpdateTime)
                consolidatedDepthLevel.UpdateTime = impliedDepthLevel.UpdateTime;

            consolidatedDepthLevel.HasImpliedSize = true;
        }
예제 #9
0
        private int GetMatchingOutrightLevel(PriceLevel[] consolidatedDepth, int? impliedPrice, int outrightDepth, ref int previousMatch)
        {
            for (int i = previousMatch; i < outrightDepth + 1; i++)
            {
                int? outrightPrice = consolidatedDepth[i].Price;

                if (outrightPrice == impliedPrice)
                {
                    previousMatch = i;
                    return i;
                }

                if (impliedPrice > outrightPrice)
                {
                    break;
                }
            }

            return 0;
        }
예제 #10
0
 private void ShiftDepthLevelsDown(PriceLevel[] depth, int from, int to)
 {
     for (int i = from; i > to; i--)
     {
         depth[i - 1].CopyInto(depth[i]);
     }
 }
예제 #11
0
        private void ShiftDepthLevelsUp(PriceLevel[] depth, DateTime updateTime, int from, int to)
        {
            for (int i = from; i < to; i++)
            {
                depth[i + 1].CopyInto(depth[i]);

                if (i == Depth - 1)
                {
                    depth[Depth].Delete(updateTime);
                }
            }
        }
예제 #12
0
        private void InitializeOrderBook(int depth)
        {
            Bid = new PriceLevel[11];
            Ask = new PriceLevel[11];

            for (int i = 0; i < depth + 1; i++)
            {
                Bid[i] = PriceLevel.GetDummy();
                Ask[i] = PriceLevel.GetDummy();
            }
        }