/// <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);
                }
            }
        }
Esempio n. 2
0
 public static extern bool ConnectMarketAgent(string srvAddr, string brokerID, string userID, string password, QuoteUpdateDelegate quoteUpdateHandler);