}// ProcessOrderAdded // // private void ProcessOrderDeleted(TT.OrderDeletedEventArgs eventArg) { Log.BeginEntry(LogLevel.Minor, "ProcessOrderDeleted:"); OrderBookEventArgs outgoingEventArg = null; // outgoing event, if needed. TT.Order ttOrder = eventArg.OldOrder; InstrumentName name; OrderBook baseBook; if (m_TTKey2Name.TryGetValue(ttOrder.InstrumentKey, out name) && this.TryEnterBookWrite(name, out baseBook)) { OrderBookTT book = (OrderBookTT)baseBook; string tag; if (book.m_TagTT2Bre.TryGetValue(ttOrder.SiteOrderKey, out tag)) { Order deletedOrder; if (book.TryDeleteOrder(tag, out deletedOrder)) { outgoingEventArg = new OrderBookEventArgs(this, name, OrderBookEventArgs.EventTypes.DeletedOrder); // Load out-going eventArg outgoingEventArg.Order = deletedOrder; Log.AppendEntry(" Deleted order {0} to book {1}.", deletedOrder, book); } } this.ExitBookWrite(baseBook); } Log.EndEntry(); if (outgoingEventArg != null) { OnBookChanged(outgoingEventArg); } }// ProcessOrderDelete()
}// ProcessMarketFoundResource() // // // #endregion//Private HubEvent Handler #region Private Order Update Handlers // ***************************************************************** // **** Private Order Update Handlers **** // ***************************************************************** // // private void ProcessOrderAdded(TT.OrderAddedEventArgs eventArg) { Log.BeginEntry(LogLevel.Minor, "ProcessOrderAdded:"); OrderBookEventArgs outgoingEventArg = null; TT.Order ttOrder = eventArg.Order; InstrumentName name; OrderBook book; if (m_TTKey2Name.TryGetValue(ttOrder.InstrumentKey, out name) && this.TryEnterBookWrite(name, out book)) { // We know this TTKey, and have an associated book! OrderBookTT booktt = (OrderBookTT)book; Order newOrder = booktt.CreateNewOrder(); int mktSign = Misty.Lib.Utilities.QTMath.BuySign; newOrder.Side = Misty.Lib.Utilities.QTMath.BuySide; if (ttOrder.BuySell == TT.BuySell.Sell) { mktSign = Misty.Lib.Utilities.QTMath.SellSign; newOrder.Side = Misty.Lib.Utilities.QTMath.SellSide; } newOrder.Qty = mktSign * ttOrder.WorkingQuantity.ToInt(); newOrder.IPrice = (int)Math.Round(ttOrder.LimitPrice.ToDouble() / book.MinimumPriceTick); int intPrice = ttOrder.LimitPrice.ToInt(); // for debugging if (book.TryAddOrder(newOrder)) { booktt.m_TagBre2TT.Add(newOrder.Tag, ttOrder.SiteOrderKey); booktt.m_TagTT2Bre.Add(ttOrder.SiteOrderKey, newOrder.Tag); outgoingEventArg = new OrderBookEventArgs(this, name, OrderBookEventArgs.EventTypes.NewOrder); // Load out-going eventArg outgoingEventArg.Order = newOrder; Log.AppendEntry(" Added new order {0} to book {2}.", newOrder, ttOrder, book); } else { Log.AppendEntry(" Failed to add order {0} to book {2}. Store order for later.", newOrder, ttOrder, book); StoreTTEvent(eventArg, ttOrder.InstrumentKey); } this.ExitBookWrite(book); } else { // We have no book for this instrument. StoreTTEvent(eventArg, ttOrder.InstrumentKey); // Store order and request mkt details. } Log.EndEntry(); if (outgoingEventArg != null) { OnBookChanged(outgoingEventArg); } }// ProcessOrderAdded