/// <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; }
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(); } }
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; }
private void InsertIntoNonNullLevel(PriceLevel[] consolidatedDepth, PriceLevel impliedDepthLevel, int outrightDepth, int insertionPoint) { ShiftDepthLevelsDown(consolidatedDepth, from: outrightDepth, to: insertionPoint); impliedDepthLevel.CopyInto(consolidatedDepth[insertionPoint]); }
private void InsertIntoNullLevel(PriceLevel impliedDepthLevel, PriceLevel consolidatedDepthLevel) { impliedDepthLevel.CopyInto(consolidatedDepthLevel); }
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; }
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; }
private void ShiftDepthLevelsDown(PriceLevel[] depth, int from, int to) { for (int i = from; i > to; i--) { depth[i - 1].CopyInto(depth[i]); } }
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); } } }