/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Login(string username, string password)
        {
            bool result = false;

            if (OperationalState == OperationalStateEnum.Disposed)
            {
                return(false);
            }

            _messageLoopOperator.Invoke(delegate()
            {
                // This is a slow blocking call, make sure to execute outside of lock.
                MbtComMgr manager     = new MbtComMgr();
                _communicationManager = manager;
                //_communicationManager.OnLogonSucceed += new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);

                _orderClient            = _communicationManager.OrderClient;
                _orderClient.SilentMode = true;

                //_quotes.Initialize(_communicationManager.Quotes);
                //_history.Initialize(_communicationManager.HistMgr);
                ///_orders.Initialize(_adapter, this, _communicationManager);

                //_communicationManager.OnAlertAdded += new IMbtComMgrEvents_OnAlertAddedEventHandler(_communicationManager_OnAlertAdded);
                _communicationManager.EnableSplash(false);

                ChangeOperationalState(OperationalStateEnum.Initialized);
                _communicationManager.EnableSplash(false);
                _communicationManager.SilentMode = true;

                result = _communicationManager.DoLogin(HostId, username, password, "");
            }, TimeSpan.FromSeconds(25));

            return(result);
        }
Esempio n. 2
0
 public InstrumentReader(MbtOrderClient orderClient, MbtQuotes quotes, SymbolInfo instrument)
 {
     m_OrderClient  = orderClient;
     m_Quotes       = quotes;
     this.symbol    = instrument;
     lastChangeTime = Environment.TickCount;
 }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public bool Logout()
 {
     _orderClient = null;
     //_communicationManager.OnLogonSucceed -= new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);
     _communicationManager = null;
     GC.Collect();
     //_communicationManager.disp
     return(true);
 }
Esempio n. 4
0
		internal MBT () {
			Client = new MbtComMgr();
			Quotes = Client.Quotes;
			Orders = Client.OrderClient;

			Client.EnableSplash(false);
			Client.SilentMode = false;

			QN = new QuoteNotifier();
		}
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        public void UnInitialize()
        {
            try
            {
                if (_orderClient != null)
                {
                    // An exception is generated here, upon trying to unsubscribe these events, so we shall leave them be.
                    // the wrapper class around the actual COM does something and releases too early ??

                    // ALWAYS CONSUME ORDERS EVENTS AND OPERATIONS TROUGH THE _orderClient VARIABLE, NEVER like this "_commManager.OrderClient"

                    _orderClient.OnAccountLoaded -= new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(_ordersClient_OnAccountLoaded);
                    _orderClient.OnBalanceUpdate -= new _IMbtOrderClientEvents_OnBalanceUpdateEventHandler(_ordersClient_OnBalanceUpdate);
                    _orderClient.OnLogonSucceed  -= new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(_ordersClient_OnLogonSucceed);
                    _orderClient.OnHistoryAdded  -= new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(_orderClient_OnHistoryAdded);
                    _orderClient.OnSubmit        -= new _IMbtOrderClientEvents_OnSubmitEventHandler(_orderClient_OnSubmit);
                    _orderClient.OnAcknowledge   -= new _IMbtOrderClientEvents_OnAcknowledgeEventHandler(_orderClient_OnAcknowledge);
                    _orderClient.OnPositionAdded -= new _IMbtOrderClientEvents_OnPositionAddedEventHandler(_orderClient_OnPositionAdded);

                    _orderClient.OnExecute       -= new _IMbtOrderClientEvents_OnExecuteEventHandler(_orderClient_OnExecute);
                    _orderClient.OnReplacePlaced -= new _IMbtOrderClientEvents_OnReplacePlacedEventHandler(_orderClient_OnReplacePlaced);

                    _orderClient = null;
                }

                if (_timer != null)
                {
                    _timer.Dispose();
                    _timer = null;
                }

                if (_commManager != null)
                {
                    _commManager.OnAlertAdded -= new IMbtComMgrEvents_OnAlertAddedEventHandler(_commManager_OnAlertAdded);
                    _commManager = null;
                }
            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
            }
            finally
            {
                _orderClient = null;
                _timer       = null;
                _commManager = null;
                _manager     = null;
                _adapter     = null;
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        public bool Initialize(MBTradingAdapter adapter, MBTradingConnectionManager manager, MbtComMgr communicationManager)
        {
            SystemMonitor.CheckError(_messageLoopOperator.InvokeRequred == false, "Init must better be called on message loop method.");

            StatusSynchronizationEnabled = true;
            StatusSynchronizationSource  = manager;

            try
            {
                _adapter     = adapter;
                _commManager = communicationManager;
                _orderClient = _commManager.OrderClient;

                // *Never* subscribe to COM events of a property, always make sure to hold the object alive
                // http://www.codeproject.com/Messages/2189754/Re-Losing-COM-events-handler-in-Csharp-client.aspx


                // *** ALWAYS CONSUME ORDERS EVENTS AND OPERATIONS TROUGH THE _orderClient VARIABLE, NEVER like this "_commManager.OrderClient"
                _commManager.OnAlertAdded += new IMbtComMgrEvents_OnAlertAddedEventHandler(_commManager_OnAlertAdded);

                _manager = manager;

                _orderClient.SilentMode = true;

                _timer = new Timer(TimerUpdate, null, 10000, 1000);

                _orderClient.OnAccountLoaded += new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(_ordersClient_OnAccountLoaded);
                _orderClient.OnBalanceUpdate += new _IMbtOrderClientEvents_OnBalanceUpdateEventHandler(_ordersClient_OnBalanceUpdate);
                _orderClient.OnLogonSucceed  += new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(_ordersClient_OnLogonSucceed);
                _orderClient.OnHistoryAdded  += new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(_orderClient_OnHistoryAdded);
                _orderClient.OnSubmit        += new _IMbtOrderClientEvents_OnSubmitEventHandler(_orderClient_OnSubmit);
                _orderClient.OnAcknowledge   += new _IMbtOrderClientEvents_OnAcknowledgeEventHandler(_orderClient_OnAcknowledge);
                _orderClient.OnPositionAdded += new _IMbtOrderClientEvents_OnPositionAddedEventHandler(_orderClient_OnPositionAdded);

                _orderClient.OnExecute       += new _IMbtOrderClientEvents_OnExecuteEventHandler(_orderClient_OnExecute);
                _orderClient.OnReplacePlaced += new _IMbtOrderClientEvents_OnReplacePlacedEventHandler(_orderClient_OnReplacePlaced);
            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        void TimerUpdate(object state)
        {
            if (_messageLoopOperator == null)
            {
                return;
            }

            _messageLoopOperator.BeginInvoke(delegate()
            {
                MbtOrderClient orderClient = _orderClient;
                if (orderClient == null || orderClient.Accounts == null)
                {
                    return;
                }

                foreach (MbtAccount account in orderClient.Accounts)
                {
                    PerformUpdate(account, true, true, true);
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Make sure to call on Invoke'd thread.
        /// </summary>
        /// <param name="account"></param>
        void PerformUpdate(MbtAccount account, bool updateAccount, bool updateOrders, bool updatePositions)
        {
            //SystemMonitor.CheckError(_messageLoopOperator.InvokeRequred == false, "Invoke must not be required in baseMethod call.");

            MbtOrderClient             orderClient = _orderClient;
            MBTradingConnectionManager manager     = _manager;
            MBTradingQuote             quotes      = null;

            if (orderClient == null || manager == null)
            {
                return;
            }

            quotes = manager.Quotes;
            if (quotes == null)
            {
                return;
            }

            AccountInfo info;
            Dictionary <string, OrderInfo> pendingOrderInfos = new Dictionary <string, OrderInfo>();
            List <PositionInfo>            positionsInfos    = new List <PositionInfo>();

            lock (this)
            {
                if (updateOrders)
                {
                    // We need to send up only the latest of each orders histories, since prev ones are for previous states.
                    foreach (MbtOrderHistory history in _orderClient.OrderHistories)
                    {
                        Order.UpdateTypeEnum updateType;
                        OrderInfo?           orderInfo = ConvertToOrderInfo(history, out updateType);
                        if (orderInfo.HasValue)
                        {
                            pendingOrderInfos[orderInfo.Value.Id] = orderInfo.Value;
                        }
                    }

                    // Make sure open orders orderInfo is always on top.
                    foreach (MbtOpenOrder pOrd in _orderClient.OpenOrders)
                    {
                        OrderInfo?orderInfo = ConvertToOrderInfo(pOrd);
                        if (orderInfo.HasValue)
                        {
                            pendingOrderInfos[orderInfo.Value.Id] = orderInfo.Value;
                        }
                    }
                }

                if (updatePositions)
                {
                    foreach (MbtPosition position in _orderClient.Positions)
                    {
                        PositionInfo?positionInfo = ConvertToPositionInfo(position);
                        if (positionInfo.HasValue)
                        {
                            positionsInfos.Add(positionInfo.Value);
                        }
                    }
                }

                if (_accountInfo.HasValue)
                {
                    info = _accountInfo.Value;
                }
                else
                {
                    info      = new AccountInfo();
                    info.Guid = Guid.NewGuid();
                }

                ConvertAccount(account, ref info);

                _accountInfo = info;
            }

            MBTradingAdapter adapter = _adapter;

            if (adapter != null)
            {
                OrderExecutionSourceStub stub = adapter.OrderExecutionSourceStub;
                if (stub != null)
                {
                    if (updateAccount)
                    {
                        stub.UpdateAccountInfo(_accountInfo.Value);
                    }

                    if (updateOrders)
                    {
                        stub.UpdateOrdersInfo(_accountInfo.Value,
                                              GeneralHelper.GenerateSingleValueArray <Order.UpdateTypeEnum>(pendingOrderInfos.Count, Order.UpdateTypeEnum.Update),
                                              GeneralHelper.EnumerableToArray <OrderInfo>(pendingOrderInfos.Values));
                    }

                    if (updatePositions)
                    {
                        stub.UpdatePositionsInfo(_accountInfo.Value, positionsInfos.ToArray());
                    }
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public void UnInitialize()
        {
            try
            {
                if (_orderClient != null)
                {
                    // An exception is generated here, upon trying to unsubscribe these events, so we shall leave them be.
                    // the wrapper class around the actual COM does something and releases too early ??

                    // ALWAYS CONSUME ORDERS EVENTS AND OPERATIONS TROUGH THE _orderClient VARIABLE, NEVER like this "_commManager.OrderClient"

                    _orderClient.OnAccountLoaded -= new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(_ordersClient_OnAccountLoaded);
                    _orderClient.OnBalanceUpdate -= new _IMbtOrderClientEvents_OnBalanceUpdateEventHandler(_ordersClient_OnBalanceUpdate);
                    _orderClient.OnLogonSucceed -= new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(_ordersClient_OnLogonSucceed);
                    _orderClient.OnHistoryAdded -= new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(_orderClient_OnHistoryAdded);
                    _orderClient.OnSubmit -= new _IMbtOrderClientEvents_OnSubmitEventHandler(_orderClient_OnSubmit);
                    _orderClient.OnAcknowledge -= new _IMbtOrderClientEvents_OnAcknowledgeEventHandler(_orderClient_OnAcknowledge);
                    _orderClient.OnPositionAdded -= new _IMbtOrderClientEvents_OnPositionAddedEventHandler(_orderClient_OnPositionAdded);

                    _orderClient.OnExecute -= new _IMbtOrderClientEvents_OnExecuteEventHandler(_orderClient_OnExecute);
                    _orderClient.OnReplacePlaced -= new _IMbtOrderClientEvents_OnReplacePlacedEventHandler(_orderClient_OnReplacePlaced);

                    _orderClient = null;
                }

                if (_timer != null)
                {
                    _timer.Dispose();
                    _timer = null;
                }

                if (_commManager != null)
                {
                    _commManager.OnAlertAdded -= new IMbtComMgrEvents_OnAlertAddedEventHandler(_commManager_OnAlertAdded);
                    _commManager = null;
                }
            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
            }
            finally
            {
                _orderClient = null;
                _timer = null;
                _commManager = null;
                _manager = null;
                _adapter = null;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool Initialize(MBTradingAdapter adapter, MBTradingConnectionManager manager, MbtComMgr communicationManager)
        {
            SystemMonitor.CheckError(_messageLoopOperator.InvokeRequred == false, "Init must better be called on message loop method.");

            StatusSynchronizationEnabled = true;
            StatusSynchronizationSource = manager;

            try
            {
                _adapter = adapter;
                _commManager = communicationManager;
                _orderClient = _commManager.OrderClient;

                // *Never* subscribe to COM events of a property, always make sure to hold the object alive
                // http://www.codeproject.com/Messages/2189754/Re-Losing-COM-events-handler-in-Csharp-client.aspx

                // *** ALWAYS CONSUME ORDERS EVENTS AND OPERATIONS TROUGH THE _orderClient VARIABLE, NEVER like this "_commManager.OrderClient"
                _commManager.OnAlertAdded += new IMbtComMgrEvents_OnAlertAddedEventHandler(_commManager_OnAlertAdded);

                _manager = manager;

                _orderClient.SilentMode = true;

                _timer = new Timer(TimerUpdate, null, 10000, 1000);

                _orderClient.OnAccountLoaded += new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(_ordersClient_OnAccountLoaded);
                _orderClient.OnBalanceUpdate += new _IMbtOrderClientEvents_OnBalanceUpdateEventHandler(_ordersClient_OnBalanceUpdate);
                _orderClient.OnLogonSucceed += new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(_ordersClient_OnLogonSucceed);
                _orderClient.OnHistoryAdded += new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(_orderClient_OnHistoryAdded);
                _orderClient.OnSubmit += new _IMbtOrderClientEvents_OnSubmitEventHandler(_orderClient_OnSubmit);
                _orderClient.OnAcknowledge += new _IMbtOrderClientEvents_OnAcknowledgeEventHandler(_orderClient_OnAcknowledge);
                _orderClient.OnPositionAdded += new _IMbtOrderClientEvents_OnPositionAddedEventHandler(_orderClient_OnPositionAdded);

                _orderClient.OnExecute += new _IMbtOrderClientEvents_OnExecuteEventHandler(_orderClient_OnExecute);
                _orderClient.OnReplacePlaced += new _IMbtOrderClientEvents_OnReplacePlacedEventHandler(_orderClient_OnReplacePlaced);

            }
            catch (Exception ex)
            {
                SystemMonitor.OperationError(ex.Message);
                return false;
            }

            return true;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public bool Logout()
 {
     _orderClient = null;
     //_communicationManager.OnLogonSucceed -= new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);
     _communicationManager = null;
     GC.Collect();
     //_communicationManager.disp
     return true;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool Login(string username, string password)
        {
            bool result = false;

            if (OperationalState == OperationalStateEnum.Disposed)
            {
                return false;
            }

            _messageLoopOperator.Invoke(delegate()
            {
                // This is a slow blocking call, make sure to execute outside of lock.
                MbtComMgr manager = new MbtComMgr();
                _communicationManager = manager;
                //_communicationManager.OnLogonSucceed += new IMbtComMgrEvents_OnLogonSucceedEventHandler(_communicationManager_OnLogonSucceed);

                _orderClient = _communicationManager.OrderClient;
                _orderClient.SilentMode = true;

                //_quotes.Initialize(_communicationManager.Quotes);
                //_history.Initialize(_communicationManager.HistMgr);
                ///_orders.Initialize(_adapter, this, _communicationManager);

                //_communicationManager.OnAlertAdded += new IMbtComMgrEvents_OnAlertAddedEventHandler(_communicationManager_OnAlertAdded);
                _communicationManager.EnableSplash(false);

                ChangeOperationalState(OperationalStateEnum.Initialized);
                _communicationManager.EnableSplash(false);
                _communicationManager.SilentMode = true;

                result = _communicationManager.DoLogin(HostId, username, password, "");

            }, TimeSpan.FromSeconds(25));

            return result;
        }
Esempio n. 13
0
		 public ServerMB(TLServer tls)
        {
			  v("VerboseDebugging: " + VerboseDebugging);
            tl = tls;
            m_ComMgr = null;
            try
            {
					m_ComMgr = new MbtComMgr();  //pmh - Preferred. Was MbtComMgrClass(). Either should work.
            }
            catch (Exception ex)
            {
                System.Diagnostics.Process.Start(@"http://code.google.com/p/tradelink/wiki/ComFactoryErrors");
					 debug("m_ComMgr = new MbtComMgr() failed: " + ex.Message + ex.StackTrace); //pmh
					 return;
            }
//            m_ComMgr.SilentMode = true; //pmh - 9/18/12 - display login dialog if blank UID/Pwd (this allows me/pmh to connect to special servers for advanced testing)
            m_ComMgr.EnableSplash(false);
            m_OrderClient = m_ComMgr.OrderClient;
            m_OrderClient.SilentMode = true;
/* //pmh - OnDemandMode has been deprecated 
	if (!m_ComMgr.IsPreviousInstanceDetected("tradelink"))
	{
		m_OrderClient.OnDemandMode = false;                                             
		v("order client on demand mode disabled as previous tradelink was running.");   
	}
*/
            m_Quotes = m_ComMgr.Quotes;
            m_OpenOrders = m_OrderClient.OpenOrders;
            m_HistMgr = m_ComMgr.HistMgr;

            // tradelink bindings
            tl.newProviderName = Providers.MBTrading;
            tl.newFeatureRequest += new MessageArrayDelegate(tl_newFeatureRequest);
            tl.newSendOrderRequest += new OrderDelegateStatus(tl_newSendOrderRequest);
            tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols);
            tl.newOrderCancelRequest += new LongDelegate(tl_newOrderCancelRequest);
            tl.newAcctRequest += new StringDelegate(tl_newAcctRequest);
            tl.newPosList += new PositionAccountArrayDelegate(tl_newPosList);
            tl.newUnknownRequest += new UnknownMessageDelegate(tl_newUnknownRequest);

				//pmh - 8/29/12 - reordered alphabetically and added almost all remaining events

				// MB Trading MbtComMgr bindings
				m_ComMgr.OnAlertAdded += new IMbtComMgrEvents_OnAlertAddedEventHandler(m_ComMgr_OnAlertAdded); //pmh
				m_ComMgr.OnAlertsRefresh += new IMbtComMgrEvents_OnAlertsRefreshEventHandler(m_ComMgr_OnAlertsRefresh); //pmh
				m_ComMgr.OnCriticalShutdown += new IMbtComMgrEvents_OnCriticalShutdownEventHandler(m_ComMgr_OnCriticalShutdown); //pmh
				m_ComMgr.OnHealthUpdate += new IMbtComMgrEvents_OnHealthUpdateEventHandler(m_ComMgr_OnHealthUpdate);
				m_ComMgr.OnLogonDeny += new IMbtComMgrEvents_OnLogonDenyEventHandler(m_ComMgr_OnLogonDeny);
				m_ComMgr.OnLogonSucceed += new IMbtComMgrEvents_OnLogonSucceedEventHandler(m_ComMgr_OnLogonSucceed);
			  /*
			   * pmh - add later if desired
			   * 
				m_ComMgr.OnMATAccountPercentSet += new IMbtComMgrEvents_OnMATAccountPercentSetEventHandler(m_ComMgr_OnMATAccountPercentSet); //pmh
				m_ComMgr.OnMATGroupAccountAdded += new IMbtComMgrEvents_OnMATGroupAccountAddedEventHandler(m_ComMgr_OnMATGroupAccountAdded); //pmh
				m_ComMgr.OnMATGroupAccountRemoved += new IMbtComMgrEvents_OnMATGroupAccountRemovedEventHandler(m_ComMgr_OnMATGroupAccountRemoved); //pmh
				m_ComMgr.OnMATGroupsGroupAdded += new IMbtComMgrEvents_OnMATGroupsGroupAddedEventHandler(m_ComMgr_OnMATGroupsGroupAdded); //pmh
				m_ComMgr.OnMATGroupsGroupRemoved += new IMbtComMgrEvents_OnMATGroupsGroupRemovedEventHandler(m_ComMgr_OnMATGroupsGroupRemoved); //pmh
				m_ComMgr.OnMATGroupsGroupRenamed += new IMbtComMgrEvents_OnMATGroupsGroupRenamedEventHandler(m_ComMgr_OnMATGroupsGroupRenamed); //pmh
			   */
				
			  // MB Trading MbtOrderClient bindings
				m_OrderClient.OnAccountLoaded += new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(m_OrderClient_OnAccountLoaded);
				m_OrderClient.OnAccountLoading += new _IMbtOrderClientEvents_OnAccountLoadingEventHandler(m_OrderClient_OnAccountLoading);
				m_OrderClient.OnAccountUnavailable += new _IMbtOrderClientEvents_OnAccountUnavailableEventHandler(m_OrderClient_OnAccountUnavailable); //pmh
				m_OrderClient.OnAcknowledge += new _IMbtOrderClientEvents_OnAcknowledgeEventHandler(m_OrderClient_OnAcknowledge); //pmh
				m_OrderClient.OnBalanceUpdate += new _IMbtOrderClientEvents_OnBalanceUpdateEventHandler(m_OrderClient_OnBalanceUpdate); //pmh
				m_OrderClient.OnCancelPlaced += new _IMbtOrderClientEvents_OnCancelPlacedEventHandler(m_OrderClient_OnCancelPlaced);
				m_OrderClient.OnCancelRejected += new _IMbtOrderClientEvents_OnCancelRejectedEventHandler(m_OrderClient_OnCancelRejected);
				m_OrderClient.OnClose += new _IMbtOrderClientEvents_OnCloseEventHandler(m_OrderClient_OnClose);
				m_OrderClient.OnConnect += new _IMbtOrderClientEvents_OnConnectEventHandler(m_OrderClient_OnConnect);
				//pmh - 9/21/12 - See note on DefaultAccount at end of document!
				//m_OrderClient.OnDefaultAccountChanged += new _IMbtOrderClientEvents_OnDefaultAccountChangedEventHandler(m_OrderClient_OnDefaultAccountChanged); //pmh
				m_OrderClient.OnExecute += new _IMbtOrderClientEvents_OnExecuteEventHandler(m_OrderClient_OnExecute); //pmh
				m_OrderClient.OnHistoryAdded += new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(m_OrderClient_OnHistoryAdded);
				m_OrderClient.OnLogonSucceed += new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(m_OrderClient_OnLogonSucceed);
				m_OrderClient.OnPositionAdded += new _IMbtOrderClientEvents_OnPositionAddedEventHandler(m_OrderClient_OnPositionAdded);
				m_OrderClient.OnPositionStrategyGroupAdded += new _IMbtOrderClientEvents_OnPositionStrategyGroupAddedEventHandler(m_OrderClient_OnPositionStrategyGroupAdded); //pmh
				m_OrderClient.OnPositionStrategyGroupRemoved += new _IMbtOrderClientEvents_OnPositionStrategyGroupRemovedEventHandler(m_OrderClient_OnPositionStrategyGroupRemoved); //pmh
				m_OrderClient.OnPositionStrategyGroupUpdated += new _IMbtOrderClientEvents_OnPositionStrategyGroupUpdatedEventHandler(m_OrderClient_OnPositionStrategyGroupUpdated); //pmh
				m_OrderClient.OnPositionUpdated += new _IMbtOrderClientEvents_OnPositionUpdatedEventHandler(m_OrderClient_OnPositionUpdated);
				m_OrderClient.OnRemove += new _IMbtOrderClientEvents_OnRemoveEventHandler(m_OrderClient_OnRemove); //pmh
				m_OrderClient.OnReplacePlaced += new _IMbtOrderClientEvents_OnReplacePlacedEventHandler(m_OrderClient_OnReplacePlaced); //pmh
				m_OrderClient.OnReplaceRejected += new _IMbtOrderClientEvents_OnReplaceRejectedEventHandler(m_OrderClient_OnReplaceRejected); //pmh
				m_OrderClient.OnSubmit += new _IMbtOrderClientEvents_OnSubmitEventHandler(m_OrderClient_OnSubmit);

				// MB Trading MbtQuote bindings
				m_Quotes.OnClose += new _IMbtQuotesEvents_OnCloseEventHandler(m_Quotes_OnClose);
            m_Quotes.OnConnect += new _IMbtQuotesEvents_OnConnectEventHandler(m_Quotes_OnConnect);
            m_Quotes.OnLogonSucceed += new _IMbtQuotesEvents_OnLogonSucceedEventHandler(m_Quotes_OnLogonSucceed);

				// MB Trading MbtHist bindings
				m_HistMgr.OnDataEvent += new _IMbtHistEvents_OnDataEventEventHandler(m_HistMgr_OnDataEvent);
				m_HistMgr.OnError += new _IMbtHistEvents_OnErrorEventHandler(m_HistMgr_OnError);

				//disable old ticks
            //DisableOldTicks = Convert.ToBoolean(ConfigurationSettings.AppSettings["DisableOldTicks"]);
            DisableOldTicks = true;
            debug("TL binding and MBT Desktop event mapping complete.");
        }
Esempio n. 14
0
        public void Stop()
        {
            v("stopping ServerMB connector.");
				pt = null;
				m_HistMgr = null;
				m_OpenOrders = null;
				m_Quotes.UnadviseAll(this); //pmh - 9/18/12 - MUST NOT FORGET THIS!
            m_Quotes.Disconnect();
            m_OrderClient.Disconnect();
				m_Quotes = null;
				m_OrderClient = null;
				m_HistMgr = null;
			  
        }
Esempio n. 15
0
 public InstrumentReaders(Receiver providerClient, MbtOrderClient orderClient, MbtQuotes quotes)
 {
     this.receiver = providerClient;
     m_OrderClient = orderClient;
     m_Quotes      = quotes;
 }
Esempio n. 16
0
        public ServerMB(TLServer tls)
        {
            tl = tls;
            m_ComMgr = null;
            try
            {
                m_ComMgr = new MbtComMgrClass();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Process.Start(@"http://code.google.com/p/tradelink/wiki/ComFactoryErrors");
                debug("An error occured: " + ex.Message + ex.StackTrace);
                return;
            }
            m_ComMgr.SilentMode = true;
            m_ComMgr.EnableSplash(false);
            m_OrderClient = m_ComMgr.OrderClient;
            m_OrderClient.SilentMode = true;
            if (!m_ComMgr.IsPreviousInstanceDetected("tradelink"))
            {
                m_OrderClient.OnDemandMode = false;
                v("order client on demand mode disabled as previous tradelink was running.");
            }
            m_Quotes = m_ComMgr.Quotes;
            m_Orders = m_OrderClient.OpenOrders;
            m_Hist = m_ComMgr.HistMgr;

            // tradelink bindings
            tl.newProviderName = Providers.MBTrading;
            tl.newFeatureRequest += new MessageArrayDelegate(tl_newFeatureRequest);
            tl.newSendOrderRequest += new OrderDelegateStatus(tl_newSendOrderRequest);
            tl.newRegisterSymbols += new SymbolRegisterDel(tl_newRegisterSymbols);
            tl.newOrderCancelRequest += new LongDelegate(tl_newOrderCancelRequest);
            tl.newAcctRequest += new StringDelegate(tl_newAcctRequest);
            tl.newPosList += new PositionArrayDelegate(tl_newPosList);
            tl.newUnknownRequest += new UnknownMessageDelegate(tl_newUnknownRequest);

            // mb bindings
            m_OrderClient.OnAccountLoaded += new _IMbtOrderClientEvents_OnAccountLoadedEventHandler(m_OrderClient_OnAccountLoaded);
            m_OrderClient.OnAccountLoading += new _IMbtOrderClientEvents_OnAccountLoadingEventHandler(m_OrderClient_OnAccountLoading);
            m_OrderClient.OnSubmit += new _IMbtOrderClientEvents_OnSubmitEventHandler(m_OrderClient_OnSubmit);
            m_OrderClient.OnClose += new _IMbtOrderClientEvents_OnCloseEventHandler(m_OrderClient_OnClose);
            m_OrderClient.OnConnect += new _IMbtOrderClientEvents_OnConnectEventHandler(m_OrderClient_OnConnect);
            m_OrderClient.OnLogonSucceed += new _IMbtOrderClientEvents_OnLogonSucceedEventHandler(m_OrderClient_OnLogonSucceed);
            m_ComMgr.OnCriticalShutdown += new IMbtComMgrEvents_OnCriticalShutdownEventHandler(m_ComMgr_OnCriticalShutdown);
            m_ComMgr.OnHealthUpdate += new IMbtComMgrEvents_OnHealthUpdateEventHandler(m_ComMgr_OnHealthUpdate);
            m_ComMgr.OnLogonSucceed += new IMbtComMgrEvents_OnLogonSucceedEventHandler(m_ComMgr_OnLogonSucceed);
            m_ComMgr.OnLogonDeny += new IMbtComMgrEvents_OnLogonDenyEventHandler(m_ComMgr_OnLogonDeny);
            m_Quotes.OnClose += new _IMbtQuotesEvents_OnCloseEventHandler(m_Quotes_OnClose);
            m_Quotes.OnConnect += new _IMbtQuotesEvents_OnConnectEventHandler(m_Quotes_OnConnect);
            m_Quotes.OnLogonSucceed += new _IMbtQuotesEvents_OnLogonSucceedEventHandler(m_Quotes_OnLogonSucceed);
            m_OrderClient.OnPositionAdded += new _IMbtOrderClientEvents_OnPositionAddedEventHandler(m_OrderClient_OnPositionAdded);
            m_OrderClient.OnPositionUpdated += new _IMbtOrderClientEvents_OnPositionUpdatedEventHandler(m_OrderClient_OnPositionUpdated);
            //m_OrderClient.OnExecute += new _IMbtOrderClientEvents_OnExecuteEventHandler( m_OrderClient_OnExecute );
            m_OrderClient.OnCancelPlaced += new _IMbtOrderClientEvents_OnCancelPlacedEventHandler(m_OrderClient_OnCancelPlaced);
            m_OrderClient.OnCancelRejected += new _IMbtOrderClientEvents_OnCancelRejectedEventHandler(m_OrderClient_OnCancelRejected);
            //m_OrderClient.OnRemove += new _IMbtOrderClientEvents_OnRemoveEventHandler( m_OrderClient_OnRemove );
            m_OrderClient.OnHistoryAdded += new _IMbtOrderClientEvents_OnHistoryAddedEventHandler(m_OrderClient_OnHistoryAdded);
            m_Hist.OnDataEvent += new _IMbtHistEvents_OnDataEventEventHandler(m_Hist_OnDataEvent);
            //disable old ticks
            //DisableOldTicks = Convert.ToBoolean(ConfigurationSettings.AppSettings["DisableOldTicks"]);
            DisableOldTicks = true;
            debug("all binding configured successfully.");
        }