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); } } }
void PostQuoteUpdate(string forexPair, DataTick dataTick) { RuntimeDataSessionInformation sessionInformation = _dataSourceStub.GetSymbolSessionInformation(new Symbol("Forex", forexPair)); if (sessionInformation != null && _subscribedSymbols.ContainsKey(forexPair)) { CombinedDataSubscriptionInformation info = _dataSourceStub.GetUnsafeSessionSubscriptions(sessionInformation.Info); if (info != null && info.GetCombinedDataSubscription().QuoteSubscription) { _dataSourceStub.UpdateQuote(sessionInformation.Info, new Quote(dataTick.Ask, dataTick.Bid, null, dataTick.DateTime), null); foreach (TimeSpan supportedPeriod in DefaultAvailablePeriods) { _dataSourceStub.UpdateDataHistory(sessionInformation.Info, new DataHistoryUpdate(supportedPeriod, new DataTick[] { dataTick })); } } } }
void manager_QuoteUpdatedEvent(FXCMConnectionManager manager, string symbolName, DataTick dataTick) { Symbol symbol = new Symbol(Symbol.SymbolGroup.Forex, symbolName); DataSourceStub dataSourceStub = _dataSourceStub; if (dataSourceStub == null) { return; } RuntimeDataSessionInformation sessionInformation = dataSourceStub.GetSymbolSessionInformation(symbol); if (sessionInformation == null) { return; } CombinedDataSubscriptionInformation info = dataSourceStub.GetUnsafeSessionSubscriptions(sessionInformation.Info); if (info != null && info.GetCombinedDataSubscription().QuoteSubscription) { dataSourceStub.UpdateQuote(sessionInformation.Info, new Quote(dataTick.Ask, dataTick.Bid, null, dataTick.DateTime), null); foreach (TimeSpan supportedPeriod in DefaultAvailablePeriods) { dataSourceStub.UpdateDataHistory(sessionInformation.Info, new DataHistoryUpdate(supportedPeriod, new DataTick[] { dataTick })); } } }