public void tdSink_ITradeDeskEvents_Event_OnRowChanged(object tableDisp, string rowID) { if (_manager.LoggedIn) { try { FXCore.ITableAut t = (FXCore.ITableAut)tableDisp; if ("offers".Equals(t.Type)) { DataTick dataTick = new DataTick(); TableAut offersTable = (TableAut)_manager.Desk.FindMainTable("offers"); RowAut instrumentRow = (RowAut)offersTable.FindRow("OfferID", rowID, 0); dataTick.Ask = (decimal)((double)instrumentRow.CellValue("Ask")); dataTick.Bid = (decimal)((double)instrumentRow.CellValue("Bid")); dataTick.DateTime = (DateTime)instrumentRow.CellValue("Time"); PostQuoteUpdate((string)instrumentRow.CellValue("Instrument"), dataTick); // TODO: this may be way too often, since it will update on each tick of any symbol... // Also update the accounts informations. foreach (AccountInfo accountInfo in _manager.Orders.GetAvailableAccounts()) { _orderExecutionStub.UpdateAccountInfo(accountInfo); } } } catch (System.Exception ex) { SystemMonitor.Error(ex.ToString()); } } }
/// <summary> /// Managed thread entrance only. /// </summary> void Managed_tdSink_ITradeDeskEvents_Event_OnRowChanged(object tableDisp, string rowID) { if (LoggedIn) { TradeDeskAut desk = _desk; if (desk == null) { return; } try { FXCore.ITableAut t = (FXCore.ITableAut)tableDisp; if ("offers".Equals(t.Type)) { TableAut offersTable = (TableAut)desk.FindMainTable("offers"); RowAut instrumentRow = (RowAut)offersTable.FindRow("OfferID", rowID, 0); DataTick dataTick = new DataTick(); dataTick.Ask = (decimal)((double)instrumentRow.CellValue("Ask")); dataTick.Bid = (decimal)((double)instrumentRow.CellValue("Bid")); dataTick.DateTime = (DateTime)instrumentRow.CellValue("Time"); QuoteUpdateDelegate delegateInstance = QuoteUpdatedEvent; if (delegateInstance != null) { GeneralHelper.FireAndForget(delegateInstance, this, (string)instrumentRow.CellValue("Instrument"), dataTick); } } else if ("orders".Equals(t.Type)) { // Orders table empty? //TableAut offersTable = (TableAut)desk.FindMainTable("orders"); //RowAut instrumentRow = (RowAut)offersTable.FindRow("OrderID", rowID, 0); //string accountId; //OrderInfo? info = Managed_ExtractOrderInfo(instrumentRow, out accountId); //OrderUpdateDelegate delegateInstance = OrderUpdatedEvent; //if (info.HasValue && delegateInstance != null) //{ // GeneralHelper.FireAndForget(delegateInstance, this, accountId, info.Value); //} } else if ("accounts".Equals(t.Type)) { ItemUpdateDelegate delegateInstance = AccountUpdatedEvent; if (delegateInstance != null) { GeneralHelper.FireAndForget(delegateInstance, this, rowID); } } } catch (System.Exception ex) { SystemMonitor.Error("Failed to handle OnRow event", ex); } } }
/// <summary> /// Helper, convert to known order information. /// </summary> /// <returns></returns> OrderInfo?Managed_ExtractOrderInfo(RowAut orderInstrumentRow, out string accountId) { accountId = (string)orderInstrumentRow.CellValue("AccountID"); OrderInfo info = new OrderInfo(); return(null); }
/// <summary> /// Helper, convert to known order information. /// </summary> /// <returns></returns> OrderInfo? Managed_ExtractOrderInfo(RowAut orderInstrumentRow, out string accountId) { accountId = (string)orderInstrumentRow.CellValue("AccountID"); OrderInfo info = new OrderInfo(); return null; }